Class MapeoManager

Hierarchy

  • TypedEmitter
    • MapeoManager

Constructors

  • Parameters

    • opts: {
          clientMigrationsFolder: string;
          coreStorage: string | CoreStorage;
          dbFolder: string;
          defaultConfigPath: undefined | string;
          fastify: FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>;
          projectMigrationsFolder: string;
          rootKey: Buffer;
      }
      • clientMigrationsFolder: string

        path for drizzle migrations folder for client database

      • coreStorage: string | CoreStorage

        Folder for hypercore storage or a function that returns a RandomAccessStorage instance

      • dbFolder: string

        Folder for sqlite Dbs. Folder must exist. Use ':memory:' to store everything in-memory

      • defaultConfigPath: undefined | string
      • fastify: FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProviderDefault>

        Fastify server instance

      • projectMigrationsFolder: string

        path for drizzle migrations folder for project database

      • rootKey: Buffer

        16-bytes of random data that uniquely identify the device, used to derive a 32-byte master key, which is used to derive all the keypairs used for Mapeo

    Returns MapeoManager

Accessors

  • get deviceId(): string
  • Returns string

Methods

  • Create a Mapeo replication stream. This replication connects the Mapeo RPC channel and allows invites. All active projects will sync automatically to this replication stream. Only use for local (trusted) connections, because the RPC channel key is public. To sync a specific project without connecting RPC, use project[kProjectReplication].

    Parameters

    • isInitiator: boolean

    Returns ReplicationStream

  • Add a project to this device. After adding a project the client should await project.$waitForInitialSync() to ensure that the device has downloaded their proof of project membership and the project config.

    Parameters

    • projectJoinDetails: Pick<ProjectJoinDetails, "projectKey" | "encryptionKeys"> & {
          projectName: string;
      }
    • Optionalopts: {
          waitForSync?: boolean;
      } = {}

      For internal use in tests, set opts.waitForSync = false to not wait for sync during addProject()

      • OptionalwaitForSync?: boolean

    Returns Promise<string>

  • Parameters

    • peer: {
          address: string;
          name: string;
          port: number;
      }
      • address: string
      • name: string
      • port: number

    Returns void

  • Create a new project.

    Parameters

    • Optionaloptions: {
          configPath?: string;
      } = {}
      • OptionalconfigPath?: string

    Returns Promise<string>

    Project public id

  • Returns Promise<string>

  • Parameters

    • projectPublicId: string

    Returns Promise<void>

  • Returns Promise<(Pick<{}, "name"> & {
        createdAt?: string;
        projectId: string;
        updatedAt?: string;
    })[]>

  • Call this when the app goes into the background.

    Will gracefully shut down sync.

    Returns void

  • Call this when the app goes into the foreground.

    Will undo the effects of onBackgrounded.

    Returns void

  • Type Parameters

    • T extends DeviceInfoParam & {
          deviceType?:
              | "UNRECOGNIZED"
              | "device_type_unspecified"
              | "mobile"
              | "tablet"
              | "desktop";
      } | ExactObject<DeviceInfoParam & {
          deviceType?:
              | "UNRECOGNIZED"
              | "device_type_unspecified"
              | "mobile"
              | "tablet"
              | "desktop";
      }, T>

    Parameters

    • deviceInfo: T

    Returns Promise<void>

  • Returns Promise<{
        name: string;
        port: number;
    }>

  • Close all servers and stop multicast advertising and browsing. Will wait for open sockets to close unless opts.force=true in which case open sockets are force-closed after opts.timeout milliseconds

    Parameters

    • Optionalopts: {
          force: undefined | boolean;
          timeout: undefined | number;
      }
      • force: undefined | boolean

        Force-close open sockets after timeout milliseconds

      • timeout: undefined | number

        Optional timeout when calling stop() with force=true

    Returns Promise<void>