Skip to content

Commit

Permalink
feat(domain): add DID standard model
Browse files Browse the repository at this point in the history
  • Loading branch information
goncalo-frade-iohk committed Sep 12, 2022
1 parent cd0b96d commit 9329431
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions Domain/Sources/Models/DID.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import Foundation

public typealias DIDMethod = String
public typealias DIDMethodId = String

/// Represents a DID with ``DIDMethod`` and ``DIDMethodId``
/// As specified in `https://www.w3.org/TR/did-core/#dfn-did-schemes`
public struct DID {
public let schema: String
public let method: DIDMethod
public let methodId: DIDMethodId

/// Initializes a standard DID
/// - Parameters:
/// - schema: By default it will be `did` as standard.
/// - method: DIDMethod specification
/// - methodId: DIDMethodId
public init(
schema: String = "did",
method: DIDMethod,
methodId: DIDMethodId
) {
self.schema = schema
self.method = method
self.methodId = methodId
}

public var string: String { "\(schema):\(method):\(methodId)" }
}

0 comments on commit 9329431

Please sign in to comment.