Make svelte peer dependency more permissive
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
"throttle-debounce": "^5.0.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@pomade/core": "^0.0.5",
|
||||
"@pomade/core": "^0.0.9",
|
||||
"@welshman/feeds": "workspace:*",
|
||||
"@welshman/lib": "workspace:*",
|
||||
"@welshman/net": "workspace:*",
|
||||
@@ -32,13 +32,12 @@
|
||||
"@welshman/signer": "workspace:*",
|
||||
"@welshman/store": "workspace:*",
|
||||
"@welshman/util": "workspace:*",
|
||||
"nostr-tools": "^2.19.4",
|
||||
"svelte": "^4.2.18"
|
||||
"svelte": "^4.0.0 || ^5.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"rimraf": "~6.0.0",
|
||||
"typescript": "~5.8.0",
|
||||
"@pomade/core": "^0.0.5",
|
||||
"@pomade/core": "^0.0.9",
|
||||
"@types/throttle-debounce": "^5.0.2",
|
||||
"@welshman/feeds": "workspace:*",
|
||||
"@welshman/lib": "workspace:*",
|
||||
@@ -47,6 +46,6 @@
|
||||
"@welshman/signer": "workspace:*",
|
||||
"@welshman/store": "workspace:*",
|
||||
"@welshman/util": "workspace:*",
|
||||
"svelte": "^4.2.18"
|
||||
"svelte": "^5.39.12"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import * as nt44 from "nostr-tools/nip44"
|
||||
import {Client, ClientOptions} from "@pomade/core"
|
||||
import {Client, ClientOptions, PomadeSigner} from "@pomade/core"
|
||||
import {derived, writable} from "svelte/store"
|
||||
import {cached, randomId, append, omit, equals, assoc, thrower, hexToBytes} from "@welshman/lib"
|
||||
import {cached, randomId, append, omit, equals, assoc} from "@welshman/lib"
|
||||
import {withGetter} from "@welshman/store"
|
||||
import {
|
||||
Wallet,
|
||||
@@ -21,75 +20,10 @@ import {
|
||||
Nip01Signer,
|
||||
Nip55Signer,
|
||||
ISigner,
|
||||
SignOptions,
|
||||
signWithOptions,
|
||||
} from "@welshman/signer"
|
||||
import {WrapManager} from "@welshman/net"
|
||||
import {tracker, repository} from "./core.js"
|
||||
|
||||
class PomadeSigner implements ISigner {
|
||||
#pubkey: string
|
||||
#sharedSecretCache = new Map<string, Uint8Array<ArrayBuffer>>()
|
||||
|
||||
constructor(readonly client: Client) {
|
||||
this.#pubkey = client.userPubkey
|
||||
}
|
||||
|
||||
private getSharedSecret = async (pubkey: string) => {
|
||||
let sharedSecret = this.#sharedSecretCache.get(pubkey)
|
||||
if (!sharedSecret) {
|
||||
const hexSharedSecret = await this.client.getConversationKey(pubkey)
|
||||
|
||||
if (hexSharedSecret) {
|
||||
sharedSecret = hexToBytes(hexSharedSecret)
|
||||
this.#sharedSecretCache.set(pubkey, sharedSecret)
|
||||
}
|
||||
}
|
||||
|
||||
return sharedSecret
|
||||
}
|
||||
|
||||
getPubkey = async () => this.#pubkey
|
||||
|
||||
sign = (event: StampedEvent, options: SignOptions = {}) => {
|
||||
const promise = this.client.sign(event).then(r => {
|
||||
if (!r.event) {
|
||||
throw new Error(r.messages[0]?.payload.message || "Failed to sign event")
|
||||
}
|
||||
|
||||
return r.event
|
||||
})
|
||||
|
||||
return signWithOptions(promise, options)
|
||||
}
|
||||
|
||||
nip04 = {
|
||||
encrypt: thrower("PomadeSigner does not support nip44"),
|
||||
decrypt: thrower("PomadeSigner does not support nip44"),
|
||||
}
|
||||
|
||||
nip44 = {
|
||||
encrypt: async (pubkey: string, message: string) => {
|
||||
const sharedSecret = await this.getSharedSecret(pubkey)
|
||||
|
||||
if (!sharedSecret) {
|
||||
throw new Error("Failed to get shared secret")
|
||||
}
|
||||
|
||||
return nt44.v2.encrypt(message, sharedSecret)
|
||||
},
|
||||
decrypt: async (pubkey: string, message: string) => {
|
||||
const sharedSecret = await this.getSharedSecret(pubkey)
|
||||
|
||||
if (!sharedSecret) {
|
||||
throw new Error("Failed to get shared secret")
|
||||
}
|
||||
|
||||
return nt44.v2.decrypt(message, sharedSecret)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export enum SessionMethod {
|
||||
Nip01 = "nip01",
|
||||
Nip07 = "nip07",
|
||||
|
||||
Reference in New Issue
Block a user