{"id":13499330,"url":"https://github.com/joule-labs/webln","last_synced_at":"2026-01-11T22:49:51.877Z","repository":{"id":33706139,"uuid":"154848995","full_name":"joule-labs/webln","owner":"joule-labs","description":"Spec and client library for WebLN apps and providers","archived":false,"fork":false,"pushed_at":"2023-07-11T16:31:18.000Z","size":94,"stargazers_count":244,"open_issues_count":22,"forks_count":28,"subscribers_count":21,"default_branch":"master","last_synced_at":"2024-08-06T01:18:52.253Z","etag":null,"topics":["lightning","lightning-network","webln"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joule-labs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-10-26T14:41:07.000Z","updated_at":"2024-08-06T01:18:52.254Z","dependencies_parsed_at":"2024-01-14T03:51:12.012Z","dependency_job_id":"eeddf1f6-07f5-4199-993f-b9daec04320c","html_url":"https://github.com/joule-labs/webln","commit_stats":{"total_commits":31,"total_committers":3,"mean_commits":"10.333333333333334","dds":0.06451612903225812,"last_synced_commit":"961f02edf0ba9f99235eb28e29e981acd24158f6"},"previous_names":["wbobeirne/webln"],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joule-labs%2Fwebln","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joule-labs%2Fwebln/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joule-labs%2Fwebln/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joule-labs%2Fwebln/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joule-labs","download_url":"https://codeload.github.com/joule-labs/webln/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246140565,"owners_count":20729797,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["lightning","lightning-network","webln"],"created_at":"2024-07-31T22:00:32.250Z","updated_at":"2026-01-11T22:49:51.831Z","avatar_url":"https://github.com/joule-labs.png","language":"TypeScript","funding_links":[],"categories":["Developer Resources","TypeScript"],"sub_categories":["Libraries"],"readme":"# WebLN\n\nThis library provides the spec and client libraries for WebLN, a way of\ninteracting with a user's Lightning node via the browser.\n\n**Heads up: This spec is in early stages, and is subject to change.\nJoin in the discussion in the issue queue, and please be mindful\nwhen building apps with it!**\n\n## Documentation and Demos\n\nCheck out the documentation site at https://webln.dev/\n\nIf you'd like to contribute to the documentation, you can find it over at https://github.com/wbobeirne/webln-docs\n\n## TL;DR Docs\n\n### Installation\n\nFor use in node-built projects, install via npm or yarn:\n\n```bash\nnpm install webln\n# OR #\nyarn add webln\n```\n\nIf you don't have a build system, you can add the following script tag to your\nproject which will add all functionality under the global `WebLN` namespace:\n\n```html\n\u003cscript\n  src=\"https://unpkg.com/webln@0.3.2/dist/webln.min.js\"\n  integrity=\"sha384-MpjpvOQqXz9nCoLUS/sR0bhLwGYuNPMOBN50jsqhnqAzDq0GiOI0u6oC5fHitzI2\"\n  crossorigin=\"anonymous\"\n\u003e\u003c/script\u003e\n```\n\n\u003csup\u003eMake sure you leave the integrity hash in to prevent possibly malicious JS\u003c/sup\u003e\n\n### Client Library\n\nApps that want to enable WebLN interactions can use the `requestProvider` function to grab a WebLN provider:\n\n```ts\nimport { requestProvider } from \"webln\";\n\nlet webln;\ntry {\n  webln = await requestProvider();\n} catch (err) {\n  // Handle users without WebLN\n}\n\n// Elsewhere in the code...\nif (webln) {\n  // Call webln functions\n}\n```\n\n### WebLN Provider\n\nProviders are classes that implement the interface provided in `webln/lib/provider`.\nThe spec is as follows:\n\n```ts\nexport interface WebLNProvider {\n  /* Determines if the WebLNProvider will allow the page to use it */\n  enable(): Promise\u003cvoid\u003e;\n\n  /* Returns some basic information about the node */\n  getInfo(): Promise\u003cGetInfoResponse\u003e;\n\n  /* Prompts the user with a BOLT-11 payment request */\n  sendPayment(paymentRequest: string): Promise\u003cSendPaymentResponse\u003e;\n\n  /* Sends a keysend payment to a node without needing an invoice */\n  keysend(args: KeysendArgs): Promise\u003cSendPaymentResponse\u003e;\n\n  /* Prompts the user to provide the page with an invoice */\n  makeInvoice(\n    amount: string | number | RequestInvoiceArgs\n  ): Promise\u003cRequestInvoiceResponse\u003e;\n\n  /* Prompts the user to sign a message with their private key */\n  signMessage(message: string): Promise\u003cSignMessageResponse\u003e;\n\n  /* Shows the user a view that verifies a signed message */\n  verifyMessage(signature: string, message: string): Promise\u003cvoid\u003e;\n}\n```\n\nSee the [typescript definitions](https://github.com/wbobeirne/webln/blob/master/src/provider.ts)\nfor more detail about request objects and response shapes. The spec\nis far from complete, and will need more functions to be fully-fledged,\nbut these methods should cover most use-cases.\n\n### Errors\n\nBoth apps and providers will want to make use of WebLN's pre-defined errors.\nThey can be found in `webln/lib/errors` and should be used when throwing and\nhandling errors to best inform the user of what's going on:\n\n```ts\n// For example, an app should check if an uncommon method isn't supported,\n// and let the user know what to do.\nimport { requestProvider } from 'webln';\nimport { UnsupportedMethodError } from 'webln/lib/errors';\n\nasync function signMsg(msg: string) {\n  try {\n    const webln = await requestProvider();\n    const res = await webln.signMessage(msg);\n    return res;\n  } catch(err) {\n    if (err.constructor === UnsupportedMethodError) {\n      alert('Your WebLN provider doesn’t support message signing, please email support@app.com for manual verification');\n    } else {\n      alert(err.message);\n    }\n  }\n```\n\nAnd the provider should throw the correct error when possible:\n\n```ts\n// And a provider should correctly throw this error\nimport { WebLNProvider } from \"webln\";\nimport { UnsupportedMethodError } from \"webln/lib/errors\";\n\nclass MyProvider extends WebLNProvider {\n  signMessage() {\n    throw new UnsupportedMethodError(\n      \"MyProvider doesn’t support message signatures!\"\n    );\n  }\n}\n```\n\nSee the [full list of error types](https://github.com/wbobeirne/webln/blob/master/src/errors.ts)\nfor more information.\n\n## Contributing\n\nPlease [join the issue queue](https://github.com/wbobeirne/webln/issues) to\ndiscuss the future of the WebLN spec.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoule-labs%2Fwebln","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoule-labs%2Fwebln","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoule-labs%2Fwebln/lists"}