diff --git a/echo_handlers.go b/echo_handlers.go index 34d2e1d3..35f7b1f2 100644 --- a/echo_handlers.go +++ b/echo_handlers.go @@ -68,7 +68,6 @@ func (svc *Service) AppsListHandler(c echo.Context) error { if err != nil { return c.JSON(http.StatusBadRequest, ErrorResponse{ Error: true, - Code: 8, Message: fmt.Sprintf("Bad arguments %s", err.Error()), }) } @@ -105,7 +104,6 @@ func (svc *Service) AppsShowHandler(c echo.Context) error { if err != nil { return c.JSON(http.StatusBadRequest, ErrorResponse{ Error: true, - Code: 8, Message: fmt.Sprintf("Bad arguments %s", err.Error()), }) } @@ -117,10 +115,8 @@ func (svc *Service) AppsShowHandler(c echo.Context) error { svc.db.Where("user_id = ? AND nostr_pubkey = ?", user.ID, c.Param("pubkey")).First(&app) if app.NostrPubkey == "" { - // TODO: Show not found? - return c.JSON(http.StatusBadRequest, ErrorResponse{ + return c.JSON(http.StatusNotFound, ErrorResponse{ Error: true, - Code: 8, Message: "App does not exist", }) } @@ -184,7 +180,6 @@ func (svc *Service) AppsCreateHandler(c echo.Context) error { if err != nil { return c.JSON(http.StatusBadRequest, ErrorResponse{ Error: true, - Code: 8, Message: fmt.Sprintf("Bad arguments %s", err.Error()), }) } @@ -206,7 +201,6 @@ func (svc *Service) AppsCreateHandler(c echo.Context) error { svc.Logger.Errorf("Invalid public key format: %s", pairingPublicKey) return c.JSON(http.StatusBadRequest, ErrorResponse{ Error: true, - Code: 8, Message: fmt.Sprintf("Invalid public key format: %s", pairingPublicKey), }) } @@ -222,7 +216,6 @@ func (svc *Service) AppsCreateHandler(c echo.Context) error { svc.Logger.Errorf("Invalid expiresAt: %s", pairingPublicKey) return c.JSON(http.StatusBadRequest, ErrorResponse{ Error: true, - Code: 8, Message: fmt.Sprintf("Invalid expiresAt: %v", err), }) } @@ -273,7 +266,6 @@ func (svc *Service) AppsCreateHandler(c echo.Context) error { }).Errorf("Failed to save app: %v", err) return c.JSON(http.StatusInternalServerError, ErrorResponse{ Error: true, - Code: 8, Message: fmt.Sprintf("Failed to save app: %v", err), }) } diff --git a/frontend/index.html b/frontend/index.html index 5f13130d..dd2981cf 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -4,7 +4,7 @@ Alby - Nostr Wallet Connect - +
diff --git a/frontend/src/assets/images/logo.svg b/frontend/src/assets/images/logo.svg index 0e8993ac..4caecebd 100644 --- a/frontend/src/assets/images/logo.svg +++ b/frontend/src/assets/images/logo.svg @@ -1 +1,18 @@ - \ No newline at end of file + + + + + + + + + + + + \ No newline at end of file diff --git a/frontend/src/screens/Login.tsx b/frontend/src/screens/Login.tsx index c8bf88a6..24f6d0dd 100644 --- a/frontend/src/screens/Login.tsx +++ b/frontend/src/screens/Login.tsx @@ -1,7 +1,11 @@ import nwcLogo from "../assets/images/nwc-logo.svg"; import albyHead from "../assets/images/alby-head.svg"; +import { useInfo } from "../hooks/useInfo"; function Login() { + const { data: info } = useInfo(); + const isAlby = info?.backendType === "ALBY"; + return (

- Securely connect your Alby Account to Nostr clients and applications. + Securely connect your {isAlby ? "Alby Account" : "LND Wallet"} to Nostr + clients and applications.

-

- - - Log in with Alby Account - -

+ {isAlby && ( +

+ + + Log in with Alby Account + +

+ )}

diff --git a/frontend/src/screens/apps/NewApp.tsx b/frontend/src/screens/apps/NewApp.tsx index e07ee611..a9b58037 100644 --- a/frontend/src/screens/apps/NewApp.tsx +++ b/frontend/src/screens/apps/NewApp.tsx @@ -117,11 +117,11 @@ const NewApp = () => { const formData = new FormData(); formData.append("name", appName); - formData.append("pubkey", pubkey); formData.append("maxAmount", maxAmount.toString()); formData.append("budgetRenewal", budgetRenewal); formData.append("expiresAt", expiresAt); formData.append("requestMethods", requestMethods); + formData.append("pubkey", pubkey); formData.append("returnTo", returnTo); try { @@ -164,6 +164,22 @@ const NewApp = () => { [NIP_47_PAY_INVOICE_METHOD]: LightningIcon, }; + const expiryOptions: Record = { + "1 week": 7, + "1 month": 30, + "1 year": 365, + Never: 0, + }; + + const budgetOptions: Record = { + "10k": 10_000, + "25k": 25_000, + "50k": 50_000, + "100k": 100_000, + "1M": 100_000_000, + Unlimited: 0, + }; + return (

@@ -172,11 +188,7 @@ const NewApp = () => {
- - - - - {!nameParam ? ( + {!nameParam && ( <>

)} diff --git a/models.go b/models.go index 4f56a251..dd566956 100644 --- a/models.go +++ b/models.go @@ -208,7 +208,6 @@ type LookupInvoiceResponse struct { type ErrorResponse struct { Error bool `json:"error"` - Code int `json:"code"` Message string `json:"message"` } diff --git a/views/404.html b/views/404.html deleted file mode 100644 index d87030b7..00000000 --- a/views/404.html +++ /dev/null @@ -1,12 +0,0 @@ -{{define "body"}} - -
-

404 Page Not Found

-

- The page you are looking for does not exist. -

-
- -{{end}} diff --git a/views/about.html b/views/about.html deleted file mode 100644 index 030b4501..00000000 --- a/views/about.html +++ /dev/null @@ -1,133 +0,0 @@ -{{define "body"}} - -
-

tl;dr

-

- Nostr Wallet Connect (NWC) is a way for applications like Nostr clients to access a remote Lightning wallet through a standardized protocol. - For instance, you can link your Alby account with any other application using this feature. -

-
- -
-

How to connect your app?

-
    -
  1. - Create a new app connection -

    - Enable the application by creating a permissioned connection to your wallet. This access - can be revoked at any time. -

    -
  2. -
  3. - Connect your app -

    - Connect your application by adding the connection secret. Either by - scanning the connect QR code or clicking a link. -

    -
  4. -
  5. - Done -

    - Zapp and Boost! Your lightning wallet is available where you need it. -
    - And if you ever want to disable it again, simply disconnect the connection again. -

    -
  6. -
-
- -
- -

FAQs

- -

How does it work?

-

- Nostr Wallet Connect uses the existing Nostr infrastructure to allow - applications to communicate with lightning wallets. This makes it easy for - developers to integrate and gives the users full flexibility on choice. -
- To learn more about the details have a look at - the specs (NIP47) -

- -

Which apps support it?

-

- Amethyst - is the first Nostr Client to fully support Nostr Wallet Connect. More are - working on support for it and are following shortly. -

- -

Is it open source?

-

- Of course! Nostr Wallet Connect is an open standard and our implementation - is - open source on GitHub -

- -

Can I run my own?

-

- Yes, Nostr Wallet Connect is for every wallet and can easily be - self-hosted.
- We are looking for contributors to add support for more wallet backends. If - you're interested please contact us - on GitHub - or - hello@getalby.com -

- -
- -
-

For developers

-

- Nostr Wallet Connect is an open protocol enabling applications to interact - with bitcoin lightning wallets. It allows users to connect their existing - wallets to your application allowing you to easily integrate bitcoin - lightning functionality but still focus on the core functionality of your - app. -

- - - -

- Happy zapping! - Bitcoin on Nostr -

-
- -{{end}} diff --git a/views/application.css b/views/application.css deleted file mode 100644 index bd6213e1..00000000 --- a/views/application.css +++ /dev/null @@ -1,3 +0,0 @@ -@tailwind base; -@tailwind components; -@tailwind utilities; \ No newline at end of file diff --git a/views/apps/create.html b/views/apps/create.html deleted file mode 100644 index 47560ac6..00000000 --- a/views/apps/create.html +++ /dev/null @@ -1,128 +0,0 @@ -{{define "body"}} - - -
-

- 🚀 Almost there! -

-
- Complete the last step of the setup by pasting or scanning your connection's pairing secret in the desired app to finalise the connection. -
- -
- - - - - Open in supported app - -
- Only connect with apps you trust! -
- - {{if not (eq .PairingSecret "")}} -
Manually pair app ↓
- - - - {{end}} -
- - -
- - - - -{{end}} diff --git a/views/apps/index.html b/views/apps/index.html deleted file mode 100644 index e749eb20..00000000 --- a/views/apps/index.html +++ /dev/null @@ -1,63 +0,0 @@ -{{define "body"}} - -
-

Connected apps

- - - - Connect app - -
- -
- - - - - - - - - - {{if not .Apps}} - - - - {{else}} - {{range .Apps}} - - - - - - {{end}} - {{end}} - -
Name
- No apps connected yet. -
- {{.Name}} - - Details -
-
- -{{end}} diff --git a/views/apps/new.html b/views/apps/new.html deleted file mode 100644 index f5d899c2..00000000 --- a/views/apps/new.html +++ /dev/null @@ -1,224 +0,0 @@ -{{define "body"}} - -

- {{if .Name}} - Connect to {{.Name}} - {{else}} - Connect a new app - {{end}} -

- - -
-
- - - - - {{if (eq .Name "")}} - - -

- Name of the app or purpose of the connection -

- {{else}} - - {{end}} - - - - -
- -
-

Authorize the app to:

- {{if (eq .CustomRequestMethods "")}} - - {{end}} -
-
-
    - {{range $key, $value := .RequestMethodHelper}} - - {{ end }} -
-
- - {{if (eq .ExpiresAt "")}} -
- + Add connection expiry time -
- - - {{else}} -

Connection expiry time

-

{{ .ExpiresAtFormatted }}

- {{end}} - - {{if .User.Email}} -

- You're logged in as {{.User.Email}}
-

- {{end}} -
- -
- {{ if not .Pubkey }} - - Cancel - - {{ end }} - -
- - - -{{end}} diff --git a/views/apps/show.html b/views/apps/show.html deleted file mode 100644 index c74fca3e..00000000 --- a/views/apps/show.html +++ /dev/null @@ -1,83 +0,0 @@ -{{define "body"}} - - -

{{.App.Name}}

-

{{.App.Description}}

- - ← - Back to overview - - -
-
-
- - - - - - - - - - - - - -
Public Key{{.App.NostrPubkey}}
Last used - {{if gt .EventsCount 0 }} - {{.LastEvent.CreatedAt.Format "02 Jan 06 15:04 MST" }} - {{else}} - never - {{end}} -
Expires at - {{ if not .ExpiresAt.IsZero}} - {{.ExpiresAtFormatted}} - {{else}} - never - {{end}} -
-
- -
-

Permissions

-
    - {{range .RequestMethods}} -
  • - - {{ . }} -
  • - {{end}} -
- {{ if gt .PaySpecificPermission.MaxAmount 0 }} -
- - - - - - - - - -
Budget{{.PaySpecificPermission.MaxAmount}} sats ({{.BudgetUsage}} sats used)
Renews in{{.RenewsIn}} (set to {{.PaySpecificPermission.BudgetRenewal}})
-
- {{ end }} -
- -
-

⚠️ Danger zone

-

- This will revoke the permission and will no longer allow calls from this public key. -

-
-
- -
- - -
-
- -{{end}} diff --git a/views/backends/alby/index.html b/views/backends/alby/index.html deleted file mode 100644 index 5a5aad1c..00000000 --- a/views/backends/alby/index.html +++ /dev/null @@ -1,49 +0,0 @@ -{{define "body"}} - -
- Nostr Wallet Connect logo - -

- Nostr Wallet Connect -

- -

- Securely connect your Alby Account to Nostr clients and applications. -

- -

- - - Log in with Alby Account - -

- -

- How does it work? -

-
- - - -{{end}} diff --git a/views/backends/lnd/index.html b/views/backends/lnd/index.html deleted file mode 100644 index a077d513..00000000 --- a/views/backends/lnd/index.html +++ /dev/null @@ -1,26 +0,0 @@ -{{define "body"}} - -
- Nostr Wallet Connect logo - -

- Nostr Wallet Connect -

- -

- Securely connect your LND wallet to Nostr clients and applications. -

- -

- How does it work? -

-
- - - -{{end}} diff --git a/views/layout.html b/views/layout.html deleted file mode 100644 index b9746008..00000000 --- a/views/layout.html +++ /dev/null @@ -1,125 +0,0 @@ -{{define "layout.html"}} - - - - - - Alby - Nostr Wallet Connect - - - - - - -
- -
-
- {{template "body" .}} -
- - - - - -{{end}}