Skip to main content

Class: TrustPool

Defined in: db/session.ts:491

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:497

Parameters

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

Returns

TrustPool

Properties

PropertyModifierTypeDefined in
orgIdreadonlystringdb/session.ts:498
rootsreadonlySession[]db/session.ts:492

Accessors

currentSession

Get Signature

get currentSession(): OwnedSession

Defined in: db/session.ts:514

Returns

OwnedSession


trustedSessions

Get Signature

get trustedSessions(): Session[]

Defined in: db/session.ts:518

Returns

Session[]

Methods

addSession()

addSession(s, commit): Promise<boolean>

Defined in: db/session.ts:571

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:586

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:631

Parameters

ParameterType
idstring

Returns

Session


sessions()

sessions(): Generator<Session>

Defined in: db/session.ts:522

Returns

Generator<Session>


verify()

verify(commit): Promise<boolean>

Defined in: db/session.ts:637

Parameters

ParameterType
commitCommit

Returns

Promise<boolean>