Giter Site home page Giter Site logo

getalby / lightning-browser-extension Goto Github PK

View Code? Open in Web Editor NEW
515.0 17.0 189.0 34.29 MB

The Bitcoin Lightning Browser extension that connects to different wallet interfaces and brings deep lightning integration to the web

Home Page: https://getalby.com

License: MIT License

JavaScript 3.35% HTML 0.14% CSS 0.15% TypeScript 96.22% Shell 0.13%
bitcoin lightning browser-extension lightning-network webln lnurl wallet nostr chrome-extension firefox-extension

lightning-browser-extension's Introduction

Alby Logo

Alby - Lightning Browser Extension

A browser extension to bring the Bitcoin Lightning Network to the browser

The extension provides deep Lightning Network integration for websites (for payments and authentication flows).

The goal is to write a minimal web extension to allow browsers to interact with the Lightning Network programmatically. It focuses on the web-payments process and does not try to be a full node UI with advanced channel-management or similar features.

The extension implements the WebLN standard as the interface that allows websites to connect to Lightning Network nodes (to request payments, invoices, signatures, login, etc.) and enable seamless UX of web payments and authentications.

The extension can connect to different node implementations and supports custodial and non-custodial setups.

Some Features

  • Custom budgets/allowances for websites to allow payment streams/auto-payments
  • Multiple accounts and support for different node backends (lnd, etc.)
  • Full WebLN send and receive payment flows (getInfo, sendPayment, fixed makeInvoice support)
  • LNURL-pay support
  • LNURL-auth support
  • Payment history with additional website metadata
  • LNURL-withdraw support
  • WebLN signMessage, verifyMessage support
  • WebLN dynamic makeInvoice support
  • Keysend
  • Lsat support

STATUS: 🚀

About Alby

Alby is open-source, our goal is to create the best online experience to consume and reward content and services online.

Join the conversation

Browser Support

Alby supports

Installation

Add Alby to your browser

Try out the most recent version of Alby (Nightly Releases)

  • Firefox Nightly - best to install it as a temporary add-on as discussed in the "Load extension into browser" section
  • Chrome Nightly
    • for Chrome: go to chrome://extensions/, enable "Developer mode" (top right), and drag & drop the file in the browser
    • for Edge: go to edge://extensions/, enable "Developer mode" (left column), and load the unpacked file in the browser

(Note: You might need to reconfigure your wallet after installing new versions)

Architecture Idea

architecture

🚀 Quick Start

Ensure you have

  • Node.js v16 or newer installed (we run tests with v18)
  • Yarn v1 or v2 installed

Supported but not required

Then run the following

🛠 Development

Refer to SETUP.md for info regarding how to setup Alby

Native Companions

Alby supports native connectors to native applications on the host computer. For this, the extension passes each call to a native application (using native messaging). This allows Alby also to connect to nodes behind Tor (through this native "proxy" application).

Currently, there is one native companion app available to connect to Tor nodes: https://github.com/getAlby/alby-companion-rs

⭐ Contributing

We welcome and appreciate new contributions.

Find a task

We use the Development Project Board to plan to-dos. Best choose something from the to-do column. (If there is nothing for you, feel free to pick something from the backlog)

Developer

Designer

Anyone

❔ FAQs

Why not use Joule?

Joule is a full interface to manage a LND node. It only supports one LND account. Our goal is NOT to write a full UI for a Lightning Network node with all the channel management features, but instead to only focus on what is necessary for the web (for payment and authentication flows). We believe there are already way better management UIs. Also, we focus on supporting multiple different node backends (non-custodial and custodial).

What is WebLN?

WebLN is a library and set of specifications for lightning apps and client providers to facilitate communication between apps and users' lightning nodes in a secure way. It provides a programmatic, permissioned interface for letting applications ask users to send payments, generate invoices to receive payments, and much more. This documentation covers how to use WebLN in your Lightning-driven applications.

Is there a bounty program and can I contribute?

Yes. Thanks to generous donors, Alby is able to offer several bounties. You can find them on our Wiki page. If you want to support Alby's bounty program, please donate here. We greatly appreciate your contribution! 🙏

Thanks

Based on the web extension starter kit: /abhijithvijayan/web-extension-starter heavily inspired by the super-amazing work of the Joule extension

⚡️Donations

Want to support the work on Alby?

Support the Alby team ⚡️[email protected] You can also contribute to our bounty program: ⚡️[email protected]

License

MIT

lightning-browser-extension's People

Contributors

adarshrawat1 avatar bitcoinuser avatar bsn21m avatar bumi avatar chris-aeviator avatar dependabot[bot] avatar depfu[bot] avatar dylancom avatar escapedcat avatar im-adithya avatar jankoegel avatar kiwiidb avatar lisabaut avatar lujakob avatar manavdesai27 avatar moritzka avatar motorina0 avatar pavanjoshi914 avatar qqqzhch avatar ra5pvt1n avatar reneaaron avatar reznord avatar rithvik-padma avatar rolznz avatar secondl1ght avatar shawkis avatar siddheshkukade avatar taboca avatar thebrandonlucas avatar weblate avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lightning-browser-extension's Issues

