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
Returns
User
Properties
pubkey
readonlypubkey: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
options?
Returns
Promise<SignedEvent>
wrapSigner()
wrapSigner(
wrap): () =>void
Defined in: app/src/user.ts:57
Parameters
wrap
Returns
():
void
Returns
void
fromSession()
staticfromSession(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
Returns
Promise<undefined | User>
fromSigner()
staticfromSigner(signer):Promise<User>
Defined in: app/src/user.ts:23
Parameters
signer
Returns
Promise<User>
require()
staticrequire(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
Returns
User