Skip to content

Commit

Permalink
Version 0.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
wbobeirne committed Dec 22, 2022
1 parent f707def commit 0ef87eb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
22 changes: 13 additions & 9 deletions README.md
Expand Up @@ -27,21 +27,23 @@ yarn add webln

If you don't have a build system, you can add the following script tag to your
project which will add all functionality under the global `WebLN` namespace:

```html
<script
src="https://unpkg.com/webln@0.3.0/dist/webln.min.js"
integrity="sha384-g4CABMESGmsa44I6J+t/4fY3DYGpbl8EjqX4L8g6rmD0RLjVinenmzEDqSH3f1QV"
src="https://unpkg.com/webln@0.3.1/dist/webln.min.js"
integrity="sha384-TddsmDgTQUTU/yuktBl5LSb8Y+QQqknQ19Lx2E0FraOK451Wv63kQ6iZFPrkmeEB"
crossorigin="anonymous"
></script>
```

<sup>Make sure you leave the integrity hash in to prevent possibly malicious JS</sup>

### Client Library

Apps that want to enable WebLN interactions can use the `requestProvider` function to grab a WebLN provider:

```ts
import { requestProvider } from 'webln';
import { requestProvider } from "webln";

let webln;
try {
Expand All @@ -56,7 +58,6 @@ if (webln) {
}
```


### WebLN Provider

Providers are classes that implement the interface provided in `webln/lib/provider`.
Expand All @@ -77,7 +78,9 @@ export interface WebLNProvider {
keysend(args: KeysendArgs): Promise<SendPaymentResponse>;

/* Prompts the user to provide the page with an invoice */
makeInvoice(amount: string | number | RequestInvoiceArgs): Promise<RequestInvoiceResponse>;
makeInvoice(
amount: string | number | RequestInvoiceArgs
): Promise<RequestInvoiceResponse>;

/* Prompts the user to sign a message with their private key */
signMessage(message: string): Promise<SignMessageResponse>;
Expand All @@ -92,7 +95,6 @@ for more detail about request objects and response shapes. The spec
is far from complete, and will need more functions to be fully-fledged,
but these methods should cover most use-cases.


### Errors

Both apps and providers will want to make use of WebLN's pre-defined errors.
Expand Down Expand Up @@ -123,12 +125,14 @@ And the provider should throw the correct error when possible:
```ts
// And a provider should correctly throw this error
import { WebLNProvider } from 'webln';
import { UnsupportedMethodError } from 'webln/lib/errors';
import { WebLNProvider } from "webln";
import { UnsupportedMethodError } from "webln/lib/errors";

class MyProvider extends WebLNProvider {
signMessage() {
throw new UnsupportedMethodError('MyProvider doesn’t support message signatures!');
throw new UnsupportedMethodError(
"MyProvider doesn’t support message signatures!"
);
}
}
```
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "webln",
"version": "0.3.0",
"version": "0.3.1",
"description": "Spec and tools around implementing WebLN",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down

0 comments on commit 0ef87eb

Please sign in to comment.