Connection
Swift wrapper for privmx.NativeConnectionWrapper
, used to establish and manage secure connections with PrivMX platform.
Static Methods
setCertsPath(_:)
Sets the path to the .pem file containing the necessary certificates for the connection, which are dependent on your PrivMX Bridge setup. This method must be called before attempting to establish a connection to ensure the certificates are properly set.
public static func setCertsPath(
_ path: std.string
) throws -> Void
Name | Type | Description |
---|---|---|
path | std.string | The path to the .pem file containing the certificates. |
connect(userPrivKey:solutionId:platformUrl:)
Creates a new connection instance to PrivMX platform using a private key. The path to the certificates must be set beforehand using `setCertsPath()`. This connection is used to interact with secured operations such as Inboxes, Threads, and Stores.
public static func connect(
userPrivKey: std.string,
solutionId: std.string,
platformUrl: std.string
) throws -> Connection
Name | Type | Description |
---|---|---|
userPrivKey | std.string | The user’s private key in WIF format, required for authentication. |
solutionId | std.string | The ID of the Solution that the connection targets. |
platformUrl | std.string | The URL of PrivMX platform endpoint. |
Type | Description |
---|---|
Connection | A `Connection` instance that can be used for further operations. |
connectPublic(solutionId:platformUrl:)
Creates a new public connection to PrivMX platform. The path to the certificates must be set beforehand using `setCertsPath()`. This type of connection is primarily used for public operations, such as inbound Inbox traffic, where authentication is not required.
public static func connectPublic(
solutionId: std.string,
platformUrl: std.string
) throws -> Connection
Name | Type | Description |
---|---|---|
solutionId | std.string | The ID of the Solution that the connection targets. |
platformUrl | std.string | The URL of PrivMX platform endpoint. |
Type | Description |
---|---|
Connection | A public `Connection` instance that can be used for non-authenticated operations. |
Methods
getConnectionId()
Retrieves the unique ID of the connection. Each connection instance has a unique identifier that can be used to track and manage multiple connections.
public func getConnectionId(
) throws -> Int64
Type | Description |
---|---|
Int64 | The unique ID of the current connection as an `Int64`. |
disconnect()
Disconnects the current connection to PrivMX platform. Once disconnected, the `Connection` instance, along with any associated API instances like `StoreApi` or `ThreadApi`, becomes unusable. It is important to call this method when the connection is no longer needed to free up resources.
public func disconnect(
) throws -> Void
listContexts(query:)
Lists all Contexts available to the currently connected user. Contexts represent different environments or groups to which the user has access. This method returns a list of these Contexts.
public func listContexts(
query: privmx.endpoint.core.PagingQuery
)throws -> privmx.ContextList
Name | Type | Description |
---|---|---|
query | privmx.endpoint.core.PagingQuery | A `PagingQuery` object that specifies the filtering and pagination options for the query. |
Type | Description |
---|---|
privmx.ContextList | A `ContextList` structure containing the total number of Contexts and a list of the retrieved Contexts. |