File tree Expand file tree Collapse file tree 3 files changed +20
-3
lines changed Expand file tree Collapse file tree 3 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -15,4 +15,7 @@ public enum WooConstants {
1515
1616 /// Slug of the free trial WooExpress plan
1717 public static let freeTrialPlanSlug = " ecommerce-trial-bundle-monthly "
18+
19+ /// Keychain Access's Key for merchant AI provider API key
20+ public static let merchantAIProviderKey = " merchantAIProviderKey "
1821}
Original file line number Diff line number Diff line change 1+ import KeychainAccess
2+ import NetworkingCore
3+
4+ extension Keychain {
5+ /// AI key provided by the merchant
6+ ///
7+ var merchantAIProviderKey : String ? {
8+ get { self [ WooConstants . merchantAIProviderKey] }
9+ set { self [ WooConstants . merchantAIProviderKey] = newValue }
10+ }
11+ }
Original file line number Diff line number Diff line change 11import Foundation
2+ import KeychainAccess
23import Networking
4+ import NetworkingCore
35import Storage
46
57// MARK: - ProductStore
@@ -604,8 +606,8 @@ private extension ProductStore {
604606 completion ( result)
605607 case . merchant:
606608 let result = await Result {
607- // Temporary. This will come from the KeyChain rather than the environment
608- let key = ProcessInfo . processInfo . environment [ " openai-debug-api-key " ] ?? " api key not found "
609+ let keychain = Keychain ( service : WooConstants . keychainServiceName )
610+ let key = keychain . merchantAIProviderKey ?? " "
609611 return try await MerchantGenerativeContentRemote ( apiKey: key) . identifyLanguage ( siteID: siteID,
610612 string: string,
611613 feature: feature)
@@ -768,7 +770,8 @@ private extension ProductStore {
768770 completion ( result)
769771 case . merchant:
770772 let result = await Result {
771- let key = ProcessInfo . processInfo. environment [ " openai-debug-api-key " ] ?? " api key not found "
773+ let keychain = Keychain ( service: WooConstants . keychainServiceName)
774+ let key = keychain. merchantAIProviderKey ?? " "
772775 return try await MerchantGenerativeContentRemote ( apiKey: key) . generateAIProduct ( siteID: siteID,
773776 productName: productName,
774777 keywords: keywords,
You can’t perform that action at this time.
0 commit comments