Skip to content

Commit 1c6af3f

Browse files
committed
Add apiKey Keychain
1 parent 6efa867 commit 1c6af3f

3 files changed

Lines changed: 6 additions & 2 deletions

File tree

Tool/Sources/Keychain/Keychain.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ public struct Keychain: KeychainType {
3535
let service = keychainService
3636
let accessGroup = keychainAccessGroup
3737
let scope: String
38+
39+
public static var apiKey: Keychain {
40+
Keychain(scope: "apiKey")
41+
}
3842

3943
public enum Error: Swift.Error {
4044
case failedToDeleteFromKeyChain

Tool/Sources/OpenAIService/Configuration/ChatGPTConfiguration.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public extension ChatGPTConfiguration {
1919
}
2020

2121
var apiKey: String {
22-
(try? Keychain(scope: "apikey").get(model.info.apiKeyName)) ?? ""
22+
(try? Keychain.apiKey.get(model.info.apiKeyName)) ?? ""
2323
}
2424

2525
func overriding(

Tool/Sources/OpenAIService/Configuration/EmbeddingConfiguration.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public extension EmbeddingConfiguration {
1616
}
1717

1818
var apiKey: String {
19-
(try? Keychain(scope: "apikey").get(model.info.apiKeyName)) ?? ""
19+
(try? Keychain.apiKey.get(model.info.apiKeyName)) ?? ""
2020
}
2121

2222
func overriding(

0 commit comments

Comments
 (0)