diff --git a/.husky/commit-msg b/.husky/commit-msg
index babe8fa..bf90b32 100755
--- a/.husky/commit-msg
+++ b/.husky/commit-msg
@@ -1,4 +1 @@
-#!/bin/sh
-. "$(dirname "$0")/_/husky.sh"
-
yarn commitlint --edit
diff --git a/.husky/pre-commit b/.husky/pre-commit
index 5a182ef..3723623 100755
--- a/.husky/pre-commit
+++ b/.husky/pre-commit
@@ -1,4 +1 @@
-#!/usr/bin/env sh
-. "$(dirname -- "$0")/_/husky.sh"
-
yarn lint-staged
diff --git a/README.md b/README.md
index d0fe992..7aefbde 100644
--- a/README.md
+++ b/README.md
@@ -56,7 +56,7 @@ There are two interfaces you can use to access NWC:
- `walletPubkey`: pubkey of the Nostr Wallet Connect app
- `secret`: secret key to sign the request event (if not available window.nostr will be used)
-#### `static newClientFromAuthorizationUrl()`
+#### `static fromAuthorizationUrl()`
Initialized a new `NWCClient` instance but generates a new random secret. The pubkey of that secret then needs to be authorized by the user (this can be initiated by redirecting the user to the `getAuthorizationUrl()` URL or calling `fromAuthorizationUrl()` to open an authorization popup.
@@ -71,6 +71,8 @@ const nwcClient = await nwc.NWCClient.fromAuthorizationUrl(
);
```
+The same options can be provided to getAuthorizationUrl() as fromAuthorizationUrl() - see [Manual Auth example](./examples/nwc/client/auth_manual.html)
+
#### Quick start example
```js
@@ -232,18 +234,7 @@ nwc.close(); // close the websocket connection
#### Generate a new NWC connect url using a locally-generated secret
```js
-// same options can be provided to .withNewSecret() as creating a new NostrWebLNProvider()
-const webln = webln.NostrWebLNProvider.withNewSecret();
-
-// get the connect URL to the interface where the user has to enable the connection
-webln.getConnectUrl({ name: `My app name` });
-// an optional return_to parameter can be passed in
-webln.getConnectUrl({
- name: `My app name`,
- returnTo: document.location.toString(),
-});
-
-// or use the `fromAuthorizationUrl` helper which opens a popup to initiate the connection flow.
+// use the `fromAuthorizationUrl` helper which opens a popup to initiate the connection flow.
// the promise resolves once the NWC app returned.
const nwc = await webln.NostrWebLNProvider.fromAuthorizationUrl(
"https://my.albyhub.com/apps/new",
@@ -258,6 +249,8 @@ const nwc = await webln.NostrWebLNProvider.fromAuthorizationUrl(
// const nostrWalletConnectUrl nwc.getNostrWalletConnectUrl(true)
```
+The same options can be provided to getAuthorizationUrl() as fromAuthorizationUrl() - see [Manual Auth example](./examples/nwc/auth_manual.html)
+
## OAuth API Documentation
Please have a look a the Alby OAuth2 Wallet API:
diff --git a/examples/nwc/auth_manual.html b/examples/nwc/auth_manual.html
new file mode 100644
index 0000000..5f98f65
--- /dev/null
+++ b/examples/nwc/auth_manual.html
@@ -0,0 +1,81 @@
+
+
+
+
diff --git a/examples/nwc/client/auth_manual.html b/examples/nwc/client/auth_manual.html
new file mode 100644
index 0000000..0fc7ee3
--- /dev/null
+++ b/examples/nwc/client/auth_manual.html
@@ -0,0 +1,77 @@
+
+
+
+
diff --git a/package.json b/package.json
index 22801e3..1661390 100644
--- a/package.json
+++ b/package.json
@@ -35,7 +35,7 @@
"clean": "rm -rf dist",
"build": "microbundle --no-sourcemap",
"dev": "microbundle watch",
- "prepare": "husky install"
+ "prepare": "husky"
},
"dependencies": {
"nostr-tools": "2.9.4"
diff --git a/src/webln/NostrWeblnProvider.ts b/src/webln/NostrWeblnProvider.ts
index 6e30ed3..53190ab 100644
--- a/src/webln/NostrWeblnProvider.ts
+++ b/src/webln/NostrWeblnProvider.ts
@@ -1,5 +1,4 @@
-import { Event, UnsignedEvent, generateSecretKey } from "nostr-tools";
-import { bytesToHex } from "@noble/hashes/utils";
+import { Event, UnsignedEvent } from "nostr-tools";
import {
GetBalanceResponse,
KeysendArgs,
@@ -93,14 +92,6 @@ export class NostrWebLNProvider implements WebLNProvider, Nip07Provider {
return this.client.options;
}
- static withNewSecret(
- options?: ConstructorParameters[0],
- ) {
- options = options || {};
- options.secret = bytesToHex(generateSecretKey());
- return new NostrWebLNProvider(options);
- }
-
static async fromAuthorizationUrl(
authorizationBasePath: string,
options: NWCAuthorizationUrlOptions = {},