Skip to content

Commit

Permalink
Merge pull request #29 from niscy-eudiw/main
Browse files Browse the repository at this point in the history
Add displayName parameter to Document initialization and update KeyChainStorageService
  • Loading branch information
phisakel authored Dec 19, 2024
2 parents 7a21a35 + 4e3affa commit 4c5c7c6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion Sources/WalletStorage/Document.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import MdocDataModel18013

/// wallet document structure
public struct Document: Sendable {
public init(id: String = UUID().uuidString, docType: String?, docDataFormat: DocDataFormat, data: Data, secureAreaName: String?, createdAt: Date?, modifiedAt: Date? = nil, metadata: Data?, status: DocumentStatus) {
public init(id: String = UUID().uuidString, docType: String?, docDataFormat: DocDataFormat, data: Data, secureAreaName: String?, createdAt: Date?, modifiedAt: Date? = nil, metadata: Data?, displayName: String?, status: DocumentStatus) {
self.id = id
self.docType = docType
self.docDataFormat = docDataFormat
Expand All @@ -28,6 +28,7 @@ public struct Document: Sendable {
self.createdAt = createdAt ?? Date()
self.modifiedAt = modifiedAt
self.metadata = metadata
self.displayName = displayName
self.status = status
}

Expand All @@ -39,9 +40,12 @@ public struct Document: Sendable {
public let createdAt: Date
public let modifiedAt: Date?
public let metadata: Data?
public var displayName: String?
public let status: DocumentStatus
public var statusDescription: String? { status.rawValue }
public var isDeferred: Bool { status == .deferred }



public func getDataForTransfer() -> (doc: (String, Data), fmt: (String, String), sa: (String, String))? {
guard let sa = secureAreaName else { return nil }
Expand Down
2 changes: 1 addition & 1 deletion Sources/WalletStorage/KeyChainStorageService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,6 @@ public actor KeyChainStorageService: DataStorageService {
defer { let c = data.count; data.withUnsafeMutableBytes { memset_s($0.baseAddress, c, 0, c); return } }
let descrBase64 = dict[kSecAttrDescription as String] as? String
let md: Data? = if let descrBase64 { Data(base64Encoded: descrBase64) } else { nil }
return Document(id: dict[kSecAttrAccount as String] as! String, docType: dict[kSecAttrLabel as String] as? String, docDataFormat: DocDataFormat(rawValue: dict[kSecAttrType as String] as? String ?? DocDataFormat.cbor.rawValue) ?? DocDataFormat.cbor, data: data, secureAreaName: dict[kSecAttrComment as String] as? String, createdAt: (dict[kSecAttrCreationDate as String] as! Date), modifiedAt: dict[kSecAttrModificationDate as String] as? Date, metadata: md, status: status)
return Document(id: dict[kSecAttrAccount as String] as! String, docType: dict[kSecAttrLabel as String] as? String, docDataFormat: DocDataFormat(rawValue: dict[kSecAttrType as String] as? String ?? DocDataFormat.cbor.rawValue) ?? DocDataFormat.cbor, data: data, secureAreaName: dict[kSecAttrComment as String] as? String, createdAt: (dict[kSecAttrCreationDate as String] as! Date), modifiedAt: dict[kSecAttrModificationDate as String] as? Date, metadata: md, displayName: nil, status: status)
}
}

0 comments on commit 4c5c7c6

Please sign in to comment.