Class MemberApi

Hierarchy

  • TypedEmitter
    • MemberApi

Constructors

  • Parameters

    • opts: {
          coreOwnership: CoreOwnership;
          dataTypes: {
              deviceInfo: Pick<DeviceInfoDataType, "getByDocId" | "getMany">;
              project: Pick<ProjectDataType, "getByDocId">;
          };
          deviceId: string;
          encryptionKeys: EncryptionKeys;
          getProjectName: (() => Promisable<undefined | string>);
          getReplicationStream: (() => ReplicationStream);
          projectKey: Buffer;
          roles: Roles;
          rpc: LocalPeers;
          waitForInitialSyncWithPeer: ((deviceId: string, abortSignal: AbortSignal) => Promise<void>);
      }
      • coreOwnership: CoreOwnership
      • dataTypes: {
            deviceInfo: Pick<DeviceInfoDataType, "getByDocId" | "getMany">;
            project: Pick<ProjectDataType, "getByDocId">;
        }
      • deviceId: string

        public key of this device as hex string

      • encryptionKeys: EncryptionKeys
      • getProjectName: (() => Promisable<undefined | string>)
          • (): Promisable<undefined | string>
          • Returns Promisable<undefined | string>

      • getReplicationStream: (() => ReplicationStream)
      • projectKey: Buffer
      • roles: Roles
      • rpc: LocalPeers
      • waitForInitialSyncWithPeer: ((deviceId: string, abortSignal: AbortSignal) => Promise<void>)
          • (deviceId, abortSignal): Promise<void>
          • Parameters

            • deviceId: string
            • abortSignal: AbortSignal

            Returns Promise<void>

    Returns MemberApi

Methods

  • Add a server peer.

    Can reject with any of the following error codes (accessed via err.code):

    • INVALID_URL: the base URL is invalid, likely due to user error.
    • MISSING_DATA: some required data is missing in order to add the server peer. For example, the project must have a name.
    • NETWORK_ERROR: there was an issue connecting to the server. Is the device online? Is the server online?
    • SERVER_HAS_TOO_MANY_PROJECTS: the server limits the number of projects it can have, and it's at the limit.
    • PROJECT_NOT_IN_SERVER_ALLOWLIST: the server only allows specific projects to be added and ours wasn't one of them.
    • INVALID_SERVER_RESPONSE: we connected to the server but it returned an unexpected response. Is the server running a compatible version of CoMapeo Cloud?

    If err.code is not specified, that indicates a bug in this module.

    Parameters

    • baseUrl: string
    • Optionaloptions: {
          dangerouslyAllowInsecureConnections: undefined | boolean;
      } = {}
      • dangerouslyAllowInsecureConnections: undefined | boolean

        Allow insecure network connections. Should only be used in tests.

    Returns Promise<void>

  • Parameters

    • deviceId: string
    • roleId: "f7c150f5a3a9a855" | "012fd2d431c0bf60" | "9e6d29263cba36c9"

    Returns Promise<void>

  • Send an invite. Resolves when receiving a response. Rejects if the invite is canceled, or if something else goes wrong.

    Parameters

    • deviceId: string
    • opts: {
          __testOnlyInviteId: undefined | Buffer;
          roleDescription: undefined | string;
          roleId: "f7c150f5a3a9a855" | "012fd2d431c0bf60" | "9e6d29263cba36c9";
          roleName: undefined | string;
      }
      • __testOnlyInviteId: undefined | Buffer

        Hard-code the invite ID. Only for tests.

      • roleDescription: undefined | string
      • roleId: "f7c150f5a3a9a855" | "012fd2d431c0bf60" | "9e6d29263cba36c9"
      • roleName: undefined | string

    Returns Promise<"REJECT" | "ACCEPT" | "ALREADY">

  • Attempt to cancel an outbound invite, if it exists.

    No-op if we weren't inviting this device.

    Parameters

    • deviceId: string

    Returns void