Skip to content

Commit

Permalink
nip-46: support secret token
Browse files Browse the repository at this point in the history
  • Loading branch information
verbiricha committed Mar 21, 2024
1 parent dd8fe82 commit c7f4409
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/core/src/context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,9 @@ export const NgineProvider = ({
if (url.includes("bunker://")) {
const asURL = new URL(url);
const relays = asURL.searchParams.getAll("relay");
const token = asURL.searchParams.get("secret");
const pubkey = asURL.hostname || asURL.pathname.replace(/^\/\//, "");
return { relays, pubkey };
return { relays, pubkey, token };
} else {
const user = await NDKUser.fromNip05(url, ndk);
if (user) {
Expand All @@ -222,13 +223,16 @@ export const NgineProvider = ({
async function nip46Login(url: string) {
const settings = await getNostrConnectSettings(url);
if (settings) {
const { pubkey, relays } = settings;
const { pubkey, relays, token } = settings;
const bunkerNDK = new NDK({
explicitRelayUrls: relays,
});
await bunkerNDK.connect();
const localSigner = NDKPrivateKeySigner.generate();
const signer = new NDKNip46Signer(bunkerNDK, pubkey, localSigner);
if (token) {
signer.token = token;
}
signer.on("authUrl", (url) => {
window.open(url, "auth", "width=600,height=600");
});
Expand Down

0 comments on commit c7f4409

Please sign in to comment.