LogoLogo
  • Platform Overview
  • 🗺️Guides
    • Getting Started
    • Users
      • Integrate the User SDK
      • Registration
      • Authentication
      • SDK Releases
      • API Reference
    • Entitlements
      • Administrative API
        • Integrating the Administrative API
        • Entitlement Definitions
        • Managing Entitlements Sets
        • Managing Entitlements Sequences
        • Managing User Entitlements
        • API Schema
      • End-user API
        • Integrate the Entitlements SDK
        • Redeeming Entitlements
        • Retrieving Entitlements
        • SDK Releases
        • API Reference
    • Sudos
      • Integrate the Sudo Profiles SDK
      • Sudo Entitlements
      • Manage Sudos
      • SDK Releases
      • API Reference
    • Telephony
      • Integrate the Telephony SDK
      • Manage Phone Numbers
      • Text Messaging
      • Voice Calling
      • Telephony Simulator
      • SDK Releases
      • API Reference
    • Email
      • Integrate the Email SDK
      • Email Entitlements
      • Manage Email Addresses
      • Sending & Receiving Email
      • Manage Email Folders
      • Draft Email Messages
      • Manage Email Address Blocklists
      • Email Address Public Information
      • Pagination
      • Caching
      • Configuration Data
      • Email Notifications
      • SDK Releases
      • API Reference
    • Decentralized Identity
      • Edge Agent
        • Relay SDK
          • Integrate the Relay SDK
          • Relay Entitlements
          • Manage Relay Postboxes
          • Manage Relay Messages
          • Receiving Messages
          • SDK Releases
        • Edge Agent SDK
          • Integrate the Edge Agent SDK
          • Agent Management
          • Manage Wallets
          • Establishing Connections
          • Manage Connections
          • Messaging
          • Manage DIDs
          • Accepting New Credentials
          • Manage Credentials
          • Present Credentials for Verification
          • Utilize Alternative Cryptography Providers
          • SDK Releases
          • Standards and Protocols
      • Cloud Agent
        • Cloud Agent Admin API
          • Integrate the Cloud Agent Admin API
          • Aries Interop Profile (AIP)
            • Connection Exchanges
            • Credential Exchanges
            • Proof Exchanges
          • Connections
          • Basic Messages
          • Credentials
            • Anoncreds Credentials
              • Schemas
              • Credential Definitions
            • W3C Credentials
          • Audit Logs
          • API Schema
          • Error Codes
          • Standards and Protocols
    • Virtual Cards
      • Integrate the Virtual Cards SDK
      • Virtual Cards Entitlements
      • Virtual Cards Transaction Velocity Constraints
      • Key Management
      • Manage Funding Sources
      • Manage Virtual Cards
      • Manage Transactions
      • Configuration Data
      • Pagination
      • Caching
      • SDK Releases
      • API Reference
    • Virtual Cards Simulator
      • Integrate the Virtual Cards Simulator SDK
      • Simulate Authorizations
      • Simulate Debits
      • Simulate Refunds
      • Simulate Reversals
      • Merchants and Currencies
      • SDK Releases
      • API Reference
    • Virtual Private Network
      • Integrate the VPN SDK
      • VPN Entitlements
      • Manage Servers
      • Manage Connection
      • Observe VPN Related Events
      • SDK Releases
      • API Reference
      • Frequently Asked Questions
    • Secure ID Verification
      • Integrate the Secure ID Verification SDK
      • List Supported Countries
      • Verify an Identity
      • Check Secure ID Verification Status
      • Use the Secure ID Verification Simulator
      • SDK Releases
      • API Reference
    • Password Manager
      • Integrate the Password Manager SDK
      • Accessing the Password Manager
      • Managing Password Vaults
      • Managing Password Vault Items
      • Vault Import and Export
      • Password Utilities
      • Password Manager Entitlements
      • Password Vault Security
      • SDK Releases
      • API Reference
    • Ad/Tracker Blocker
      • Integrate the Ad/Tracker Blocker SDK
      • Manage Rulesets
      • Blocking Ads and Trackers
      • Manage Exceptions
      • SDK Releases
      • API Reference
    • Site Reputation
      • Integrate the Site Reputation SDK
      • Use the Site Reputation SDK
      • SDK Releases
      • API Reference
  • 💡Concepts
    • Sudo Digital Identities
  • 🧱Development
    • Versioning
  • 🏢Administration
    • Admin Console Roles
  • ❓Get Help
    • Request a Demo
    • Report an Issue
Powered by GitBook
On this page
  • Get a Connection by ID
  • Delete a Connection by ID
  • Updating the Metadata of a Connection
  • Listing Connections
  • Filtered Listing
  1. Guides
  2. Decentralized Identity
  3. Edge Agent
  4. Edge Agent SDK

Manage Connections

Manage peer connections that the agent has established

PreviousEstablishing ConnectionsNextMessaging

Last updated 6 months ago

Connections are the gateway to DIDComm interactions with peers, whether that be receiving a credential, sending a credential proof, or more. After a connection has been , the established connection will appear under the agent's ConnectionsModule where they are ready to be used and managed.

