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 Web
import Account import Account
import CoreResources import CoreResources
import Secrets
import OSLog import OSLog
import Core import Core
import CrashReporter import CrashReporter

View File

@ -13,7 +13,6 @@ import Account
import Core import Core
import AppKitExtras import AppKitExtras
import ArticleExtractor import ArticleExtractor
import Secrets
enum TimelineSourceMode { enum TimelineSourceMode {
case regular, search case regular, search
@ -1278,7 +1277,7 @@ private extension MainWindowController {
} }
func startArticleExtractorForCurrentLink() { 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.delegate = self
extractor.process() extractor.process()
articleExtractor = extractor articleExtractor = extractor

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -16,7 +16,6 @@ import Core
import ArticleExtractor import ArticleExtractor
import Images import Images
import Web import Web
import Secrets
protocol WebViewControllerDelegate: AnyObject { protocol WebViewControllerDelegate: AnyObject {
@ -697,7 +696,7 @@ private extension WebViewController {
func startArticleExtractor() { func startArticleExtractor() {
guard articleExtractor == nil else { return } 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.delegate = self
extractor.process() extractor.process()
articleExtractor = extractor articleExtractor = extractor