From d08b1e2a062c08a5e4528eabbe8fe1889f4ea49a Mon Sep 17 00:00:00 2001 From: Michael Bumann Date: Tue, 13 Aug 2024 06:01:40 +0200 Subject: [PATCH 1/3] Special help link (#463) --- frontend/src/components/layouts/AppLayout.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/layouts/AppLayout.tsx b/frontend/src/components/layouts/AppLayout.tsx index 160b14e9..81307d70 100644 --- a/frontend/src/components/layouts/AppLayout.tsx +++ b/frontend/src/components/layouts/AppLayout.tsx @@ -172,7 +172,7 @@ export default function AppLayout() { { - openLink("https://getalby.com/#help"); + openLink("https://getalby.com/help"); e.preventDefault(); }} > From 774c45b6f3d7da8d0f442a6697e893c2c9fec304 Mon Sep 17 00:00:00 2001 From: Roland <33993199+rolznz@users.noreply.github.com> Date: Tue, 13 Aug 2024 12:54:40 +0700 Subject: [PATCH 2/3] fix: do not require jwt for oauth callback, disable service worker (#465) * fix: do not require jwt for oauth callback, disable service worker * fix: remove debug log * fix: comment --- frontend/vite.config.ts | 5 +-- http/alby_http_service.go | 18 ++++----- http/http_service.go | 84 +++++++++++++++++++-------------------- 3 files changed, 53 insertions(+), 54 deletions(-) diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 87232345..bd72f10b 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -10,6 +10,8 @@ export default defineConfig(({ command }) => ({ tsconfigPaths(), VitePWA({ registerType: "autoUpdate", + // disable service worker - Alby Hub cannot be used offline (and also breaks oauth callback) + injectRegister: false, includeAssets: [ "favicon.ico", "robots.txt", @@ -41,9 +43,6 @@ export default defineConfig(({ command }) => ({ theme_color: "#000000", background_color: "#ffffff", }, - workbox: { - globPatterns: ["**/*.{js,css,html,png,svg,ico}"], - }, }), ...(command === "serve" ? [insertDevCSPPlugin] : []), ], diff --git a/http/alby_http_service.go b/http/alby_http_service.go index 4358f14f..a88b5b62 100644 --- a/http/alby_http_service.go +++ b/http/alby_http_service.go @@ -25,15 +25,15 @@ func NewAlbyHttpService(svc service.Service, albyOAuthSvc alby.AlbyOAuthService, } } -func (albyHttpSvc *AlbyHttpService) RegisterSharedRoutes(r *echo.Group) { - r.GET("/api/alby/callback", albyHttpSvc.albyCallbackHandler) - r.GET("/api/alby/me", albyHttpSvc.albyMeHandler) - r.GET("/api/alby/balance", albyHttpSvc.albyBalanceHandler) - r.POST("/api/alby/pay", albyHttpSvc.albyPayHandler) - r.POST("/api/alby/drain", albyHttpSvc.albyDrainHandler) - r.POST("/api/alby/link-account", albyHttpSvc.albyLinkAccountHandler) - r.POST("/api/alby/auto-channel", albyHttpSvc.autoChannelHandler) - r.POST("/api/alby/unlink-account", albyHttpSvc.unlinkHandler) +func (albyHttpSvc *AlbyHttpService) RegisterSharedRoutes(restrictedGroup *echo.Group, e *echo.Echo) { + e.GET("/api/alby/callback", albyHttpSvc.albyCallbackHandler) + restrictedGroup.GET("/api/alby/me", albyHttpSvc.albyMeHandler) + restrictedGroup.GET("/api/alby/balance", albyHttpSvc.albyBalanceHandler) + restrictedGroup.POST("/api/alby/pay", albyHttpSvc.albyPayHandler) + restrictedGroup.POST("/api/alby/drain", albyHttpSvc.albyDrainHandler) + restrictedGroup.POST("/api/alby/link-account", albyHttpSvc.albyLinkAccountHandler) + restrictedGroup.POST("/api/alby/auto-channel", albyHttpSvc.autoChannelHandler) + restrictedGroup.POST("/api/alby/unlink-account", albyHttpSvc.unlinkHandler) } func (albyHttpSvc *AlbyHttpService) autoChannelHandler(c echo.Context) error { diff --git a/http/http_service.go b/http/http_service.go index 2895ccde..bd0cf268 100644 --- a/http/http_service.go +++ b/http/http_service.go @@ -107,48 +107,48 @@ func (httpSvc *HttpService) RegisterSharedRoutes(e *echo.Echo) { }, SigningKey: []byte(httpSvc.cfg.GetJWTSecret()), } - r := e.Group("") - r.Use(echojwt.WithConfig(jwtConfig)) - - r.GET("/api/apps", httpSvc.appsListHandler) - r.GET("/api/apps/:pubkey", httpSvc.appsShowHandler) - r.PATCH("/api/apps/:pubkey", httpSvc.appsUpdateHandler) - r.DELETE("/api/apps/:pubkey", httpSvc.appsDeleteHandler) - r.POST("/api/apps", httpSvc.appsCreateHandler) - r.POST("/api/mnemonic", httpSvc.mnemonicHandler) - r.PATCH("/api/backup-reminder", httpSvc.backupReminderHandler) - r.GET("/api/channels", httpSvc.channelsListHandler) - r.POST("/api/channels", httpSvc.openChannelHandler) - r.GET("/api/channels/suggestions", httpSvc.channelPeerSuggestionsHandler) - r.POST("/api/lsp-orders", httpSvc.newInstantChannelInvoiceHandler) - r.GET("/api/node/connection-info", httpSvc.nodeConnectionInfoHandler) - r.GET("/api/node/status", httpSvc.nodeStatusHandler) - r.GET("/api/node/network-graph", httpSvc.nodeNetworkGraphHandler) - r.GET("/api/peers", httpSvc.listPeers) - r.POST("/api/peers", httpSvc.connectPeerHandler) - r.DELETE("/api/peers/:peerId", httpSvc.disconnectPeerHandler) - r.DELETE("/api/peers/:peerId/channels/:channelId", httpSvc.closeChannelHandler) - r.PATCH("/api/peers/:peerId/channels/:channelId", httpSvc.updateChannelHandler) - r.GET("/api/wallet/address", httpSvc.onchainAddressHandler) - r.POST("/api/wallet/new-address", httpSvc.newOnchainAddressHandler) - r.POST("/api/wallet/redeem-onchain-funds", httpSvc.redeemOnchainFundsHandler) - r.POST("/api/wallet/sign-message", httpSvc.signMessageHandler) - r.POST("/api/wallet/sync", httpSvc.walletSyncHandler) - r.GET("/api/wallet/capabilities", httpSvc.capabilitiesHandler) - r.POST("/api/payments/:invoice", httpSvc.sendPaymentHandler) - r.POST("/api/invoices", httpSvc.makeInvoiceHandler) - r.GET("/api/transactions", httpSvc.listTransactionsHandler) - r.GET("/api/transactions/:paymentHash", httpSvc.lookupTransactionHandler) - r.GET("/api/balances", httpSvc.balancesHandler) - r.POST("/api/reset-router", httpSvc.resetRouterHandler) - r.POST("/api/stop", httpSvc.stopHandler) - r.GET("/api/mempool", httpSvc.mempoolApiHandler) - r.POST("/api/send-payment-probes", httpSvc.sendPaymentProbesHandler) - r.POST("/api/send-spontaneous-payment-probes", httpSvc.sendSpontaneousPaymentProbesHandler) - r.GET("/api/log/:type", httpSvc.getLogOutputHandler) - r.POST("/api/backup", httpSvc.createBackupHandler) - - httpSvc.albyHttpSvc.RegisterSharedRoutes(r) + restrictedGroup := e.Group("") + restrictedGroup.Use(echojwt.WithConfig(jwtConfig)) + + restrictedGroup.GET("/api/apps", httpSvc.appsListHandler) + restrictedGroup.GET("/api/apps/:pubkey", httpSvc.appsShowHandler) + restrictedGroup.PATCH("/api/apps/:pubkey", httpSvc.appsUpdateHandler) + restrictedGroup.DELETE("/api/apps/:pubkey", httpSvc.appsDeleteHandler) + restrictedGroup.POST("/api/apps", httpSvc.appsCreateHandler) + restrictedGroup.POST("/api/mnemonic", httpSvc.mnemonicHandler) + restrictedGroup.PATCH("/api/backup-reminder", httpSvc.backupReminderHandler) + restrictedGroup.GET("/api/channels", httpSvc.channelsListHandler) + restrictedGroup.POST("/api/channels", httpSvc.openChannelHandler) + restrictedGroup.GET("/api/channels/suggestions", httpSvc.channelPeerSuggestionsHandler) + restrictedGroup.POST("/api/lsp-orders", httpSvc.newInstantChannelInvoiceHandler) + restrictedGroup.GET("/api/node/connection-info", httpSvc.nodeConnectionInfoHandler) + restrictedGroup.GET("/api/node/status", httpSvc.nodeStatusHandler) + restrictedGroup.GET("/api/node/network-graph", httpSvc.nodeNetworkGraphHandler) + restrictedGroup.GET("/api/peers", httpSvc.listPeers) + restrictedGroup.POST("/api/peers", httpSvc.connectPeerHandler) + restrictedGroup.DELETE("/api/peers/:peerId", httpSvc.disconnectPeerHandler) + restrictedGroup.DELETE("/api/peers/:peerId/channels/:channelId", httpSvc.closeChannelHandler) + restrictedGroup.PATCH("/api/peers/:peerId/channels/:channelId", httpSvc.updateChannelHandler) + restrictedGroup.GET("/api/wallet/address", httpSvc.onchainAddressHandler) + restrictedGroup.POST("/api/wallet/new-address", httpSvc.newOnchainAddressHandler) + restrictedGroup.POST("/api/wallet/redeem-onchain-funds", httpSvc.redeemOnchainFundsHandler) + restrictedGroup.POST("/api/wallet/sign-message", httpSvc.signMessageHandler) + restrictedGroup.POST("/api/wallet/sync", httpSvc.walletSyncHandler) + restrictedGroup.GET("/api/wallet/capabilities", httpSvc.capabilitiesHandler) + restrictedGroup.POST("/api/payments/:invoice", httpSvc.sendPaymentHandler) + restrictedGroup.POST("/api/invoices", httpSvc.makeInvoiceHandler) + restrictedGroup.GET("/api/transactions", httpSvc.listTransactionsHandler) + restrictedGroup.GET("/api/transactions/:paymentHash", httpSvc.lookupTransactionHandler) + restrictedGroup.GET("/api/balances", httpSvc.balancesHandler) + restrictedGroup.POST("/api/reset-router", httpSvc.resetRouterHandler) + restrictedGroup.POST("/api/stop", httpSvc.stopHandler) + restrictedGroup.GET("/api/mempool", httpSvc.mempoolApiHandler) + restrictedGroup.POST("/api/send-payment-probes", httpSvc.sendPaymentProbesHandler) + restrictedGroup.POST("/api/send-spontaneous-payment-probes", httpSvc.sendSpontaneousPaymentProbesHandler) + restrictedGroup.GET("/api/log/:type", httpSvc.getLogOutputHandler) + restrictedGroup.POST("/api/backup", httpSvc.createBackupHandler) + + httpSvc.albyHttpSvc.RegisterSharedRoutes(restrictedGroup, e) } func (httpSvc *HttpService) infoHandler(c echo.Context) error { From 14b071a5c903ddba9197a955df8e2e1eed08fac1 Mon Sep 17 00:00:00 2001 From: Roland <33993199+rolznz@users.noreply.github.com> Date: Tue, 13 Aug 2024 21:38:19 +0700 Subject: [PATCH 3/3] feat: add alby cloud link (#471) --- frontend/src/components/layouts/AppLayout.tsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/frontend/src/components/layouts/AppLayout.tsx b/frontend/src/components/layouts/AppLayout.tsx index 81307d70..303aa851 100644 --- a/frontend/src/components/layouts/AppLayout.tsx +++ b/frontend/src/components/layouts/AppLayout.tsx @@ -1,5 +1,6 @@ import { Cable, + Cloud, EllipsisVertical, ExternalLinkIcon, Home, @@ -179,6 +180,18 @@ export default function AppLayout() { Live Support + {!albyMe?.hub.name && ( + { + openLink("https://getalby.com/subscription/new"); + e.preventDefault(); + }} + > + + Alby Cloud + + )} ); }