Skip to content

Welshman Docs / @welshman/app / User

Class: User ​

Defined in: app/src/user.ts:17

A single identity: a pubkey plus the signer that proves it. An App is centered on (at most) one User, since the data a user can access depends entirely on who they are.

signer is mutable so app policies can layer behavior onto it after construction via wrapSigner — e.g. appPolicyCacheDecrypt and appPolicyLogSignerMethods.

Constructors ​

Constructor ​

new User(pubkey, signer): User

Defined in: app/src/user.ts:18

Parameters ​

pubkey ​

string

signer ​

ISigner

Returns ​

User

Properties ​

pubkey ​

readonly pubkey: string

Defined in: app/src/user.ts:19


signer ​

signer: ISigner

Defined in: app/src/user.ts:20

Methods ​

nip44EncryptToSelf() ​

nip44EncryptToSelf(payload): Promise<string>

Defined in: app/src/user.ts:55

Parameters ​

payload ​

string

Returns ​

Promise<string>


sign() ​

sign(event, options?): Promise<SignedEvent>

Defined in: app/src/user.ts:53

Parameters ​

event ​

StampedEvent

options? ​

SignOptions

Returns ​

Promise<SignedEvent>


wrapSigner() ​

wrapSigner(wrap): () => void

Defined in: app/src/user.ts:57

Parameters ​

wrap ​

SignerMethodWrapper

Returns ​

(): void

Returns ​

void


fromSession() ​

static fromSession(session): Promise<undefined | User>

Defined in: app/src/user.ts:35

Reconstruct a signing user from a persisted session, using the registered session handlers to find the one for the session's method. The pubkey is derived from the signer. Returns undefined when no handler is registered for the session's method.

Parameters ​

session ​

Session

Returns ​

Promise<undefined | User>


fromSigner() ​

static fromSigner(signer): Promise<User>

Defined in: app/src/user.ts:23

Parameters ​

signer ​

ISigner

Returns ​

Promise<User>


require() ​

static require(app): User

Defined in: app/src/user.ts:45

Return the app's signed-in user, throwing if there isn't one — the entry point for actions that can only run as a user (publishing, signing).

Parameters ​

app ​

IApp

Returns ​

User