Skip to main content

Class: TrustPool

Defined in: db/session.ts:484

Each commit in the graph is signed with the private key of the session that generated it. The trust pool manages all known sessions and their public keys which are later used to verify that the commits in the graph make only modifications that are valid. Each commit's signature is checked against its session's public key, and then the modifications themselves are checked to ensure the creator only made changes within their scope of permissions.

Constructors​

Constructor​

new TrustPool(orgId, currentSession, roots?, trustedSessions?, changeCallback?): TrustPool

Defined in: db/session.ts:490

Parameters​

ParameterType
orgIdstring
currentSessionOwnedSession
roots?Session[]
trustedSessions?Session[]
changeCallback?() => void

Returns​

TrustPool

Properties​

PropertyModifierTypeDefined in
orgIdreadonlystringdb/session.ts:491
rootsreadonlySession[]db/session.ts:485

Accessors​

currentSession​

Get Signature​

get currentSession(): OwnedSession

Defined in: db/session.ts:507

Returns​

OwnedSession


trustedSessions​

Get Signature​

get trustedSessions(): Session[]

Defined in: db/session.ts:511

Returns​

Session[]

Methods​

addSession()​

addSession(s, commit): Promise<boolean>

Defined in: db/session.ts:564

When a commit containing a session is discovered, use this method to add it to the trust pool. This method does the necessary checks to ensure the integrity of this commit, then if all checks pass it adds the session to the trust pool.

Parameters​

ParameterTypeDescription
sSession-
commitCommit-

Returns​

Promise<boolean>


addSessionUnsafe()​

addSessionUnsafe(s): boolean

Defined in: db/session.ts:579

Adds the given session to the trust pool, without verifying its origin commit. Be very careful to only use this method for verified sessions.

Parameters​

ParameterTypeDescription
sSessionThe session to add to this trust pool.

Returns​

boolean

Whether the session has been added or not.


getSession()​

getSession(id): Session

Defined in: db/session.ts:624

Parameters​

ParameterType
idstring

Returns​

Session


sessions()​

sessions(): Generator<Session>

Defined in: db/session.ts:515

Returns​

Generator<Session>


verify()​

verify(commit): Promise<boolean>

Defined in: db/session.ts:630

Parameters​

ParameterType
commitCommit

Returns​

Promise<boolean>