Skip to content

Welshman Docs / @welshman/app

@welshman/app ​

Enumerations ​

MembershipStatus ​

Defined in: plugins/rooms.ts:112

Enumeration Members ​

Granted ​

Granted: "granted"

Defined in: plugins/rooms.ts:115

Initial ​

Initial: "initial"

Defined in: plugins/rooms.ts:113

Pending ​

Pending: "pending"

Defined in: plugins/rooms.ts:114


WotScope ​

Defined in: plugins/wot.ts:18

How much of the graph a read counts: every list in the repository, or only the lists the current user's follows published.

Enumeration Members ​

Follows ​

Follows: "follows"

Defined in: plugins/wot.ts:20

Global ​

Global: "global"

Defined in: plugins/wot.ts:19

Classes ​

Interfaces ​

Type Aliases ​

AppConfig ​

AppConfig = object

Defined in: app.ts:11

Properties ​

dufflepudUrl? ​

optional dufflepudUrl?: string

Defined in: app.ts:12

getDefaultRelays? ​

optional getDefaultRelays?: () => string[]

Defined in: app.ts:13

Returns ​

string[]

getIndexerRelays? ​

optional getIndexerRelays?: () => string[]

Defined in: app.ts:14

Returns ​

string[]

getSearchRelays? ​

optional getSearchRelays?: () => string[]

Defined in: app.ts:15

Returns ​

string[]

routes? ​

optional routes?: RouteOverrides

Defined in: app.ts:17


AppOptions ​

AppOptions = object

Defined in: app.ts:20

Properties ​

config? ​

optional config?: AppConfig

Defined in: app.ts:22

getAdapter? ​

optional getAdapter?: AdapterFactory

Defined in: app.ts:23

policies? ​

optional policies?: AppPolicy[]

Defined in: app.ts:24

repository? ​

optional repository?: Repository

Defined in: app.ts:26

user? ​

optional user?: User

Defined in: app.ts:21

wrapManager? ​

optional wrapManager?: WrapManager

Defined in: app.ts:28


AppPolicy ​

AppPolicy = (app) => Unsubscriber

Defined in: policy.ts:22

An app policy is a side effect applied once per app at construction, returning a cleanup function — directly analogous to a socket policy. Policies own everything that subscribes or links components together (event ingestion, stats collection, gift-wrap unwrapping), so the data classes themselves stay pure and free of subscriptions, and teardown is centralized in cleanup().

Parameters ​

app ​

IApp

Returns ​

Unsubscriber


AppSyncOpts ​

AppSyncOpts = object

Defined in: plugins/sync.ts:8

Properties ​

filters ​

filters: Filter[]

Defined in: plugins/sync.ts:10

relays ​

relays: string[]

Defined in: plugins/sync.ts:9


BookmarkSetFields ​

BookmarkSetFields = object

Defined in: plugins/bookmarkSets.ts:10

Properties ​

description? ​

optional description?: string

Defined in: plugins/bookmarkSets.ts:12

image? ​

optional image?: string

Defined in: plugins/bookmarkSets.ts:13

title ​

title: string

Defined in: plugins/bookmarkSets.ts:11


DerivedPluginOptions ​

DerivedPluginOptions<T> = object

Defined in: plugins/base.ts:196

Type Parameters ​

T ​

T

Properties ​

eventToItem ​

eventToItem: EventToItem<T>

Defined in: plugins/base.ts:198

filters ​

filters: Filter[]

Defined in: plugins/base.ts:197

getKey ​

getKey: (item) => string

Defined in: plugins/base.ts:199

Parameters ​
item ​

T

Returns ​

string

loadOptions? ​

optional loadOptions?: MakeLoadItemOptions

Defined in: plugins/base.ts:200


FeedFields ​

FeedFields = object

Defined in: plugins/feeds.ts:19

Properties ​

definition ​

definition: Feed

Defined in: plugins/feeds.ts:22

description? ​

optional description?: string

Defined in: plugins/feeds.ts:21

title ​

title: string

Defined in: plugins/feeds.ts:20


LogMessage ​

LogMessage = object

Defined in: plugins/logger.ts:5

Indexable ​

[key: string]: unknown

Properties ​

at ​

at: number

Defined in: plugins/logger.ts:8

id ​

id: string

Defined in: plugins/logger.ts:7

source ​

source: string

Defined in: plugins/logger.ts:6


MakeFeedControllerOptions ​

MakeFeedControllerOptions = Partial<Omit<FeedControllerOptions, "feed">> & object

