refine session type

This commit is contained in:
Jon Staab
2024-12-02 09:28:49 -08:00
parent 6d1494be19
commit 2fa49e0dec
+30 -6
View File
@@ -4,15 +4,39 @@ import {withGetter, synced} from "@welshman/store"
import {type Nip46Handler} from "@welshman/signer"
import {Nip46Broker, Nip46Signer, Nip07Signer, Nip01Signer, Nip55Signer} from "@welshman/signer"
export type Session = {
method: string
export type SessionNip01 = {
method: 'nip01'
pubkey: string
token?: string
secret?: string
handler?: Nip46Handler
signer?: string
secret: string
}
export type SessionNip07 = {
method: 'nip07'
pubkey: string
}
export type SessionNip46 = {
method: 'nip46'
pubkey: string
secret: string
handler: Nip46Handler
}
export type SessionNip55 = {
method: 'nip55'
pubkey: string
signer: string
}
export type SessionAnyMethod =
SessionNip01 |
SessionNip07 |
SessionNip46 |
SessionNip55
export type Session = SessionAnyMethod & Record<string, any>
export const pubkey = withGetter(synced<string | null>("pubkey", null))
export const sessions = withGetter(synced<Record<string, Session>>("sessions", {}))