diff --git a/config.json b/config.json index 1f58e7b..afe7ed5 100644 --- a/config.json +++ b/config.json @@ -1,17 +1,8 @@ { "name": "Nostr Client", - "short_description": "Nostr relay multiplexer", "version": "1.1.0", + "short_description": "Nostr client for extensions", "tile": "/nostrclient/static/images/nostr-bitcoin.png", "contributors": ["calle", "motorina0", "dni"], - "min_lnbits_version": "1.4.0", - "images": [ - { - "uri": "https://raw.githubusercontent.com/lnbits/nostrclient/add-extension-metadata/static/images/1.jpeg" - }, - { - "uri": "https://raw.githubusercontent.com/lnbits/nostrclient/add-extension-metadata/static/images/2.jpeg" - } - ], - "description_md": "https://raw.githubusercontent.com/lnbits/nostrclient/add-extension-metadata/description.md" + "min_lnbits_version": "1.0.0" } diff --git a/description.md b/description.md index 5293087..6c274f3 100644 --- a/description.md +++ b/description.md @@ -1,8 +1 @@ -An always-on relay multiplexer that simplifies connecting to multiple Nostr relays. - -Instead of your Nostr client managing connections to dozens of relays, you connect to a single WebSocket endpoint provided by `nostrclient`, which then fans out your requests to all configured relays and aggregates the responses back to you. - -- **Simplified Client Configuration** - Connect to one endpoint instead of managing multiple relay connections -- **Always-On Connectivity** - Your LNbits instance maintains persistent connections to relays -- **Resource Efficient** - Share relay connections across multiple clients -- **Automatic Subscription Management** - Subscription ID rewriting prevents conflicts between clients +An always-on extension that can open multiple connections to nostr relays and act as a multiplexer for other clients: You open a single websocket to nostrclient which then sends the data to multiple relays. The responses from these relays are then sent back to the client. diff --git a/static/images/1.jpeg b/static/images/1.jpeg deleted file mode 100644 index 1f00661..0000000 Binary files a/static/images/1.jpeg and /dev/null differ diff --git a/static/images/2.jpeg b/static/images/2.jpeg deleted file mode 100644 index e7301fd..0000000 Binary files a/static/images/2.jpeg and /dev/null differ diff --git a/templates/nostrclient/index.html b/templates/nostrclient/index.html index ca44f1b..0c9b468 100644 --- a/templates/nostrclient/index.html +++ b/templates/nostrclient/index.html @@ -476,7 +476,11 @@ getRelays: function () { var self = this LNbits.api - .request('GET', '/nostrclient/api/v1/relays') + .request( + 'GET', + '/nostrclient/api/v1/relays?usr=' + this.g.user.id, + this.g.user.wallets[0].adminkey + ) .then(function (response) { if (response.data) { response.data.map(maplrelays) @@ -504,9 +508,12 @@ console.log('ADD RELAY ' + this.relayToAdd) let that = this LNbits.api - .request('POST', '/nostrclient/api/v1/relay', null, { - url: this.relayToAdd - }) + .request( + 'POST', + '/nostrclient/api/v1/relay?usr=' + this.g.user.id, + this.g.user.wallets[0].adminkey, + {url: this.relayToAdd} + ) .then(function (response) { console.log('response:', response) if (response.data) { @@ -533,7 +540,12 @@ }, deleteRelay(url) { LNbits.api - .request('DELETE', '/nostrclient/api/v1/relay', null, {url: url}) + .request( + 'DELETE', + '/nostrclient/api/v1/relay?usr=' + this.g.user.id, + this.g.user.wallets[0].adminkey, + {url: url} + ) .then(response => { const relayIndex = this.nostrrelayLinks.indexOf(r => r.url === url) if (relayIndex !== -1) { @@ -549,7 +561,8 @@ try { const {data} = await LNbits.api.request( 'GET', - '/nostrclient/api/v1/config' + '/nostrclient/api/v1/config', + this.g.user.wallets[0].adminkey ) this.config.data = data } catch (error) { @@ -561,7 +574,7 @@ const {data} = await LNbits.api.request( 'PUT', '/nostrclient/api/v1/config', - null, + this.g.user.wallets[0].adminkey, this.config.data ) this.config.data = data @@ -610,7 +623,7 @@ const {data} = await LNbits.api.request( 'PUT', '/nostrclient/api/v1/relay/test', - null, + this.g.user.wallets[0].adminkey, { sender_private_key: this.testData.senderPrivateKey, reciever_public_key: this.testData.recieverPublicKey, diff --git a/views.py b/views.py index 3d90198..cb2dd89 100644 --- a/views.py +++ b/views.py @@ -1,7 +1,6 @@ from fastapi import APIRouter, Depends, Request from fastapi.responses import HTMLResponse -from lnbits.core.crud.users import get_user_from_account -from lnbits.core.models.users import Account +from lnbits.core.models import User from lnbits.decorators import check_admin from lnbits.helpers import template_renderer @@ -13,10 +12,7 @@ def nostr_renderer(): @nostrclient_generic_router.get("/", response_class=HTMLResponse) -async def index(request: Request, account: Account = Depends(check_admin)): - user = await get_user_from_account(account) - if not user: - return HTMLResponse("No user found", status_code=404) +async def index(request: Request, user: User = Depends(check_admin)): return nostr_renderer().TemplateResponse( "nostrclient/index.html", {"request": request, "user": user.json()} )