Remove CustomEvent
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import {schnorr} from '@noble/curves/secp256k1'
|
||||
import {bytesToHex, hexToBytes} from '@noble/hashes/utils'
|
||||
import {nip04 as nt04, nip44 as nt44, generateSecretKey, getPublicKey, getEventHash} from "nostr-tools"
|
||||
import {cached} from '@welshman/lib'
|
||||
import {SignedEvent, HashedEvent, EventTemplate, OwnedEvent} from '@welshman/util'
|
||||
import {cached, now} from '@welshman/lib'
|
||||
import {SignedEvent, HashedEvent, EventTemplate, StampedEvent, OwnedEvent} from '@welshman/util'
|
||||
|
||||
export const makeSecret = () => bytesToHex(generateSecretKey())
|
||||
|
||||
@@ -13,9 +13,11 @@ export const getHash = (event: OwnedEvent) => getEventHash(event)
|
||||
export const getSig = (event: HashedEvent, secret: string) =>
|
||||
bytesToHex(schnorr.sign(event.id, secret))
|
||||
|
||||
export const own = (pubkey: string, event: EventTemplate) => ({...event, pubkey})
|
||||
export const stamp = (event: EventTemplate, created_at = now()) => ({...event, created_at})
|
||||
|
||||
export const hash = (event: OwnedEvent): HashedEvent => ({...event, id: getHash(event)})
|
||||
export const own = (event: StampedEvent, pubkey: string) => ({...event, pubkey})
|
||||
|
||||
export const hash = (event: OwnedEvent) => ({...event, id: getHash(event)})
|
||||
|
||||
export const sign = (event: HashedEvent, secret: string) => ({...event, sig: getSig(event, secret)})
|
||||
|
||||
@@ -35,7 +37,7 @@ export const nip44 = {
|
||||
decrypt: (pubkey: string, secret: string, m: string) => nt44.v2.decrypt(m, nip44.getSharedSecret(secret, pubkey)),
|
||||
}
|
||||
|
||||
export type Sign = (event: EventTemplate) => Promise<SignedEvent>
|
||||
export type Sign = (event: StampedEvent) => Promise<SignedEvent>
|
||||
|
||||
export type Encrypt = (pubkey: string, message: string) => Promise<string>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user