Defined in: plugins/feeds.ts:15

Type Declaration ​

feed ​

feed: Feed


NotifyItem ​

NotifyItem = object

Defined in: plugins/notify.ts:6

Properties ​

message ​

message: string

Defined in: plugins/notify.ts:8

receivedAt ​

receivedAt: number

Defined in: plugins/notify.ts:9

url ​

url: string

Defined in: plugins/notify.ts:7


PartialLogMessage ​

PartialLogMessage = object

Defined in: plugins/logger.ts:12

Indexable ​

[key: string]: unknown

Properties ​

at? ​

optional at?: number

Defined in: plugins/logger.ts:14

id? ​

optional id?: string

Defined in: plugins/logger.ts:13


PinboardFields ​

PinboardFields = object

Defined in: plugins/pinboards.ts:12

Properties ​

collaborative? ​

optional collaborative?: boolean

Defined in: plugins/pinboards.ts:17

description? ​

optional description?: string

Defined in: plugins/pinboards.ts:14

image? ​

optional image?: string

Defined in: plugins/pinboards.ts:15

title ​

title: string

Defined in: plugins/pinboards.ts:13

topics? ​

optional topics?: string[]

Defined in: plugins/pinboards.ts:16


Plugin ​

Plugin<T> = (app) => T

Defined in: app.ts:31

Type Parameters ​

T ​

T = unknown

Parameters ​

app ​

IApp

Returns ​

T


PublicationStage ​

PublicationStage = PublicationState["stage"]

Defined in: plugins/publisher.ts:51


PublicationState ​

PublicationState = { stage: "queued"; } | { stage: "delayed"; until: number; } | { stage: "wrapping"; } | { difficulty: number; stage: "pow"; } | { stage: "signing"; } | { results: PublishResultsByRelay; stage: "sending"; } | { results: PublishResultsByRelay; stage: "sent"; } | { error: string; results: PublishResultsByRelay; stage: "failed"; } | { results: PublishResultsByRelay; stage: "aborted"; }

Defined in: plugins/publisher.ts:40

A publication's place in the pipeline. Every terminal state has a result for each relay.


Publishable ​

Publishable = Publication | PublicationGroup

Defined in: plugins/publisher.ts:273


PublishRequest ​

PublishRequest = object

Defined in: plugins/publisher.ts:29

What the caller asked for. A retry rebuilds from it and the publication's current event.

Properties ​

delay? ​

optional delay?: number

Defined in: plugins/publisher.ts:33

event ​

event: EventTemplate

Defined in: plugins/publisher.ts:30

pow? ​

optional pow?: number

Defined in: plugins/publisher.ts:34

priority? ​

optional priority?: number

Defined in: plugins/publisher.ts:35

recipient? ​

optional recipient?: string

Defined in: plugins/publisher.ts:32

relays ​

relays: string[]

Defined in: plugins/publisher.ts:31

timeout? ​

optional timeout?: number

Defined in: plugins/publisher.ts:36


RelayScopedDerivedPluginOptions ​

RelayScopedDerivedPluginOptions<T> = object

Defined in: plugins/base.ts:219

Type Parameters ​

T ​

T

Properties ​

eventToItem ​

eventToItem: EventToItem<T>

Defined in: plugins/base.ts:221

filters ​

filters: Filter[]

Defined in: plugins/base.ts:220

getKey ​

getKey: (item, url) => string | undefined

Defined in: plugins/base.ts:223

Parameters ​
item ​

T

url ​

string

Returns ​

string | undefined

loadOptions? ​

optional loadOptions?: MakeLoadItemOptions

Defined in: plugins/base.ts:224

revalidateOn? ​

optional revalidateOn?: Readable<unknown>

Defined in: plugins/base.ts:227


RelaySignedItem ​

RelaySignedItem = object

Defined in: plugins/relays.ts:71

Methods ​

author() ​

author(): string

Defined in: plugins/relays.ts:71

Returns ​

string


RelayStatsItem ​

RelayStatsItem = object

Defined in: plugins/relayStats.ts:10

Properties ​

close_count ​

close_count: number

Defined in: plugins/relayStats.ts:15

eose_count ​

eose_count: number

Defined in: plugins/relayStats.ts:28

event_count ​

event_count: number

Defined in: plugins/relayStats.ts:18

first_seen ​

first_seen: number

Defined in: plugins/relayStats.ts:12

last_auth ​

last_auth: number

Defined in: plugins/relayStats.ts:25

