mirror of
https://github.com/believethehype/nostrdvm.git
synced 2025-04-10 21:00:02 +02:00
remove some unused code
This commit is contained in:
parent
faf05d88b7
commit
c277e2d46b
@ -1,7 +1,9 @@
|
||||
import { getEventHash, nip19, verifySignature } from "nostr-tools";
|
||||
// taken from https://github.com/hzrd149/nostrudel
|
||||
|
||||
import { nip19, verifySignature } from "nostr-tools";
|
||||
import createDefer, { Deferred } from "./classes/deffered";
|
||||
import { getPubkeyFromDecodeResult, isHex, isHexKey } from "./helpers/nip19";
|
||||
import { DraftNostrEvent, NostrEvent } from "./types/nostr-event";
|
||||
import { getPubkeyFromDecodeResult, isHexKey } from "./helpers/nip19";
|
||||
import { 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`;
|
||||
@ -11,16 +13,6 @@ export function createSignEventIntent(draft) {
|
||||
JSON.stringify(draft),
|
||||
)}#Intent;scheme=nostrsigner;S.compressionType=none;S.returnType=event;S.type=sign_event;end`;
|
||||
}
|
||||
export function createNip04EncryptIntent(pubkey: string, plainText: string) {
|
||||
return `intent:${encodeURIComponent(
|
||||
plainText,
|
||||
)}#Intent;scheme=nostrsigner;S.pubKey=${pubkey};S.compressionType=none;S.returnType=signature;S.type=nip04_encrypt;end`;
|
||||
}
|
||||
export function createNip04DecryptIntent(pubkey: string, data: string) {
|
||||
return `intent:${encodeURIComponent(
|
||||
data,
|
||||
)}#Intent;scheme=nostrsigner;S.pubKey=${pubkey};S.compressionType=none;S.returnType=signature;S.type=nip04_decrypt;end`;
|
||||
}
|
||||
|
||||
let pendingRequest: Deferred<string> | null = null;
|
||||
|
||||
@ -79,26 +71,10 @@ async function signEvent(draft): Promise<NostrEvent> {
|
||||
return signedEvent;
|
||||
}
|
||||
|
||||
async function nip04Encrypt(pubkey: string, plaintext: string): Promise<string> {
|
||||
const data = await intentRequest(createNip04EncryptIntent(pubkey, plaintext));
|
||||
return data;
|
||||
}
|
||||
async function nip04Decrypt(pubkey: string, data: string): Promise<string> {
|
||||
const plaintext = await intentRequest(createNip04DecryptIntent(pubkey, data));
|
||||
return plaintext;
|
||||
}
|
||||
|
||||
const amberSignerService = {
|
||||
supported: navigator.userAgent.includes("Android") && navigator.clipboard,
|
||||
getPublicKey,
|
||||
signEvent,
|
||||
nip04Encrypt,
|
||||
nip04Decrypt,
|
||||
signEvent
|
||||
};
|
||||
|
||||
// if (import.meta.env.DEV) {
|
||||
// // @ts-ignore
|
||||
// window.amberSignerService = amberSignerService;
|
||||
// }
|
||||
|
||||
export default amberSignerService;
|
||||
|
@ -1,9 +1,5 @@
|
||||
import { getPublicKey, nip19 } from "nostr-tools";
|
||||
|
||||
export function isHex(str?: string) {
|
||||
if (str?.match(/^[0-9a-f]+$/i)) return true;
|
||||
return false;
|
||||
}
|
||||
export function isHexKey(key?: string) {
|
||||
if (key?.toLowerCase()?.match(/^[0-9a-f]{64}$/)) return true;
|
||||
return false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user