The functionality of the ConnectionsModule is accessed via the agent's fields: agent.connections. The functionality provided is described below.

Get a Connection by ID

Established connections are represented by Connection objects. To retrieve the current state of a specific Connection in the agent's wallet, the getById API can be used. If a connection cannot be found by the given identifier, then null is returned:

let id: String // ID of the connection to get ([Connection.connectionId])

do {
    let connection = try await agent.connections.getById(connectionId: id)
} catch {
    // handle error
}
val id: String // ID of the connection to get ([Connection.connectionId])

launch {
    try {
        val connection = agent.connections.getById(id)
    } catch (e: ConnectionsModule.GetException) {
        // Handle exception
    }
}

Delete a Connection by ID

Similarly, a Connection in the wallet can be easily deleted via the deleteById API:

let id: String // ID of the connection to delete ([Connection.connectionId])

do {
    try await agent.connections.deleteById(connectionId: id)
} catch {
    // handle error
}
val id: String // ID of the connection to delete ([Connection.connectionId])

launch {
    try {
        agent.connections.deleteById(id)
    } catch (e: ConnectionsModule.DeleteException) {
        // Handle exception
    }
}

Updating the Metadata of a Connection

Each Connection contains a list of RecordTag (Connection.tags) attached to it, where a RecordTag is simply a name-value pair stored with the record. By default, some tags are attached to a new Connection. These include:

  • tag-name: ~created_timestamp tag-value: The UNIX epoch seconds which this connection was established

The tags on a Connection can be replaced or updated by using the updateConnection API, and providing a new set to update. This will replace the current set of tags. An example follows:

let id: String // ID of the connection to update

// add a 'category' of 'work' to this connection, and a 'priority' of '1'
let update = ConnectionUpdate(tags: [
    RecordTag(name: "category", value: "work"),
    RecordTag(name: "~priority", value: "1")
])

do {
    try await agent.connections.updateConnection(connectionId: id, connectionUpdate: update)
} catch {
    // handle error
}
val id: String // ID of the connection to update ([Connection.connectionId])

// add a 'category' of 'work' to this connection, and a 'priority' of '1'
val update = ConnectionUpdate(
    tags = listOf(
         RecordTag("category", "work"),
         RecordTag("~priority", "1")   
    )
)

launch {
    try {
        agent.connections.updateConnection(id, update)
    } catch (e: ConnectionsModule.UpdateException) {
        // Handle exception
    }
}

Listing Connections

To list all connections in the agent's wallet, the listAll API can be used:

do {
    let conns = try await agent.connections.listAll(options: nil)
} catch {
    // handle error
}
launch {
    try {
        val conns: List<Connection> = agent.connections.listAll(null)
    } catch (e: ConnectionsModule.ListException) {
        // Handle exception
    }
}

Filtered Listing

More complicated Connection list queries can also be achieved by utilizing the ListConnectionsFilters.

// WQL Query, filter for 'category' == 'work'
let wqlQuery = "{ \"category\": \"work\" }"
let filters = ListConnectionsFilters(tagFilter: wqlQuery)
let options = ListConnectionsOptions(filters: filters)
do {
    let workConnections = try await agent.connections.listAll(options: options)
} catch {
    // handle error
}
// WQL Query, filter for priority < 2 (e.g. 'high' priority items)
let wqlQuery = "{ \"~priority\": { \"$lt\": \"2\" } }"
let filters = ListConnectionsFilters(tagFilter: wqlQuery)
let options = ListConnectionsOptions(filters: filters)

do {
    let highPriorityConnections = try await agent.connections.listAll(options: options)
} catch {
    // Handle error
}
// WQL Query, filter for 'category' == 'work'
val wqlQuery = """{ "category": "work" }"""
val filters = ListConnectionsFilters(tagFilter = wqlQuery)
val options = ListConnectionsOptions(filters)

launch {
    try {
        val workConnections = agent.connections.listAll(options)
    } catch (e: ConnectionsModule.ListException) {
        // Handle exception
    }
}
// WQL Query, filter for priority < 2 (e.g. 'high' priority items)
val wqlQuery = """{ "~priority": { "${"$"}lt": "2" } }"""
val filters = ListConnectionsFilters(tagFilter = wqlQuery)
val options = ListConnectionsOptions(filters)

launch {
    try {
        val highPriorityConnections = agent.connections.listAll(options)
    } catch (e: ConnectionsModule.ListException) {
        // Handle exception
    }
}

Connection objects contain metadata that can be controlled by SDK consumers, allowing custom information to be attached to each Connection . It also allows custom to be leveraged.

Like most data in the wallet, RecordTag will be stored encrypted. Unless, the tag name is prefixed with ~, then the tag value will be stored unencrypted. Storing a tag value as unencrypted will allow some additional listing queries to be performed ().

To filter by tags applied to the Connection (i.e. applied ), the tagFilter field of ListConnectionsFilters should be used. This field takes a String in compliance with a Query.

Continuing from the example in the :

🗺️
established with a peer
listing functionality
see below
Wallet Query Langauge (WQL)
via the update API
Update section