Re-work connection auth

This commit is contained in:
Jon Staab
2024-10-14 15:18:21 -07:00
parent e025a8de36
commit f841de2a50
10 changed files with 171 additions and 115 deletions
+3 -3
View File
@@ -2,10 +2,10 @@ import {partition} from "@welshman/lib"
import {defaultOptimizeSubscriptions, getDefaultNetContext as originalGetDefaultNetContext} from "@welshman/net"
import type {Subscription, RelaysAndFilters, NetContext} from "@welshman/net"
import {WRAP, unionFilters, isSignedEvent, hasValidSignature} from "@welshman/util"
import type {TrustedEvent} from "@welshman/util"
import type {TrustedEvent, StampedEvent} from "@welshman/util"
import {tracker, repository} from './core'
import {makeRouter, getFilterSelections} from './router'
import {onAuth, getSession} from './session'
import {getSession, signer} from './session'
import type {Router} from './router'
import {loadProfile} from './profiles'
@@ -20,7 +20,7 @@ export type AppContext = {
export const getDefaultNetContext = (overrides: Partial<NetContext> = {}) => ({
...originalGetDefaultNetContext(),
onAuth: onAuth,
signEvent: (event: StampedEvent) => signer.get()?.sign(event),
onEvent: (url: string, event: TrustedEvent) => {
tracker.track(event.id, url)
repository.publish(event)