Make ArticleExtractor reference SecretKey instead of passing in secrets. Remove unused imports of Secrets.

This commit is contained in:
Brent Simmons 2024-07-07 15:48:56 -07:00
parent 445306ef2a
commit aa807249b9
10 changed files with 9 additions and 14 deletions

View File

@ -13,7 +13,6 @@ import Tree
import Web
import Account
import CoreResources
import Secrets
import OSLog
import Core
import CrashReporter

View File

@ -13,7 +13,6 @@ import Account
import Core
import AppKitExtras
import ArticleExtractor
import Secrets
enum TimelineSourceMode {
case regular, search
@ -1278,7 +1277,7 @@ private extension MainWindowController {
}
func startArticleExtractorForCurrentLink() {
if let link = currentLink, let extractor = ArticleExtractor(link, clientID: SecretKey.mercuryClientID, clientSecret: SecretKey.mercuryClientSecret) {
if let link = currentLink, let extractor = ArticleExtractor(link) {
extractor.delegate = self
extractor.process()
articleExtractor = extractor

View File

@ -11,7 +11,6 @@ import Web
import Articles
import ArticlesDatabase
import Database
import Secrets
@MainActor public final class AccountManager: UnreadCountProvider {

View File

@ -9,7 +9,6 @@
import XCTest
import Web
@testable import Account
import Secrets
//class AccountCredentialsTest: XCTestCase {
//

View File

@ -8,7 +8,6 @@
import XCTest
@testable import Account
import Secrets
//class FeedlyLogoutOperationTests: XCTestCase {
//

View File

@ -8,7 +8,6 @@
import XCTest
import Parser
import Secrets
@testable import Account
import os.log
import SyncDatabase

View File

@ -11,13 +11,15 @@ let package = Package(
targets: ["ArticleExtractor"]),
],
dependencies: [
.package(path: "../FoundationExtras")
.package(path: "../FoundationExtras"),
.package(path: "../Secrets")
],
targets: [
.target(
name: "ArticleExtractor",
dependencies: [
"FoundationExtras",
"Secrets"
],
swiftSettings: [
.enableExperimentalFeature("StrictConcurrency")

View File

@ -8,6 +8,7 @@
import Foundation
import FoundationExtras
import Secrets
public enum ArticleExtractorState: Sendable {
case ready
@ -33,12 +34,12 @@ public protocol ArticleExtractorDelegate {
private var dataTask: URLSessionDataTask? = nil
private let url: URL!
public init?(_ articleLink: String, clientID: String, clientSecret: String) {
public init?(_ articleLink: String) {
self.articleLink = articleLink
let clientURL = "https://extract.feedbin.com/parser"
let username = clientID
let signature = articleLink.hmacUsingSHA1(key: clientSecret)
let username = SecretKey.mercuryClientID
let signature = articleLink.hmacUsingSHA1(key: SecretKey.mercuryClientSecret)
if let base64URL = articleLink.data(using: .utf8)?.base64EncodedString() {
let fullURL = "\(clientURL)/\(username)/\(signature)?base64_url=\(base64URL)"

View File

@ -11,7 +11,6 @@ import Web
import Account
@preconcurrency import BackgroundTasks
import os.log
import Secrets
import WidgetKit
import Core
import Images

View File

@ -16,7 +16,6 @@ import Core
import ArticleExtractor
import Images
import Web
import Secrets
protocol WebViewControllerDelegate: AnyObject {
@ -697,7 +696,7 @@ private extension WebViewController {
func startArticleExtractor() {
guard articleExtractor == nil else { return }
if let link = article?.preferredLink, let extractor = ArticleExtractor(link, clientID: SecretKey.mercuryClientID, clientSecret: SecretKey.mercuryClientSecret) {
if let link = article?.preferredLink, let extractor = ArticleExtractor(link) {
extractor.delegate = self
extractor.process()
articleExtractor = extractor