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
Name | Type | Description |
---|---|---|
path | String | Path 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
Name | Type | Description |
---|---|---|
userPrivKey | String | Userβs Private Key in WIF format |
solutionID | String | Unique Solution Identifier defined at PrivMX Bridge |
bridgeUrl | String |
Type | Description |
---|---|
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
Name | Type | Description |
---|---|---|
solutionID | String | Unique Solution Identifier defined at PrivMX Bridge |
bridgeUrl | String |
Type | Description |
---|---|
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
Type | Description |
---|---|
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
Name | Type | Description |
---|---|---|
query | privmx.endpoint.core.PagingQuery | Object holding parameters of the query |
Type | Description |
---|---|
privmx.ContextList | Structure containing all Contexts user has access to. |