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
  • Create DIDs
  • Get full DID Information by ID
  • Delete a DID
  • Updating the Storage Metadata of a DID
  • Listing DIDs
  • Filtered Listing
  1. Guides
  2. Decentralized Identity
  3. Edge Agent
  4. Edge Agent SDK

Manage DIDs

Manage the DIDs which are owned by the Edge Agent for usage in DI protocols

PreviousMessagingNextAccepting New Credentials

Last updated 2 months ago

Many DI protocols require the agent to provide the DID which they want to use for the interaction. Some Edge Agent interactions automatically handle this usage of DIDs in protocols. However in some protocols it is more suitable for the SDK consumer to be explicit about the DID/s they want to use. When this is the case, the SDK's DidsModule can be used to manage the DIDs owned by the agent.

The functionality of the DidsModule is accessed via the agent's fields: agent.dids.

Create DIDs

To create and store DIDs with the Edge Agent SDK, the createDid API can be used. This API takes a CreateDidOptions type, which has different data variants for the different DID methods supported. On success, this API returns a DidInformation data object with the details of the DID that was created.

For instance, to create a did:key DID:

let agent: SudoDIEdgeAgent

do {
    let createdDid = try await agent.dids.createDid(
        options: .didKey(keyType: .ed25519)
    )
} catch {
    // handle error
}
val agent: SudoDIEdgeAgent

try {
    val createdDid = agent.dids.createDid(
        options = CreateDidOptions.DidKey(
            keyType = DidKeyType.ED25519
        )
    )
} catch (e: DidsModule.CreateDidException) {
    // handle error
}

In the above example, the DID's cryptographic key will be generated using the agent's internal software-based key management. For hardware-based key management and other custom options, see .

See the Standards and Protocols section for a list of DID methods supported for creation by the Edge Agent SDK.

Get full DID Information by ID

To retrieve the current full DidInformation of a specific DID owned by the agent, the getById API can be used. If a DID cannot be found by the given identifier, then null is returned:

let agent: SudoDIEdgeAgent

do {
    let did = try await agent.dids.getById(did: "did:example:123")
} catch {
    // handle error
}
val agent: SudoDIEdgeAgent

try {
    val did = agent.dids.getById("did:example:123")
} catch (e: DidsModule.GetException) {
    // handle error
}

Delete a DID

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

let agent: SudoDIEdgeAgent

do {
    try await agent.dids.deleteById(did: "did:example:123")
} catch {
// handle error
}
val agent: SudoDIEdgeAgent

try {
    agent.dids.deleteById("did:example:123")
} catch (e: DidsModule.DeleteException) {
    // handle error
}

Updating the Storage Metadata of a DID

Each DidInformation contains a list of RecordTag (DidInformation.tags) attached to it, where a RecordTag is simply a name-value pair stored with the record.

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

let agent: SudoDIEdgeAgent

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

do {
    try await agent.dids.updateDid(
        did: "did:example:123",
        didUpdate: update
    )
} catch {
    // handle error
}
val agent: SudoDIEdgeAgent

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

try {
    agent.dids.updateDid("did:example:123", update)
} catch (e: DidsModule.UpdateException) {
    // handle error
}

Listing DIDs

To list all DIDs owned by the agent, the listAll API can be used:

let agent: SudoDIEdgeAgent

do {
    let dids: [DidInformation] = try await agent.dids.listAll(
        options: nil
    )
} catch {
    // handle error
}
val agent: SudoDIEdgeAgent

try {
    val dids: List<DidInformation> = agent.dids.listAll()
} catch (e: DidsModule.ListException) {
    // handle error
}

Filtered Listing

More complicated DidInformation list queries can also be achieved by utilizing the ListDidsFilters filter. These filters allow for filtering by DID Method, Key Types and record tags.

let agent: SudoDIEdgeAgent

// WQL Query, filter for 'category' == 'work'
let wqlQuery = "{ \"category\": \"work\" }"
let filters = ListDidsFilters(tagFilter: wqlQuery)
let options = ListDidsOptions(filters: filters)

do {
    let workDids = try await agent.dids.listAll(options: options)
} catch {
    // handle error
}
// WQL Query, filter for priority < 2 (e.g. 'high' priority items)
let wqlQuery = "{ \"~priority\": { \"$lt\": \"2\" } }"
let filters = ListDidsFilters(tagFilter: wqlQuery)
let options = ListDidsOptions(filters: filters)

do {
    let highPriorityDids = try await agent.dids.listAll(options: options)
} catch {
    // handle error
}
val agent: SudoDIEdgeAgent

// WQL Query, filter for 'category' == 'work'
val wqlQuery = """{ "category": "work" }"""
val filters = ListDidsFilters(tagFilter = wqlQuery)
val options = ListDidsOptions(filters)

try {
    val workDids = agent.dids.listAll(options)
} catch (e: DidsModule.ListException) {
    // Handle exception
}
// WQL Query, filter for priority < 2 (e.g. 'high' priority items)
val wqlQuery = """{ "~priority": { "${"$"}lt": "2" } }"""
val filters = ListDidsFilters(tagFilter = wqlQuery)
val options = ListDidsOptions(filters)

try {
    val highPriorityDids = agent.dids.listAll(options)
} catch (e: DidsModule.ListException) {
    // Handle exception
}

DidInformation objects contain storage metadata (local only) that can be controlled by SDK consumers, allowing custom information to be attached to each DidInformation . 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 DidInformation (i.e. applied ), the tagFilter field of ListDidsFilters should be used. This field takes a String in compliance with a Query.

Continuing from the example in the :

🗺️
listing functionality
see below
Wallet Query Language (WQL)
via the update API
Update section
Create a DID backed by a Custom Cryptography Provider