-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(domain): add DID standard model
- Loading branch information
1 parent
cd0b96d
commit 9329431
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)" } | ||
} |