last_close ​

last_close: number

Defined in: plugins/relayStats.ts:20

last_error ​

last_error: number

Defined in: plugins/relayStats.ts:21

last_event ​

last_event: number

Defined in: plugins/relayStats.ts:24

last_open ​

last_open: number

Defined in: plugins/relayStats.ts:19

last_publish ​

last_publish: number

Defined in: plugins/relayStats.ts:22

last_request ​

last_request: number

Defined in: plugins/relayStats.ts:23

notice_count ​

notice_count: number

Defined in: plugins/relayStats.ts:29

open_count ​

open_count: number

Defined in: plugins/relayStats.ts:14

publish_count ​

publish_count: number

Defined in: plugins/relayStats.ts:16

publish_failure_count ​

publish_failure_count: number

Defined in: plugins/relayStats.ts:27

publish_success_count ​

publish_success_count: number

Defined in: plugins/relayStats.ts:26

recent_errors ​

recent_errors: number[]

Defined in: plugins/relayStats.ts:13

request_count ​

request_count: number

Defined in: plugins/relayStats.ts:17

url ​

url: string

Defined in: plugins/relayStats.ts:11


RelayStatsUpdate ​

RelayStatsUpdate = [string, (stats) => void]

Defined in: plugins/relayStats.ts:8


Room ​

Room = object

Defined in: plugins/rooms.ts:68

Properties ​

admins? ​

optional admins?: RoomAdminsReader

Defined in: plugins/rooms.ts:74

h ​

h: string

Defined in: plugins/rooms.ts:69

id ​

id: string

Defined in: plugins/rooms.ts:70

members? ​

optional members?: RoomMembersReader

Defined in: plugins/rooms.ts:73

meta? ​

optional meta?: RoomMetaReader

Defined in: plugins/rooms.ts:72

url ​

url: string

Defined in: plugins/rooms.ts:71


RoomMembership ​

RoomMembership = object

Defined in: plugins/rooms.ts:121

Properties ​

admins ​

admins: Set<string>

Defined in: plugins/rooms.ts:123

members ​

members: Set<string>

Defined in: plugins/rooms.ts:122

requests ​

requests: Map<string, TrustedEvent>

Defined in: plugins/rooms.ts:124


RoomMeta ​

RoomMeta = object

Defined in: plugins/rooms.ts:78

Properties ​

about? ​

optional about?: string

Defined in: plugins/rooms.ts:81

h ​

h: string

Defined in: plugins/rooms.ts:79

isClosed? ​

optional isClosed?: boolean

Defined in: plugins/rooms.ts:84

isHidden? ​

optional isHidden?: boolean

Defined in: plugins/rooms.ts:85

isPrivate? ​

optional isPrivate?: boolean

Defined in: plugins/rooms.ts:86

isRestricted? ​

optional isRestricted?: boolean

Defined in: plugins/rooms.ts:87

livekit? ​

optional livekit?: boolean

Defined in: plugins/rooms.ts:88

name? ​

optional name?: string

Defined in: plugins/rooms.ts:80

picture? ​

optional picture?: string

Defined in: plugins/rooms.ts:82

pictureMeta? ​

optional pictureMeta?: string[]

Defined in: plugins/rooms.ts:83


Search<V, T> = object

Defined in: plugins/base.ts:35

Type Parameters ​

V ​

V

T ​

T

Properties ​

getOption ​

getOption: (value) => T | undefined

Defined in: plugins/base.ts:38

Parameters ​
value ​

V

Returns ​

T | undefined

getValue ​

getValue: (item) => V

Defined in: plugins/base.ts:37

Parameters ​
item ​

T

Returns ​

V

options ​

options: T[]

Defined in: plugins/base.ts:36

searchOptions ​

searchOptions: (term) => T[]

Defined in: plugins/base.ts:39

Parameters ​
term ​

string

Returns ​

T[]

searchValues ​

searchValues: (term) => V[]

Defined in: plugins/base.ts:40

Parameters ​
term ​

string

Returns ​

V[]


SearchOptions ​

SearchOptions<V, T> = object

Defined in: plugins/base.ts:28

Type Parameters ​

V ​

V

T ​

T

Properties ​

fuseOptions? ​

optional fuseOptions?: IFuseOptions<T>

Defined in: plugins/base.ts:30

getValue ​

getValue: (item) => V

Defined in: plugins/base.ts:29

Parameters ​
item ​

T

Returns ​

V

onSearch? ​

