diff --git a/Domain/Sources/Models/DID.swift b/Domain/Sources/Models/DID.swift new file mode 100644 index 00000000..e6850ece --- /dev/null +++ b/Domain/Sources/Models/DID.swift @@ -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)" } +}