mirror of
https://github.com/nostr-connect/connect.git
synced 2026-02-01 10:24:35 +01:00
update nostr-tools
This commit is contained in:
@@ -3,20 +3,20 @@ import { useEffect, useState } from 'react';
|
||||
import { useStatePersist } from 'use-state-persist';
|
||||
|
||||
import * as ReactDOM from 'react-dom';
|
||||
import { broadcastToRelay, Connect, connectToRelay, ConnectURI, TimeRanges } from '../src/index';
|
||||
import { broadcastToRelay, Connect, connectToRelay, ConnectURI } from '@nostr-connect/connect';
|
||||
|
||||
import { QRCodeSVG } from 'qrcode.react';
|
||||
import { getEventHash, getPublicKey, Event, nip19 } from 'nostr-tools';
|
||||
import { getEventHash, getPublicKey, Event } from 'nostr-tools';
|
||||
|
||||
const secretKey = "5acff99d1ad3e1706360d213fd69203312d9b5e91a2d5f2e06100cc6f686e5b3";
|
||||
const connectURI = new ConnectURI({
|
||||
target: getPublicKey(secretKey),
|
||||
relay: 'wss://nostr.vulpem.com',
|
||||
metadata: {
|
||||
name: 'Vulpem',
|
||||
description: 'Bitcoin company',
|
||||
url: 'https://vulpem.com',
|
||||
icons: ['https://vulpem.com/favicon.ico'],
|
||||
name: 'Example',
|
||||
description: '🔉🔉🔉',
|
||||
url: 'https://example.com',
|
||||
icons: ['https://example.com/icon.png'],
|
||||
},
|
||||
});
|
||||
|
||||
@@ -54,7 +54,7 @@ const App = () => {
|
||||
target: pubkey,
|
||||
});
|
||||
const pk = await connect.getPublicKey();
|
||||
setGetPublicKeyReply(nip19.npubEncode(pk));
|
||||
setGetPublicKeyReply(pk);
|
||||
}
|
||||
|
||||
const sendMessage = async () => {
|
||||
@@ -116,13 +116,19 @@ const App = () => {
|
||||
target: pubkey,
|
||||
});
|
||||
|
||||
const sig = await connect.delegate(
|
||||
getPublicKey(secretKey),
|
||||
{
|
||||
kind: 1,
|
||||
until: TimeRanges.ONE_DAY,
|
||||
const sig = await connect.rpc.call({
|
||||
target: pubkey,
|
||||
request: {
|
||||
method: 'delegate',
|
||||
params: [
|
||||
getPublicKey(secretKey),
|
||||
{
|
||||
kind: 0,
|
||||
until: Math.floor(Date.now() / 1000) + 60 * 60 * 24 * 365,
|
||||
}
|
||||
],
|
||||
}
|
||||
);
|
||||
});
|
||||
setDelegateSig(sig);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
@@ -152,7 +158,6 @@ const App = () => {
|
||||
});
|
||||
}
|
||||
|
||||
const appEpehemeralPubKey = nip19.npubEncode(getPublicKey(secretKey));
|
||||
return (
|
||||
<div className='hero is-fullheight has-background-black has-text-white'>
|
||||
<section className="container">
|
||||
@@ -160,7 +165,7 @@ const App = () => {
|
||||
<h1 className='title has-text-white'>Nostr Connect Playground</h1>
|
||||
</div>
|
||||
<div className='content'>
|
||||
<p className='subtitle is-6 has-text-white'><b>Nostr ID (ephemeral)</b> {appEpehemeralPubKey}</p>
|
||||
<p className='subtitle is-6 has-text-white'><b>Nostr ID</b> {getPublicKey(secretKey)}</p>
|
||||
</div>
|
||||
<div className='content'>
|
||||
<p className='subtitle is-6 has-text-white'><b>Status</b> {isConnected() ? '🟢 Connected' : '🔴 Disconnected'}</p>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@nostr-connect/connect": "^0.2.3",
|
||||
"nostr-tools": "^1.1.1",
|
||||
"nostr-tools": "^1.6.0",
|
||||
"qrcode.react": "^3.1.0",
|
||||
"react": "^18.2.0",
|
||||
"react-app-polyfill": "^1.0.0",
|
||||
|
||||
@@ -61,6 +61,6 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"events": "^3.3.0",
|
||||
"nostr-tools": "^1.0.1"
|
||||
"nostr-tools": "^1.6.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import EventEmitter from 'events';
|
||||
import { Event, getPublicKey, nip04 } from 'nostr-tools';
|
||||
import { Event, getPublicKey, nip04, Kind } from 'nostr-tools';
|
||||
|
||||
import { isValidRequest, NostrRPC } from './rpc';
|
||||
|
||||
@@ -212,7 +212,13 @@ export class Connect {
|
||||
return response as string;
|
||||
}
|
||||
|
||||
async signEvent(event: Event): Promise<string> {
|
||||
async signEvent(event: {
|
||||
kind: Kind;
|
||||
tags: string[][];
|
||||
pubkey: string;
|
||||
content: string;
|
||||
created_at: number;
|
||||
}): Promise<string> {
|
||||
if (!this.target) throw new Error('Not connected');
|
||||
|
||||
const signature = await this.rpc.call({
|
||||
|
||||
80
yarn.lock
80
yarn.lock
@@ -1186,17 +1186,22 @@
|
||||
"@jridgewell/resolve-uri" "3.1.0"
|
||||
"@jridgewell/sourcemap-codec" "1.4.14"
|
||||
|
||||
"@noble/hashes@^0.5.7":
|
||||
version "0.5.9"
|
||||
resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-0.5.9.tgz#9f3051a4cc6f7c168022b3b7fbbe9fe2a35cccf0"
|
||||
integrity sha512-7lN1Qh6d8DUGmfN36XRsbN/WcGIPNtTGhkw26vWId/DlCIGsYJJootTtPGghTLcn/AaXPx2Q0b3cacrwXa7OVw==
|
||||
"@noble/hashes@1.0.0":
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.0.0.tgz#d5e38bfbdaba174805a4e649f13be9a9ed3351ae"
|
||||
integrity sha512-DZVbtY62kc3kkBtMHqwCOfXrT/hnoORy5BJ4+HU1IR59X0KWAOqsfzQPcUl/lQLlG7qXbe/fZ3r/emxtAl+sqg==
|
||||
|
||||
"@noble/hashes@~1.1.1", "@noble/hashes@~1.1.3":
|
||||
version "1.1.5"
|
||||
resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.1.5.tgz#1a0377f3b9020efe2fae03290bd2a12140c95c11"
|
||||
integrity sha512-LTMZiiLc+V4v1Yi16TD6aX2gmtKszNye0pQgbaLqkvhIqP7nVsSaJsWloGQjJfJ8offaoP5GtX3yY5swbcJxxQ==
|
||||
"@noble/hashes@~1.2.0":
|
||||
version "1.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.2.0.tgz#a3150eeb09cc7ab207ebf6d7b9ad311a9bdbed12"
|
||||
integrity sha512-FZfhjEDbT5GRswV3C6uvLPHMiVD6lQBmpoX5+eSiPaMTXte/IKqI5dykDxzZB/WBeK/CDuQRBWarPdi3FNY2zQ==
|
||||
|
||||
"@noble/secp256k1@^1.7.0", "@noble/secp256k1@~1.7.0":
|
||||
"@noble/secp256k1@^1.7.1":
|
||||
version "1.7.1"
|
||||
resolved "https://registry.yarnpkg.com/@noble/secp256k1/-/secp256k1-1.7.1.tgz#b251c70f824ce3ca7f8dc3df08d58f005cc0507c"
|
||||
integrity sha512-hOUk6AyBFmqVrv7k5WAw/LpszxVbj9gGN4JRkIX52fdFAj1UA61KXmZDvqVEm+pOyec3+fIeZB02LYa/pWOArw==
|
||||
|
||||
"@noble/secp256k1@~1.7.0":
|
||||
version "1.7.0"
|
||||
resolved "https://registry.yarnpkg.com/@noble/secp256k1/-/secp256k1-1.7.0.tgz#d15357f7c227e751d90aa06b05a0e5cf993ba8c1"
|
||||
integrity sha512-kbacwGSsH/CTout0ZnZWxnW1B+jH/7r/WAAKLBtrRJ/+CUH7lgmQzl3GTrQua3SGKWNSDsS6lmjnDpIJ5Dxyaw==
|
||||
@@ -1279,26 +1284,26 @@
|
||||
estree-walker "^1.0.1"
|
||||
picomatch "^2.2.2"
|
||||
|
||||
"@scure/base@~1.1.0":
|
||||
"@scure/base@^1.1.1", "@scure/base@~1.1.0":
|
||||
version "1.1.1"
|
||||
resolved "https://registry.yarnpkg.com/@scure/base/-/base-1.1.1.tgz#ebb651ee52ff84f420097055f4bf46cfba403938"
|
||||
integrity sha512-ZxOhsSyxYwLJj3pLZCefNitxsj093tb2vq90mp2txoYeBqbcjDjqFhyM8eUjq/uFm6zJ+mUuqxlS2FkuSY1MTA==
|
||||
|
||||
"@scure/bip32@^1.1.1":
|
||||
version "1.1.1"
|
||||
resolved "https://registry.yarnpkg.com/@scure/bip32/-/bip32-1.1.1.tgz#f62e4a2f13cc3e5e720ad81b7582b8631ae6835a"
|
||||
integrity sha512-UmI+liY7np2XakaW+6lMB6HZnpczWk1yXZTxvg8TM8MdOcKHCGL1YkraGj8eAjPfMwFNiAyek2hXmS/XFbab8g==
|
||||
"@scure/bip32@^1.1.5":
|
||||
version "1.1.5"
|
||||
resolved "https://registry.yarnpkg.com/@scure/bip32/-/bip32-1.1.5.tgz#d2ccae16dcc2e75bc1d75f5ef3c66a338d1ba300"
|
||||
integrity sha512-XyNh1rB0SkEqd3tXcXMi+Xe1fvg+kUIcoRIEujP1Jgv7DqW2r9lg3Ah0NkFaCs9sTkQAQA8kw7xiRXzENi9Rtw==
|
||||
dependencies:
|
||||
"@noble/hashes" "~1.1.3"
|
||||
"@noble/hashes" "~1.2.0"
|
||||
"@noble/secp256k1" "~1.7.0"
|
||||
"@scure/base" "~1.1.0"
|
||||
|
||||
"@scure/bip39@^1.1.0":
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/@scure/bip39/-/bip39-1.1.0.tgz#92f11d095bae025f166bef3defcc5bf4945d419a"
|
||||
integrity sha512-pwrPOS16VeTKg98dYXQyIjJEcWfz7/1YJIwxUEPFfQPtc86Ym/1sVgQ2RLoD43AazMk2l/unK4ITySSpW2+82w==
|
||||
"@scure/bip39@^1.1.1":
|
||||
version "1.1.1"
|
||||
resolved "https://registry.yarnpkg.com/@scure/bip39/-/bip39-1.1.1.tgz#b54557b2e86214319405db819c4b6a370cf340c5"
|
||||
integrity sha512-t+wDck2rVkh65Hmv280fYdVdY25J9YeEUIgn2LG1WM6gxFkGzcksoDiUkWVpVp3Oex9xGC68JU2dSbUfwZ2jPg==
|
||||
dependencies:
|
||||
"@noble/hashes" "~1.1.1"
|
||||
"@noble/hashes" "~1.2.0"
|
||||
"@scure/base" "~1.1.0"
|
||||
|
||||
"@sinonjs/commons@^1.7.0":
|
||||
@@ -1927,11 +1932,6 @@ balanced-match@^1.0.0:
|
||||
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
|
||||
integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==
|
||||
|
||||
base64-arraybuffer@^1.0.2:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/base64-arraybuffer/-/base64-arraybuffer-1.0.2.tgz#1c37589a7c4b0746e34bd1feb951da2df01c1bdc"
|
||||
integrity sha512-I3yl4r9QB5ZRY3XuJVEPfc2XhZO6YweFPI+UovAzn+8/hb3oJ6lnysaFcjVpkCPfVWFUDvoZ8kmVDP7WyRtYtQ==
|
||||
|
||||
base@^0.11.1:
|
||||
version "0.11.2"
|
||||
resolved "https://registry.yarnpkg.com/base/-/base-0.11.2.tgz#7bde5ced145b6d551a90db87f83c558b4eb48a8f"
|
||||
@@ -1952,11 +1952,6 @@ bcrypt-pbkdf@^1.0.0:
|
||||
dependencies:
|
||||
tweetnacl "^0.14.3"
|
||||
|
||||
bech32@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/bech32/-/bech32-2.0.0.tgz#078d3686535075c8c79709f054b1b226a133b355"
|
||||
integrity sha512-LcknSilhIGatDAsY1ak2I8VtGaHNhgMSYVxFrGLXv+xLHytaKZKcaUJJUE7qmBr7h33o5YQwP55pMI0xmkpJwg==
|
||||
|
||||
binary-extensions@^2.0.0:
|
||||
version "2.2.0"
|
||||
resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d"
|
||||
@@ -4906,17 +4901,17 @@ normalize-path@^3.0.0, normalize-path@~3.0.0:
|
||||
resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65"
|
||||
integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==
|
||||
|
||||
nostr-tools@^1.0.1:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/nostr-tools/-/nostr-tools-1.0.1.tgz#acf21758fc745674ed047e7dc219b30baf489005"
|
||||
integrity sha512-URBNadrVq4qSmndzd4clZqubze4y/LB8cdzzen9mNwlFh3ICDdWp7TCShTbLEZQYPPSVoOe2n13l77jzcVvH/w==
|
||||
nostr-tools@^1.6.0:
|
||||
version "1.6.0"
|
||||
resolved "https://registry.yarnpkg.com/nostr-tools/-/nostr-tools-1.6.0.tgz#4052fe717a378982c8ce56d39986089abacfc6d3"
|
||||
integrity sha512-qjjJQ7YxJUMzgS24eVlxkZ87PKJtU6dlH04OzVuK6w+GSPL+VdUZkMe2lfSpnb7OkCrDIzmbFbtx+Q4LXdU2xw==
|
||||
dependencies:
|
||||
"@noble/hashes" "^0.5.7"
|
||||
"@noble/secp256k1" "^1.7.0"
|
||||
"@scure/bip32" "^1.1.1"
|
||||
"@scure/bip39" "^1.1.0"
|
||||
base64-arraybuffer "^1.0.2"
|
||||
bech32 "^2.0.0"
|
||||
"@noble/hashes" "1.0.0"
|
||||
"@noble/secp256k1" "^1.7.1"
|
||||
"@scure/base" "^1.1.1"
|
||||
"@scure/bip32" "^1.1.5"
|
||||
"@scure/bip39" "^1.1.1"
|
||||
prettier "^2.8.4"
|
||||
|
||||
npm-run-path@^2.0.0:
|
||||
version "2.0.2"
|
||||
@@ -5230,6 +5225,11 @@ prettier@^1.19.1:
|
||||
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb"
|
||||
integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==
|
||||
|
||||
prettier@^2.8.4:
|
||||
version "2.8.4"
|
||||
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.4.tgz#34dd2595629bfbb79d344ac4a91ff948694463c3"
|
||||
integrity sha512-vIS4Rlc2FNh0BySk3Wkd6xmwxB0FpOndW5fisM5H8hsZSxU2VWVB5CWIkIjWvrHjIhxk2g3bfMKM87zNTrZddw==
|
||||
|
||||
pretty-format@^25.2.1, pretty-format@^25.5.0:
|
||||
version "25.5.0"
|
||||
resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-25.5.0.tgz#7873c1d774f682c34b8d48b6743a2bf2ac55791a"
|
||||
|
||||
Reference in New Issue
Block a user