diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c3895ae..2ea904e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,7 +8,7 @@ jobs: strategy: matrix: node: ['14.x', '16.x', '18.x'] - os: [ubuntu-latest, windows-latest, macOS-latest] + os: [ubuntu-latest] steps: - name: Checkout repo diff --git a/.github/workflows/size.yml b/.github/workflows/size.yml deleted file mode 100644 index 6021cda..0000000 --- a/.github/workflows/size.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: size -on: [pull_request] -jobs: - size: - runs-on: ubuntu-latest - env: - CI_JOB_NUMBER: 1 - steps: - - uses: actions/checkout@v1 - - uses: andresz1/size-limit-action@v1 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/example/package.json b/example/package.json index 46460b9..199043e 100644 --- a/example/package.json +++ b/example/package.json @@ -8,7 +8,7 @@ "build": "parcel build --public-url /connect index.html" }, "dependencies": { - "@nostr-connect/connect": "^0.1.0", + "@nostr-connect/connect": "^0.1.1", "nostr-tools": "^1.1.1", "qrcode.react": "^3.1.0", "react": "^18.2.0", diff --git a/example/yarn.lock b/example/yarn.lock index 1bdfbf5..80c6d88 100644 --- a/example/yarn.lock +++ b/example/yarn.lock @@ -159,10 +159,10 @@ resolved "https://registry.yarnpkg.com/@noble/secp256k1/-/secp256k1-1.7.0.tgz#d15357f7c227e751d90aa06b05a0e5cf993ba8c1" integrity sha512-kbacwGSsH/CTout0ZnZWxnW1B+jH/7r/WAAKLBtrRJ/+CUH7lgmQzl3GTrQua3SGKWNSDsS6lmjnDpIJ5Dxyaw== -"@nostr-connect/connect@^0.1.0": - version "0.1.0" - resolved "https://registry.yarnpkg.com/@nostr-connect/connect/-/connect-0.1.0.tgz#0f5537237d63e328922b9b13b97d98da53cc3bd4" - integrity sha512-YcQvkvMEdWBFy1tnPJhuS+wNK+W1EOz0vdOeIth6KezdSKS+yTHoR/jV58nQdRLvmiAIAIr+ZY/gYTztFddiUA== +"@nostr-connect/connect@^0.1.1": + version "0.1.1" + resolved "https://registry.yarnpkg.com/@nostr-connect/connect/-/connect-0.1.1.tgz#e289d6abd617fc537435321612df68a448df459d" + integrity sha512-1lhogg58haTObD2KnnZZW4wEjYRrEIOOc8ll0N7s20WDVs4uoL+5bAetVXSzf1XzgyakDWJGTYawqbtbgCo45w== dependencies: events "^3.3.0" nostr-tools "^1.0.1" diff --git a/package.json b/package.json index 955c770..ec98482 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "0.1.0", + "version": "0.1.1", "license": "MIT", "main": "dist/index.js", "typings": "dist/index.d.ts", diff --git a/src/connect.ts b/src/connect.ts index 0a0b0f6..10d1eb1 100644 --- a/src/connect.ts +++ b/src/connect.ts @@ -17,10 +17,9 @@ export class ConnectURI { static fromURI(uri: string): ConnectURI { const url = new URL(uri); - const target = url.searchParams.get('target'); - if (!target) { + const target = url.pathname.substring(2); + if (!url.pathname.startsWith('//')) throw new Error('Invalid connect URI: missing target'); - } const relay = url.searchParams.get('relay'); if (!relay) { throw new Error('Invalid connect URI: missing relay'); @@ -33,7 +32,7 @@ export class ConnectURI { /* eslint-disable @typescript-eslint/no-unused-vars */ try { const md = JSON.parse(metadata); - return new ConnectURI({ target, metadata: md, relay: relay }); + return new ConnectURI({ target, metadata: md, relay }); } catch (ignore) { throw new Error('Invalid connect URI: metadata is not valid JSON'); } @@ -54,7 +53,7 @@ export class ConnectURI { } toString() { - return `nostr://connect?${this.target}?metadata=${JSON.stringify( + return `nostrconnect://${this.target}?metadata=${JSON.stringify( this.metadata )}&relay=${this.relay}`; } diff --git a/test/connect.test.ts b/test/connect.test.ts index f266066..463251b 100644 --- a/test/connect.test.ts +++ b/test/connect.test.ts @@ -42,6 +42,12 @@ class MobileHandler extends NostrSigner { } describe('Nostr Connect', () => { + it.only('generates a connectURI', async () => { + const url = ConnectURI.fromURI( + `nostrconnect://b889ff5b1513b641e2a139f661a661364979c5beee91842f8f0ef42ab558e9d4?metadata={"name":"Example","description":"🔉🔉🔉","url":"https://example.com","icons":["https://example.com/icon.png"]}&relay=wss://nostr.vulpem.com` + ); + console.log(url.target); + }); it('connect', async () => { const testHandler = jest.fn(); @@ -68,7 +74,7 @@ describe('Nostr Connect', () => { expect(testHandler).toBeCalledTimes(1); }); - it.only('returns pubkey', async () => { + it('returns pubkey', async () => { // start listening for connect messages on the mobile app const remoteHandler = new MobileHandler({ secretKey: mobileSK,