mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-11-18 09:26:54 +01:00
implement search
This commit is contained in:
@@ -79,7 +79,6 @@ export default {
|
||||
supports_android_signer: false,
|
||||
};
|
||||
},
|
||||
|
||||
async mounted() {
|
||||
try{
|
||||
if (amberSignerService.supported) {
|
||||
@@ -99,7 +98,6 @@ export default {
|
||||
catch (error){
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
methods: {
|
||||
@@ -257,10 +255,10 @@ export default {
|
||||
localStorage.setItem('nostr-key', "")
|
||||
await this.get_user_info(publicKey)
|
||||
|
||||
miniToastr.showMessage("Login successful!", "Logged in as " + publicKey.toHex(), VueNotifications.types.success)
|
||||
//miniToastr.showMessage("Login successful!", "Logged in as " + publicKey.toHex(), VueNotifications.types.success)
|
||||
|
||||
} catch (error) {
|
||||
alert(error);
|
||||
console.log(error);
|
||||
}
|
||||
},
|
||||
async getnip89s(){
|
||||
|
||||
@@ -19,6 +19,7 @@ import {computed, onMounted, ref} from "vue";
|
||||
import countries from "@/components/data/countries.json";
|
||||
import deadnip89s from "@/components/data/deadnip89s.json";
|
||||
import Nip07 from "@/components/Nip07.vue";
|
||||
import amberSignerService from "./android-signer/AndroidSigner";
|
||||
|
||||
let items = []
|
||||
let dvms =[]
|
||||
@@ -92,26 +93,43 @@ async function send_search_request(msg) {
|
||||
tags.push(Tag.parse(['param', 'users', JSON.stringify(users)]))
|
||||
|
||||
let evt = new EventBuilder(5302, "NIP 90 Search request", tags)
|
||||
let res;
|
||||
let requestid;
|
||||
if (localStorage.getItem('nostr-key-method') === 'android-signer') {
|
||||
let draft = {
|
||||
content: "NIP 90 Search request",
|
||||
kind: 5302,
|
||||
pubkey: store.state.pubkey.toHex(),
|
||||
tags: [
|
||||
["i", msg, "text"],
|
||||
["param", "max_results", "150"],
|
||||
['param', 'users', JSON.stringify(users)]
|
||||
],
|
||||
createdAt: Date.now()
|
||||
};
|
||||
|
||||
let res = await client.sendEventBuilder(evt)
|
||||
let requestid = res.toHex()
|
||||
res = await amberSignerService.signEvent(draft)
|
||||
await client.sendEvent(Event.fromJson(JSON.stringify(res)))
|
||||
requestid = res.id;
|
||||
res = res.id;
|
||||
} else {
|
||||
res = await client.sendEventBuilder(evt)
|
||||
requestid = res.toHex()
|
||||
}
|
||||
|
||||
console.log("STORE: " +store.state.requestidSearch)
|
||||
store.commit('set_current_request_id_search', requestid)
|
||||
console.log("STORE AFTER: " + store.state.requestidSearch)
|
||||
|
||||
|
||||
//miniToastr.showMessage("Sent Request to DVMs", "Awaiting results", VueNotifications.types.warn)
|
||||
if (!store.state.hasEventListener){
|
||||
listen()
|
||||
listen()
|
||||
store.commit('set_hasEventListener', true)
|
||||
}
|
||||
else{
|
||||
console.log("Already has event listener")
|
||||
}
|
||||
|
||||
console.log(res)
|
||||
|
||||
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
@@ -313,7 +331,7 @@ async function listen() {
|
||||
},
|
||||
// Handle relay message
|
||||
handleMsg: async (relayUrl, message) => {
|
||||
//console.log("Received message from", relayUrl, message.asJson());
|
||||
//console.log(`Received message from ${relayUrl} ${message.asJson()}`);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -6,10 +6,10 @@ import { DraftNostrEvent, NostrEvent } from "./types/nostr-event";
|
||||
export function createGetPublicKeyIntent() {
|
||||
return `intent:#Intent;scheme=nostrsigner;S.compressionType=none;S.returnType=signature;S.type=get_public_key;end`;
|
||||
}
|
||||
export function createSignEventIntent(draft: DraftNostrEvent) {
|
||||
export function createSignEventIntent(draft) {
|
||||
return `intent:${encodeURIComponent(
|
||||
JSON.stringify(draft),
|
||||
)}#Intent;scheme=nostrsigner;S.compressionType=none;S.returnType=signature;S.type=sign_event;end`;
|
||||
)}#Intent;scheme=nostrsigner;S.compressionType=none;S.returnType=event;S.type=sign_event;end`;
|
||||
}
|
||||
export function createNip04EncryptIntent(pubkey: string, plainText: string) {
|
||||
return `intent:${encodeURIComponent(
|
||||
@@ -71,14 +71,12 @@ async function getPublicKey() {
|
||||
throw new Error("Expected clipboard to have pubkey");
|
||||
}
|
||||
|
||||
async function signEvent(draft: DraftNostrEvent & { pubkey: string }): Promise<NostrEvent> {
|
||||
const draftWithId = { ...draft, id: draft.id || getEventHash(draft) };
|
||||
const sig = await intentRequest(createSignEventIntent(draftWithId));
|
||||
if (!isHex(sig)) throw new Error("Expected hex signature");
|
||||
|
||||
const event: NostrEvent = { ...draftWithId, sig };
|
||||
if (!verifySignature(event)) throw new Error("Invalid signature");
|
||||
return event;
|
||||
async function signEvent(draft): Promise<NostrEvent> {
|
||||
const signedEventJson = await intentRequest(createSignEventIntent(draft));
|
||||
const signedEvent = JSON.parse(signedEventJson) as NostrEvent;
|
||||
|
||||
if (!verifySignature(signedEvent)) throw new Error("Invalid signature");
|
||||
return signedEvent;
|
||||
}
|
||||
|
||||
async function nip04Encrypt(pubkey: string, plaintext: string): Promise<string> {
|
||||
|
||||
Reference in New Issue
Block a user