Skip to main content
reference

PrivMXConnection

The PrivMXConnection protocol declares methods for managing connections to PrivMX Bridge with Swift types. This protocol defines the required methods for setting up, managing, and disconnecting a connection to PrivMX platform. It provides functionality for setting up the path to SSL certificates, managing connection lifecycle (connect/disconnect), and retrieving important connection details such as the connection ID. Additionally, it offers methods for connecting with public or private access.

This protocol is implemented by classes that establish and manage connections to PrivMX system, providing a common interface for interacting with various aspects of PrivMX platform, including API access and connection management.

Static Methods​

setCertsPath(_:)​

Sets path to .pem file with certificates needed for establishing connection. This certificates depends on your Bridge setup.

static func setCertsPath(
_ path: String
) throws -> Void

NameTypeDescription
pathStringPath to the .pem file

connect(as:toπŸ”›)​

Connects with provided credentials to PrivMX Bridge.

static func connect(
as userPrivKey: String,
to solutionID: String,
on bridgeUrl: String
) throws -> any PrivMXConnection

NameTypeDescription
userPrivKeyStringUser’s Private Key in WIF format
solutionIDStringUnique Solution Identifier defined at PrivMX Bridge
bridgeUrlString

TypeDescription
any PrivMXConnection new Connection object which can be used for initializing proper PrivMX Endpoint APIs

connectPublic(toπŸ”›)​

Connects with public access to PrivMX Bridge. It is used mainly for public access to `InboxApi`.

static func connectPublic(
to solutionID: String,
on bridgeUrl: String
) throws -> any PrivMXConnection

NameTypeDescription
solutionIDStringUnique Solution Identifier defined at PrivMX Bridge
bridgeUrlString

TypeDescription
any PrivMXConnection new Connection object which can be used for initializing PrivMX `InboxApi`.

Methods​

disconnect()​

Disconnects current connection. Calling this function finished usage of PrivMXConnection object.

func disconnect(
) throws -> Void

getConnectionId()​

Returns current Connection ID.

func getConnectionId(
) throws -> Int64

TypeDescription
Int64 Current Connection ID. Used for managing and identifying connections.

listContexts(basedOn:)​

Lists Contexts to which the connected user has access.

func listContexts(
basedOn query: privmx.endpoint.core.PagingQuery
) throws -> privmx.ContextList

NameTypeDescription
queryprivmx.endpoint.core.PagingQueryObject holding parameters of the query

TypeDescription
privmx.ContextList Structure containing all Contexts user has access to.