Combine Step 4 and Step 5 of the onboarding

Step 4 and Step 5 are somewhat both confirmation screens.
Maybe we can combine both into one screen that shows the connection details and also leads the user to the demo publisher

Manifest v3

Hello, why you are not using manifest v3 in your extension?

Display Error Messages on payment Events

We should have a way to display messages/errors. When running into an error on a payment e.g.

payment_error "insufficient_balance"

it would be nice to see what happened.

If we decide to let the client website show the message, we should standardize and document the API's necessary to react to events.

Publishers blank state

What do we show on the publishers page when a user does not yet has configured any allowances?
Maybe: an explanation what an allowance is and a link to a demo publisher (as after the onboarding screen)

Update webpack to v5

Currently we are using Webpack v4 (as provided by the extension boilerplate) we should update to v5.
Maybe this also makes it easier to have good source maps? (#23 )

I tried to update all dependencies but getting the following error:

lightning/lightning-browser-extension@issue_23  » yarn dev:firefox
yarn run v1.22.10
$ cross-env NODE_ENV=development cross-env TARGET_BROWSER=firefox webpack --watch
[ Starting the Hot Extension Reload Server... ]
(node:47178) [DEP_WEBPACK_COMPILATION_AFTER_OPTIMIZE_CHUNK_ASSETS] DeprecationWarning: afterOptimizeChunkAssets is deprecated (use Compilation.hooks.processAssets instead and use one of Compilation.PROCESS_ASSETS_STAGE_* as stage option)
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:47178) [DEP_WEBPACK_COMPILATION_OPTIMIZE_CHUNK_ASSETS] DeprecationWarning: optimizeChunkAssets is deprecated (use Compilation.hooks.processAssets instead and use one of Compilation.PROCESS_ASSETS_STAGE_* as stage option)
(node:47178) [DEP_WEBPACK_DEPRECATION_ARRAY_TO_SET] DeprecationWarning: Compilation.chunks was changed from Array to Set (using Array method 'reduce' is deprecated)
wext-manifest-webpack-plugin: removed js/manifest.bundle.js
(node:47178) [DEP_WEBPACK_CHUNK_HAS_ENTRY_MODULE] DeprecationWarning: Chunk.hasEntryModule: Use new ChunkGraph API
(node:47178) [DEP_WEBPACK_CHUNK_ENTRY_MODULE] DeprecationWarning: Chunk.entryModule: Use new ChunkGraph API
[webpack-cli] HookWebpackError: item.node is not a function
    at makeWebpackError (/Users/bumi/src/lightning/lightning-browser-extension/node_modules/webpack/lib/HookWebpackError.js:49:9)
    at /Users/bumi/src/lightning/lightning-browser-extension/node_modules/webpack/lib/Compilation.js:2394:12
    at eval (eval at create (/Users/bumi/src/lightning/lightning-browser-extension/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:80:1)
-- inner error --
TypeError: item.node is not a function
    at /Users/bumi/src/lightning/lightning-browser-extension/node_modules/webpack-sources/lib/ConcatSource.js:59:50
    at Array.map (<anonymous>)
    at ConcatSource.node (/Users/bumi/src/lightning/lightning-browser-extension/node_modules/webpack-sources/lib/ConcatSource.js:58:63)
    at ConcatSource.proto.sourceAndMap (/Users/bumi/src/lightning/lightning-browser-extension/node_modules/webpack-sources/lib/SourceAndMapMixin.js:29:18)
    at /Users/bumi/src/lightning/lightning-browser-extension/node_modules/terser-webpack-plugin/dist/index.js:321:27
    at /Users/bumi/src/lightning/lightning-browser-extension/node_modules/terser-webpack-plugin/node_modules/p-limit/index.js:23:31
    at run (/Users/bumi/src/lightning/lightning-browser-extension/node_modules/terser-webpack-plugin/node_modules/p-limit/index.js:23:43)
    at /Users/bumi/src/lightning/lightning-browser-extension/node_modules/terser-webpack-plugin/node_modules/p-limit/index.js:45:20
caused by plugins in Compilation.hooks.processAssets
TypeError: item.node is not a function
    at /Users/bumi/src/lightning/lightning-browser-extension/node_modules/webpack-sources/lib/ConcatSource.js:59:50
    at Array.map (<anonymous>)
    at ConcatSource.node (/Users/bumi/src/lightning/lightning-browser-extension/node_modules/webpack-sources/lib/ConcatSource.js:58:63)
    at ConcatSource.proto.sourceAndMap (/Users/bumi/src/lightning/lightning-browser-extension/node_modules/webpack-sources/lib/SourceAndMapMixin.js:29:18)
    at /Users/bumi/src/lightning/lightning-browser-extension/node_modules/terser-webpack-plugin/dist/index.js:321:27
    at /Users/bumi/src/lightning/lightning-browser-extension/node_modules/terser-webpack-plugin/node_modules/p-limit/index.js:23:31
    at run (/Users/bumi/src/lightning/lightning-browser-extension/node_modules/terser-webpack-plugin/node_modules/p-limit/index.js:23:43)
    at /Users/bumi/src/lightning/lightning-browser-extension/node_modules/terser-webpack-plugin/node_modules/p-limit/index.js:45:20
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Connector: LndHub

The extension supports multiple backend connections/accounts.

A LndHub connector could allow users to use their LndHub (e.g. bluewallet) accounts with the extension.

Connector: Lnbits

The extension supports multiple backend connections/accounts.

A lnbits connector could allow users to use their lnbits accounts with the extension.

[FFox] Account config is not persisted

After setting up an account I can see the account details & config displayed in the options window of the extension.

image

When trying to use the account to pay, webln reports err, provider No account available.
When returning to the account options, the account config seems not to be persisted

image

{
  "currentKey": "e3c6b9ac4ccae3f063a4c4c1a9b464a8bb60413de200e60457b638c6e27834d0",
  "accounts": {}
}

The account config should be persisted.

Receive screen

The receive screen should allow the user to create an invoice

Edit publisher allowances

Currently we do not have an option to edit the allowance of a publisher.
This could be a full publisher edit page?

Depfu Error: No dependency files found

Hello,

We've tried to activate or update your repository on Depfu and couldn't find any supported dependency files. If we were to guess, we would say that this is not actually a project Depfu supports and has probably been activated by error.

Monorepos

Please note that Depfu currently only searches for your dependency files in the root folder. We do support monorepos and non-root files, but don't auto-detect them. If that's the case with this repo, please send us a quick email with the folder you want Depfu to work on and we'll set it up right away!

How to deactivate the project

  • Go to the Settings page of either your own account or the organization you've used
  • Go to "Installed Integrations"
  • Click the "Configure" button on the Depfu integration
  • Remove this repo (bumi/lightning-browser-extension) from the list of accessible repos.

Please note that using the "All Repositories" setting doesn't make a lot of sense with Depfu.

If you think that this is a mistake

Please let us know by sending an email to [email protected].


This is an automated issue by Depfu. You're getting it because someone configured Depfu to automatically update dependencies on this project.

Payment confirmation prompt

The confirmation prompt is shown whenever a website requests a payment from the user (and the user does not have an allowance configured)

We need to show the user all relevant information required to decide if the payment should be made:

  • Website details (URL, Title, Favicon,...)
  • Amount
  • Memo
  • Fees

We should also allow the user to configure an allowance budget for the page.

Related component:
https://github.com/bumi/lightning-browser-extension/blob/master/src/app/components/ConfirmPayment/index.jsx

Setup a new allowance

On the payment prompt we want to allow the users to set an allowance for the current website/publisher.

Instead of doing a "one-time payment" the user can choose to setup an allowance for the publisher. For this the user should be able to set a maximum budget and a time period.

image

Accounts options page

We need an options page that allows the user to see, add and edit the configured account(s).

Accounts consist of:

  • name
  • connector specific credentials (e.g. for LND: host + macaroon, for LNDHub host + API key)
  • status (if the connection works)

It should be possible to remove and add a new account.

Set Password dialog has disappeared

After resetting my account I am no longer asked to set a password.

When trying to use my previous password I'll see

image

action: "unlock"
​
error: Error
​​
columnNumber: 2640
​​
fileName: "moz-extension://ccdfc1cb-f91c-49b8-864d-e4af850c4fe3/js/background.bundle.js"
​​
lineNumber: 2315
​​
message: "Malformed UTF-8 data"
​​
stack: "stringify@moz-extension://ccdfc1cb-f91c-49b8-864d-e4af850c4fe3/js/background.bundle.js:2315:2640\ntoString@moz-extension://ccdfc1cb-f91c-49b8-864d-e4af850c4fe3/js/background.bundle.js:2315:1400\no@moz-extension://ccdfc1cb-f91c-49b8-864d-e4af850c4fe3/js/background.bundle.js:4137:373\nvalue@moz-extension://ccdfc1cb-f91c-49b8-864d-e4af850c4fe3/js/background.bundle.js:4149:1615\nv@moz-extension://ccdfc1cb-f91c-49b8-864d-e4af850c4fe3/js/background.bundle.js:4173:1923\n"
​



I'm still able to setup my account by manually visiting the optionspage but not use it

Source Map configuration

I'm new to React, sorry if this already explained/configured somewhere else.

We need to have the Source Code visible in the Browser console so we can easily locate errors.
Currently the stack trace is for the generated JS file (hard to read).

I've added the default configs for sourcemaps in this PR #22
But it still does not give me the friendly source code.

See #20 for current stack trace.

Lock account

Currently it is not possible to lock an account after it is unlocked.

Add standard-version for automatic changelog and version bump

I find https://github.com/conventional-changelog/standard-version to be an amazing tool to create releases. This adds a yarn release command which automatically bumps your version (can be displayed inside the plugin), adds a git tag, creates/ appends a changelog.md .

All you need to do is to add feat: my awesome feature or fix: fixes the world or breaking: integrated non-backward compatibe feature as your commit message (only the ones that are supposed to show up inside the changelog) and upon yarn release you get the complete changelog

Example:
grafik

Command husky-run not found

hey @bumi is it possible that branches I take from you include a githook that tries to find husky.sh? I cannot base any new commit ontop of #37

❯ git commit
error Command "husky-run" not found.

EDIT: I actually have husky.sh in .git

Welcome screen

After the user installs the extension we need some kind of onboarding wizzard that gives the user some introduction and helps the user getting started connecting an account.

Figma screens:

https://www.figma.com/file/xEPJFGFdc3HD0JS1ax2IpH/Lightning-Browser-Extension

Current page:

https://github.com/bumi/lightning-browser-extension/blob/master/source/Welcome/Welcome.js

Goals

  • Guide the user through the initial required account configuration
  • Validate and test the account
  • Explain the user the concept of lightning payments in the browser

Steps

  • Intro
  • Choose an account type (LND, Lnbits, etc.)
  • Configure account (e.g. enter LND macaroon and URL) (later we can also add some onramp tools here)
  • Validate and review the connection details (can we connect to the node, get node details)
  • Confirm and save the account
  • Success: explain what can be done now. give an example of a payment to test. - maybe list pages that support webln

ToDos:

  • automatically open the page after the user has installed the extension

Inspiration:

https://metamask.zendesk.com/hc/en-us/articles/360015489531-Getting-Started-With-MetaMask-Part-1-
image
image
image
image
image

Later

Evaluate iOS / Android capabilites

We should check how we are doing on Android and iOS Versions of Chrome and Firefox.

  • AFAIK iOS Firefox/ Chrome is nothing more than Safari with a different UI. Are we able to address this?
  • How is the extension/onboarding behaving on mobile OS'es in general
  • is a browser extension for mobile browsers a thing at all?
  • How can we integrate mobile OS'es into our testing pipeline?

Send screen

The send screen should allow the user to paste a lightning invoice and to pay this lightning invoice.

Split up options page into multiple smaller parts

Currently the options page becomes one big page and the components become quite hard to handle.
How can we best split up the options page int smaller parts/components?
Potentially also different pages for general options, accounts and allowances.

Error [chorme] [chromium]: Uncaught ReferenceError: browser is not defined

It looks like the variable browser is not defined for chorme and chromium and it prevents the extension to work on those browsers.

The full error in the console looks like:

Uncaught ReferenceError: browser is not defined
    at t.default.load (options.bundle.js?aec019069628d7b690f7:4682)
    at B (options.bundle.js?aec019069628d7b690f7:4642)
    at options.bundle.js?aec019069628d7b690f7:4642
    at pb (options.bundle.js?aec019069628d7b690f7:4400)
    at HTMLUnknownElement.v (options.bundle.js?aec019069628d7b690f7:4387)
    at Object.$n (options.bundle.js?aec019069628d7b690f7:4387)
    at tr (options.bundle.js?aec019069628d7b690f7:4387)
    at mb (options.bundle.js?aec019069628d7b690f7:4400)
    at t.unstable_runWithPriority (options.bundle.js?aec019069628d7b690f7:4538)
    at xu (options.bundle.js?aec019069628d7b690f7:4400)

[LND Client] HTTP REST vs GRPC generated from proto

Currently the LND client uses REST over HTTP. This approach works, but there is a lot of overhead in handling the communication.

The alternative is to use gRPC.
By using gRPC we get all the LND APIs out of the box with minimal configuration.

gRPC-generated stubs and skeletons hide HTTP from the client and server too, so nobody has to worry how the RPC concepts are mapped to HTTP

LND supports gRPC:

The gRPC API is well documented:

It is a low effort to replace it since I have already created a client on a boilerplate project that I'm building:

Sphinx_chat also uses gRPC for LND

Question:

  • is it OK to replace the current REST API with gRPC for the LND connection?

Password Screen - Configure vs Unlock

The Password pop-up always asks to confirm the password.

The confirmation field should be required only when the password is set (or changed).
The password should not be entered twice for the unlock flow.

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.