Class VaultInternal

Hierarchy

  • CreateDestroyStartStop
    • VaultInternal

Constructors

  • Parameters

    • __namedParameters: {
          db: DB;
          efs: EncryptedFS;
          keyRing: KeyRing;
          logger: Logger;
          vaultId: VaultId;
          vaultsDbPath: readonly (string | Buffer)[];
      }
      • db: DB
      • efs: EncryptedFS
      • keyRing: KeyRing
      • logger: Logger
      • vaultId: VaultId
      • vaultsDbPath: readonly (string | Buffer)[]

    Returns VaultInternal

Properties

[initLock]: RWLockWriter
db: DB
efs: EncryptedFS
efsVault: EncryptedFS
keyRing: KeyRing
lock: RWLockWriter = ...
logger: Logger
vaultDataDir: string
vaultGitDir: string
vaultId: VaultId
vaultIdEncoded: string
vaultMetadataDbPath: readonly (string | Buffer)[]
vaultsDbPath: readonly (string | Buffer)[]
vaultsNamesPath: readonly (string | Buffer)[]
dirtyKey: string = 'dirty'
nameKey: string = 'key'
remoteKey: string = 'remote'

Accessors

  • get [destroyed](): boolean
  • Returns boolean

  • get [eventHandled](): ReadonlyWeakSet<Event>
  • Returns ReadonlyWeakSet<Event>

  • get [eventHandlers](): ReadonlyMap<string, Set<EventHandlerInfo>>
  • Returns ReadonlyMap<string, Set<EventHandlerInfo>>

  • get [eventTarget](): EventTarget
  • Returns EventTarget

  • get [handleEventError](): ((evt) => void)
  • Returns ((evt) => void)

      • (evt): void
      • Parameters

        • evt: EventError

        Returns void

  • get [running](): boolean
  • Returns boolean

  • get [statusP](): Promise<Status>
  • Returns Promise<Status>

  • get [status](): Status
  • Returns Status

