generated from StanfordBDHG/SwiftPackageTemplate
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d964013
commit 430fac2
Showing
5 changed files
with
93 additions
and
11 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
44 changes: 44 additions & 0 deletions
44
Sources/SpeziSecureStorage/Credentials/CredentialTypes.swift
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,44 @@ | ||
// | ||
// CredentialType.swift | ||
// SpeziStorage | ||
// | ||
// Created by Paul Kraft on 21.10.2024. | ||
// | ||
|
||
import CryptoKit | ||
import Foundation | ||
|
||
public struct CredentialTypes: OptionSet { | ||
/// Credentials that are created using a server name. | ||
/// | ||
/// Refers to any credentials that are stored with a server name using ``CredentialStorage``. | ||
public static let server = CredentialTypes(rawValue: 1 << 1) | ||
/// Credentials that are created without supplying a server name. | ||
/// | ||
/// Refers to any credentials that are stored without a server name using ``CredentialStorage``. | ||
public static let nonServer = CredentialTypes(rawValue: 1 << 2) | ||
|
||
/// Any credentials created with the `CredentialStorage` module. | ||
/// | ||
/// Refers to any credentials that are created using ``CredentialStorage``. | ||
public static let all: CredentialTypes = [.server, .nonServer] | ||
|
||
var kSecClasses: [CFString] { | ||
var kSecClasses: [CFString] = [] | ||
if self.contains(.server) { | ||
kSecClasses.append(kSecClassGenericPassword) | ||
} | ||
if self.contains(.nonServer) { | ||
kSecClasses.append(kSecClassInternetPassword) | ||
} | ||
return kSecClasses | ||
} | ||
|
||
public let rawValue: Int | ||
|
||
public init(rawValue: Int) { | ||
self.rawValue = rawValue | ||
} | ||
} | ||
|
||
extension CredentialTypes: Sendable {} |
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
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
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