optional onSearch?: (term) => void

Defined in: plugins/base.ts:31

Parameters ​
term ​

string

Returns ​

void

sortFn? ​

optional sortFn?: (items) => any

Defined in: plugins/base.ts:32

Parameters ​
items ​

FuseResult<T>

Returns ​

any


SendWrappedOptions ​

SendWrappedOptions = Omit<PublishRequest, "event" | "relays" | "recipient"> & object

Defined in: plugins/wraps.ts:11

Type Declaration ​

event ​

event: EventTemplate

recipients ​

recipients: string[]


Session ​

Session<M, D> = object

Defined in: session.ts:8

Type Parameters ​

M ​

M extends string = string

D ​

D = unknown

Properties ​

data ​

data: D

Defined in: session.ts:10

method ​

method: M

Defined in: session.ts:9


SessionHandler ​

SessionHandler<M, D> = object

Defined in: session.ts:15

Type Parameters ​

M ​

M extends string

D ​

D

Properties ​

getSigner ​

getSigner: (data) => MaybeAsync<ISigner>

Defined in: session.ts:17

Parameters ​
data ​

D

Returns ​

MaybeAsync<ISigner>

method ​

method: M

Defined in: session.ts:16


Topic ​

Topic = object

Defined in: plugins/topics.ts:10

Properties ​

count ​

count: number

Defined in: plugins/topics.ts:12

name ​

name: string

Defined in: plugins/topics.ts:11

Variables ​

appPolicyAuthAlways ​

const appPolicyAuthAlways: AppPolicy

Defined in: policy.ts:55


appPolicyAuthNever ​

const appPolicyAuthNever: AppPolicy

Defined in: policy.ts:53


appPolicyAuthUnlessBlocked ​

const appPolicyAuthUnlessBlocked: AppPolicy

Defined in: policy.ts:57


appPolicyCacheDecrypt ​

const appPolicyCacheDecrypt: AppPolicy

Defined in: policy.ts:114

Wraps user.signer in a WrappedSigner which checks the plaintext cache before attempting to decrypt something.


appPolicyIngest ​

const appPolicyIngest: AppPolicy

Defined in: policy.ts:70

Ingests every validly signed event received on any socket into the app's repository. The net layer doesn't do this for us, and it's how all the repository-backed collections (and gift-wrap unwrapping) get populated.


appPolicyLogSignerMethods ​

const appPolicyLogSignerMethods: AppPolicy

Defined in: policy.ts:134

Wraps user.signer in a WrappedSigner which logs sign requests to the app logger.


appPolicyNotify ​

const appPolicyNotify: AppPolicy

Defined in: policy.ts:93

Listens for NOTIFY messages on the app's pool into the Notify store.


appPolicyRelayStats ​

const appPolicyRelayStats: AppPolicy

Defined in: policy.ts:86

Listens to socket activity on the app's pool into the RelayStats store.


appPolicyWraps ​

const appPolicyWraps: AppPolicy

Defined in: policy.ts:101

Watches the app's repository for gift wraps (existing and incoming) and feeds them to the unwrap queue.


defaultAppPolicies ​

const defaultAppPolicies: AppPolicy[]

Defined in: policy.ts:158


MAX_UNWRAP_ATTEMPTS ​

const MAX_UNWRAP_ATTEMPTS: 3 = 3

Defined in: plugins/wraps.ts:16


nip01 ​

const nip01: SessionHandler<"nip01", { secret: string; }>

Defined in: session.ts:35


nip07 ​

const nip07: SessionHandler<"nip07", Record<string, never>>

Defined in: session.ts:40


nip46 ​

const nip46: SessionHandler<"nip46", { clientSecret: string; relays: string[]; signerPubkey: string; }>

Defined in: session.ts:45


nip55 ​

const nip55: SessionHandler<"nip55", { pubkey: string; signer: string; }>

Defined in: session.ts:51


pomade ​

const pomade: SessionHandler<"pomade", { clientOptions: ClientOptions; email: string; }>

Defined in: session.ts:59


sessionHandlers ​

const sessionHandlers: Map<string, SessionHandler<string, any>>

Defined in: session.ts:70


STAGES ​

const STAGES: Stage[]

Defined in: plugins/publisher.ts:406


TERMINAL_STAGES ​

const TERMINAL_STAGES: PublicationStage[]

Defined in: plugins/publisher.ts:53


UNWRAP_RETRY_DELAY ​

const UNWRAP_RETRY_DELAY: 5000 = 5_000