Methods

  • Parameters

    • type: string
    • callback: null | EventListenerOrEventListenerObject
    • Optional options: boolean | AddEventListenerOptions

    Returns void

  • Cleans the git working directory by checking out the canonical branch. This will remove any un-committed changes since any untracked or modified files outside a commit is dirty state. Dirty state should only happen if the usual commit procedure was interrupted ungracefully.

    Parameters

    • ctx: ContextTimed

    Returns Promise<void>

  • Creates a commit while moving the canonicalBranch reference to that new commit. If the commit creates a branch from the canonical history. Then the new commit becomes the new canonical history and the old history is removed from the old canonical head to the branch point. This is to maintain the strict non-branching linear history.

    Parameters

    • ctx: ContextTimed

    Returns Promise<void>

  • Parameters

    • Optional tran: DBTransaction

    Returns Promise<void>

  • We use a protected destroy method to avoid the async-init lifecycle deadlocking when doing the recursive call to create a DBTransaction.

    Parameters

    • tran: DBTransaction

    Returns Promise<void>

  • Parameters

    • event: Event

    Returns boolean

  • This will walk the current canonical branch history and delete any objects that are not a part of it. This is costly since it will compare the walked tree with all existing objects.

    Parameters

    • ctx: ContextTimed

    Returns Promise<void>

  • This will walk from the startId to the StopId deleting objects as it goes. This is smarter since it only walks over the old history and not everything.

    Parameters

    • startId: string
    • stopId: string
    • ctx: ContextTimed

    Returns Promise<void>

  • Pulls changes to a vault from the vault's default remote. If pullNodeId and pullVaultNameOrId it uses that for the remote instead.

    Parameters

    • __namedParameters: {
          nodeManager: NodeManager;
          pullNodeId?: NodeId;
          pullVaultNameOrId?: string | VaultId;
      }
    • Optional tran: DBTransaction
    • Optional ctx: Partial<ContextTimedInput>

    Returns Promise<void>

  • With context handler for using a vault in a read-only context.

    Type Parameters

    • T

    Parameters

    • f: ((fs) => Promise<T>)

    Returns Promise<T>

  • With context handler for using a vault in a read-only context for a generator.

    Type Parameters

    • T

    • TReturn

    • TNext

    Parameters

    • g: ((fs) => AsyncGenerator<T, TReturn, TNext>)
        • (fs): AsyncGenerator<T, TReturn, TNext>
        • Parameters

          Returns AsyncGenerator<T, TReturn, TNext>

    Returns AsyncGenerator<T, TReturn, TNext>

  • Parameters

    • type: string
    • callback: null | EventListenerOrEventListenerObject
    • Optional options: boolean | EventListenerOptions

    Returns void

  • Does an idempotent initialization of the git repository for the vault. If the vault is in a dirty state then we clean up the working directory or any history not part of the canonical branch.

    Parameters

    • tran: DBTransaction
    • ctx: ContextTimed

    Returns Promise<string>

  • Sets up the vault metadata. Creates a dirty boolean in the database to track dirty state of the vault. Also adds the vault's name to the database.

    Parameters

    • __namedParameters: {
          vaultName?: string;
      }
      • Optional vaultName?: string
    • tran: DBTransaction

    Returns Promise<void>

  • Parameters

    • __namedParameters: {
          fresh?: boolean;
          vaultName?: string;
      } = {}
      • Optional fresh?: boolean
      • Optional vaultName?: string
    • Optional tran: DBTransaction
    • Optional ctx: ContextTimed

    Returns Promise<void>

  • We use a protected start method to avoid the async-init lifecycle deadlocking when doing the recursive call to create a DBTransaction.

    Parameters

    • __namedParameters: {
          fresh: boolean;
          vaultName?: string;
      }
      • fresh: boolean
      • Optional vaultName?: string
    • tran: DBTransaction
    • Optional ctx: Partial<ContextTimedInput>

    Returns Promise<void>

  • Checks out the vault repository to specific commit ID or special tags. This changes the working directory and updates the HEAD reference.

    Parameters

    • ref: string = tagLast

    Returns Promise<void>

  • With context handler for using a vault in a writable context.

    Parameters

    • f: ((fs) => Promise<void>)
    • Optional tran: DBTransaction
    • Optional ctx: Partial<ContextTimedInput>

    Returns Promise<void>

  • With context handler for using a vault in a writable context for a generator.

    Type Parameters

    • T

    • TReturn

    • TNext

    Parameters

    • g: ((fs) => AsyncGenerator<T, TReturn, TNext>)
        • (fs): AsyncGenerator<T, TReturn, TNext>
        • Parameters

          Returns AsyncGenerator<T, TReturn, TNext>

    • Optional tran: DBTransaction
    • Optional ctx: Partial<ContextTimedInput>

    Returns AsyncGenerator<T, TReturn, TNext>

  • Will create a new vault by cloning the vault from a remote node.

    Parameters

    • __namedParameters: {
          db: DB;
          efs: EncryptedFS;
          keyRing: KeyRing;
          logger?: Logger;
          nodeManager: NodeManager;
          targetNodeId: NodeId;
          targetVaultNameOrId: string | VaultId;
          vaultId: VaultId;
          vaultsDbPath: readonly (string | Buffer)[];
      }
      • db: DB
      • efs: EncryptedFS
      • keyRing: KeyRing
      • Optional logger?: Logger
      • nodeManager: NodeManager
      • targetNodeId: NodeId
      • targetVaultNameOrId: string | VaultId
      • vaultId: VaultId
      • vaultsDbPath: readonly (string | Buffer)[]
    • Optional tran: DBTransaction
    • Optional ctx: Partial<ContextTimedInput>

    Returns Promise<VaultInternal>

  • Creates a VaultInternal. If no state already exists then a new state for the vault is initialized. If state already exists then this just creates the VaultInternal instance for managing that state.

    Parameters

    • __namedParameters: {
          db: DB;
          efs: EncryptedFS;
          fresh?: boolean;
          keyRing: KeyRing;
          logger?: Logger;
          vaultId: VaultId;
          vaultName?: string;
          vaultsDbPath: readonly (string | Buffer)[];
      }
      • db: DB
      • efs: EncryptedFS
      • Optional fresh?: boolean
      • keyRing: KeyRing
      • Optional logger?: Logger
      • vaultId: VaultId
      • Optional vaultName?: string
      • vaultsDbPath: readonly (string | Buffer)[]
    • Optional tran: DBTransaction
    • Optional ctx: Partial<ContextTimedInput>

    Returns Promise<VaultInternal>

Generated using TypeDoc