From 52f6b6ced871c88eaba3445d7f9fd25097a8fa0a Mon Sep 17 00:00:00 2001 From: tiero <3596602+tiero@users.noreply.github.com> Date: Sat, 14 Jan 2023 01:18:36 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=A5=20breaking:=20no=20more=20target?= =?UTF-8?q?=20in=20query=20string?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 +++- example/index.tsx | 2 +- src/connect.ts | 18 +++++++++--------- test/connect.test.ts | 2 +- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 28544a7..e08fa45 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,10 @@ yarn add @nostr-connect/connect ``` -## 🚀 Getting started +## 📖 Usage +1. [👩‍💻 For Apps developers](#-for-apps-developers) +2. [🔐 For Remote Signer developers](#-for-wallet-developers) ### Create an ephemeral key To use the SDK, you need to create an ephemeral key. This key is used to authenticate your user and to create a session. diff --git a/example/index.tsx b/example/index.tsx index 36e7d7c..863a48a 100644 --- a/example/index.tsx +++ b/example/index.tsx @@ -11,7 +11,7 @@ import { getEventHash, getPublicKey, Event } from 'nostr-tools'; const secretKey = "5acff99d1ad3e1706360d213fd69203312d9b5e91a2d5f2e06100cc6f686e5b3"; const connectURI = new ConnectURI({ target: getPublicKey(secretKey), - relayURL: 'wss://nostr.vulpem.com', + relay: 'wss://nostr.vulpem.com', metadata: { name: 'Example', description: '🔉🔉🔉', diff --git a/src/connect.ts b/src/connect.ts index 60574ba..4eee3c0 100644 --- a/src/connect.ts +++ b/src/connect.ts @@ -13,7 +13,7 @@ export interface Metadata { export class ConnectURI { target: string; metadata: Metadata; - relayURL: string; + relay: string; static fromURI(uri: string): ConnectURI { const url = new URL(uri); @@ -33,7 +33,7 @@ export class ConnectURI { /* eslint-disable @typescript-eslint/no-unused-vars */ try { const md = JSON.parse(metadata); - return new ConnectURI({ target, metadata: md, relayURL: relay }); + return new ConnectURI({ target, metadata: md, relay: relay }); } catch (ignore) { throw new Error('Invalid connect URI: metadata is not valid JSON'); } @@ -42,26 +42,26 @@ export class ConnectURI { constructor({ target, metadata, - relayURL, + relay, }: { target: string; metadata: Metadata; - relayURL: string; + relay: string; }) { this.target = target; this.metadata = metadata; - this.relayURL = relayURL; + this.relay = relay; } toString() { - return `nostr://connect?target=${this.target}&metadata=${JSON.stringify( + return `nostr://connect?${this.target}?metadata=${JSON.stringify( this.metadata - )}&relay=${this.relayURL}`; + )}&relay=${this.relay}`; } async approve(secretKey: string): Promise { const rpc = new NostrRPC({ - relay: this.relayURL, + relay: this.relay, secretKey, }); await rpc.call( @@ -78,7 +78,7 @@ export class ConnectURI { async reject(secretKey: string): Promise { const rpc = new NostrRPC({ - relay: this.relayURL, + relay: this.relay, secretKey, }); await rpc.call( diff --git a/test/connect.test.ts b/test/connect.test.ts index 56a64ef..1b324ef 100644 --- a/test/connect.test.ts +++ b/test/connect.test.ts @@ -36,7 +36,7 @@ describe('Nostr Connect', () => { // send the connect message to the web app from the mobile const connectURI = new ConnectURI({ target: webPK, - relayURL: 'wss://nostr.vulpem.com', + relay: 'wss://nostr.vulpem.com', metadata: { name: 'My Website', description: 'lorem ipsum dolor sit amet',