Defined in: plugins/wraps.ts:19

Functions ​

createApp() ​

createApp(options?): App

Defined in: createApp.ts:13

Creates a batteries-included app: an App wired with the default app policies (event ingestion, relay-stats collection, gift-wrap unwrapping). Reach data modules via app.use(Profiles), app.use(FollowLists), etc.

For a bare app (no default side effects) construct new App(...) directly, or pass your own policies.

Parameters ​

options? ​

AppOptions = {}

Returns ​

App


createSearch() ​

createSearch<V, T>(options, opts): Search<V, T>

Defined in: plugins/base.ts:48

A reusable fuzzy-search primitive over a fixed list of options. Plugins that expose a search (profiles, topics, relays) build one of these reactively from their collection. Blends fuse scoring with an optional sortFn.

Type Parameters ​

V ​

V

T ​

T

Parameters ​

options ​

T[]

opts ​

SearchOptions<V, T>

Returns ​

Search<V, T>


defineSessionHandler() ​

defineSessionHandler<M, D>(handler): SessionHandler<M, D>

Defined in: session.ts:25

Define a session handler. M and D are inferred from the arguments, so getSigner is type-checked against the data shape — and the same handler is used to build typed sessions (toSession) and to reconstruct signers.

Type Parameters ​

M ​

M extends string

D ​

D

Parameters ​

handler ​

SessionHandler<M, D>

Returns ​

SessionHandler<M, D>


getSignerFromSession() ​

getSignerFromSession(session): MaybeAsync<ISigner> | undefined

Defined in: session.ts:80

Parameters ​

session ​

Session

Returns ​

MaybeAsync<ISigner> | undefined


makeAppPolicyAuth() ​

makeAppPolicyAuth(shouldAuth, recheck?): AppPolicy

Defined in: policy.ts:35

Builds an app policy that authenticates the app's sockets (NIP-42) with the user's signer. It appends an auth socket policy to the pool's socketPolicies, so every socket the pool creates answers AUTH challenges according to shouldAuth; the policy is spliced back out on cleanup. No-op when the app has no user.

Use the appPolicyAuthAlways / appPolicyAuthNever presets below, or call this with a custom predicate.

Parameters ​

shouldAuth ​

(socket, app) => boolean

recheck? ​

(app) => Readable<unknown>

Returns ​

AppPolicy


makeRelayRoleKey() ​

makeRelayRoleKey(url, d): string

Defined in: plugins/relayRoles.ts:13

Parameters ​

url ​

string

d ​

string

Returns ​

string


makeRelayStatsItem() ​

makeRelayStatsItem(url): RelayStatsItem

Defined in: plugins/relayStats.ts:32

Parameters ​

url ​

string

Returns ​

RelayStatsItem


makeRoomKey() ​

makeRoomKey(url, room): string

Defined in: plugins/rooms.ts:57

Parameters ​

url ​

string

room ​

string

Returns ​

string


mergeResults() ​

mergeResults(publications): PublishResultsByRelay

Defined in: plugins/publisher.ts:222

Parameters ​

publications ​

Publication[]

Returns ​

PublishResultsByRelay


publish() ​

publish(command): Publication

Defined in: command.ts:25

Parameters ​

command ​

Command

Returns ​

Publication


publishToRelays() ​

publishToRelays(urls): (command) => Publication

Defined in: command.ts:27

Parameters ​

urls ​

string[]

Returns ​

(command) => Publication


registerSessionHandler() ​

registerSessionHandler(handler): void

Defined in: session.ts:72

Parameters ​

handler ​

SessionHandler<string, any>

Returns ​

void


splitRelayRoleKey() ​

splitRelayRoleKey(key): [string, string]

Defined in: plugins/relayRoles.ts:15

Parameters ​

key ​

string

Returns ​

[string, string]


splitRoomKey() ​

splitRoomKey(key): [string, string]

Defined in: plugins/rooms.ts:59

Parameters ​

key ​

string

Returns ​

[string, string]


toSession() ​

toSession<M, D>(handler, data): Session<M, D>

Defined in: session.ts:28

Build a typed, serializable session from a handler and its data.

Type Parameters ​

M ​

M extends string

D ​

D

Parameters ​

handler ​

SessionHandler<M, D>

data ​

D

Returns ​

Session<M, D>


unregisterSessionHandler() ​

unregisterSessionHandler(handler): void

Defined in: session.ts:76

Parameters ​

handler ​

SessionHandler<string, any>

Returns ​

void