chore: update nostr-tools
This commit is contained in:
8
package-lock.json
generated
8
package-lock.json
generated
@@ -39,7 +39,7 @@
|
|||||||
"i18next-browser-languagedetector": "^8.0.4",
|
"i18next-browser-languagedetector": "^8.0.4",
|
||||||
"lru-cache": "^11.0.2",
|
"lru-cache": "^11.0.2",
|
||||||
"lucide-react": "^0.469.0",
|
"lucide-react": "^0.469.0",
|
||||||
"nostr-tools": "^2.12.0",
|
"nostr-tools": "^2.13.0",
|
||||||
"nstart-modal": "^2.0.0",
|
"nstart-modal": "^2.0.0",
|
||||||
"path-to-regexp": "^8.2.0",
|
"path-to-regexp": "^8.2.0",
|
||||||
"qrcode.react": "^4.2.0",
|
"qrcode.react": "^4.2.0",
|
||||||
@@ -7120,9 +7120,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/nostr-tools": {
|
"node_modules/nostr-tools": {
|
||||||
"version": "2.12.0",
|
"version": "2.13.0",
|
||||||
"resolved": "https://registry.npmjs.org/nostr-tools/-/nostr-tools-2.12.0.tgz",
|
"resolved": "https://registry.npmjs.org/nostr-tools/-/nostr-tools-2.13.0.tgz",
|
||||||
"integrity": "sha512-pUWEb020gTvt1XZvTa8AKNIHWFapjsv2NKyk43Ez2nnvz6WSXsrTFE0XtkNLSRBjPn6EpxumKeNiVzLz74jNSA==",
|
"integrity": "sha512-A1arGsvpULqVK0NmZQqK1imwaCiPm8gcG/lo+cTax2NbNqBEYsuplbqAFdVqcGHEopmkByYbTwF76x25+oEbew==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@noble/ciphers": "^0.5.1",
|
"@noble/ciphers": "^0.5.1",
|
||||||
"@noble/curves": "1.2.0",
|
"@noble/curves": "1.2.0",
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
"i18next-browser-languagedetector": "^8.0.4",
|
"i18next-browser-languagedetector": "^8.0.4",
|
||||||
"lru-cache": "^11.0.2",
|
"lru-cache": "^11.0.2",
|
||||||
"lucide-react": "^0.469.0",
|
"lucide-react": "^0.469.0",
|
||||||
"nostr-tools": "^2.12.0",
|
"nostr-tools": "^2.13.0",
|
||||||
"nstart-modal": "^2.0.0",
|
"nstart-modal": "^2.0.0",
|
||||||
"path-to-regexp": "^8.2.0",
|
"path-to-regexp": "^8.2.0",
|
||||||
"qrcode.react": "^4.2.0",
|
"qrcode.react": "^4.2.0",
|
||||||
|
|||||||
@@ -32,13 +32,18 @@ export function pubkeyToNpub(pubkey: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function userIdToPubkey(userId: string) {
|
export function userIdToPubkey(userId: string) {
|
||||||
if (userId.startsWith('npub1')) {
|
if (userId.startsWith('npub1') || userId.startsWith('nprofile1')) {
|
||||||
const { data } = nip19.decode(userId as `npub1${string}`)
|
try {
|
||||||
|
const { type, data } = nip19.decode(userId)
|
||||||
|
if (type === 'npub') {
|
||||||
return data
|
return data
|
||||||
} else if (userId.startsWith('nprofile1')) {
|
} else if (type === 'nprofile') {
|
||||||
const { data } = nip19.decode(userId as `nprofile1${string}`)
|
|
||||||
return data.pubkey
|
return data.pubkey
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error decoding userId:', userId, 'error:', error)
|
||||||
|
}
|
||||||
|
}
|
||||||
return userId
|
return userId
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user