Remove CustomEvent

This commit is contained in:
Jon Staab
2024-08-19 08:59:39 -07:00
parent 975d51cafa
commit 8d3ca2ef6a
25 changed files with 124 additions and 120 deletions
+2 -2
View File
@@ -1,4 +1,4 @@
import {EventTemplate} from '@welshman/util'
import {StampedEvent} from '@welshman/util'
import {nip04, nip44, own, hash, sign, getPubkey, ISigner, makeSecret} from "../util"
export class Nip01Signer implements ISigner {
@@ -14,7 +14,7 @@ export class Nip01Signer implements ISigner {
getPubkey = async () => this.pubkey
sign = async (event: EventTemplate) => sign(hash(own(this.pubkey, event)), this.secret)
sign = async (event: StampedEvent) => sign(hash(own(event, this.pubkey)), this.secret)
nip04 = {
encrypt: async (pubkey: string, message: string) =>
+3 -3
View File
@@ -1,4 +1,4 @@
import {EventTemplate} from '@welshman/util'
import {StampedEvent} from '@welshman/util'
import {hash, own, Sign, ISigner, EncryptionImplementation} from '../util'
export type Nip07 = {
@@ -30,8 +30,8 @@ export class Nip07Signer implements ISigner {
getPubkey = async () => getNip07()!.getPublicKey()!
sign = async (template: EventTemplate) => {
const event = hash(own(await this.getPubkey(), template))
sign = async (template: StampedEvent) => {
const event = hash(own(template, await this.getPubkey()))
return this.#then(ext => ext.signEvent(event))
}
+4 -4
View File
@@ -1,7 +1,7 @@
import {finalizeEvent, getPublicKey} from "nostr-tools"
import {hexToBytes} from '@noble/hashes/utils'
import {Emitter, tryCatch, randomId, sleep, equals, now} from "@welshman/lib"
import {createEvent, TrustedEvent, EventTemplate, NOSTR_CONNECT} from "@welshman/util"
import {createEvent, TrustedEvent, StampedEvent, NOSTR_CONNECT} from "@welshman/util"
import {subscribe, publish, Subscription} from "@welshman/net"
import {nip04, nip44, ISigner, decrypt, hash, own} from '../util'
import {Nip01Signer} from './nip01'
@@ -138,7 +138,7 @@ export class Nip46Broker extends Emitter {
return this.#connectResult === "ack"
}
signEvent = async (event: EventTemplate) => {
signEvent = async (event: StampedEvent) => {
return JSON.parse(await this.request("sign_event", [JSON.stringify(event)]) as string)
}
@@ -169,8 +169,8 @@ export class Nip46Signer implements ISigner {
getPubkey = async () => this.broker.pubkey
sign = (template: EventTemplate) =>
this.broker.signEvent(hash(own(this.broker.pubkey, template)))
sign = (template: StampedEvent) =>
this.broker.signEvent(hash(own(template, this.broker.pubkey)))
nip04 = {
encrypt: this.broker.nip04Encrypt,