Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: integrate di needle - WPB-15593 #2447

Open
wants to merge 12 commits into
base: refactor/nse-pull-pending-events
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public protocol AuthenticationManagerProtocol {

}

actor AuthenticationManager: AuthenticationManagerProtocol {
public actor AuthenticationManager: AuthenticationManagerProtocol {

enum Failure: Error, Equatable {

Expand All @@ -47,7 +47,7 @@ actor AuthenticationManager: AuthenticationManagerProtocol {
private let cookieStorage: any CookieStorageProtocol
private let networkService: NetworkService

init(
public init(
clientID: String,
cookieStorage: any CookieStorageProtocol,
networkService: NetworkService
Expand All @@ -64,7 +64,7 @@ actor AuthenticationManager: AuthenticationManagerProtocol {
///
/// - Returns: A valid (non-expired) access token.

func getValidAccessToken() async throws -> AccessToken {
public func getValidAccessToken() async throws -> AccessToken {
switch currentToken {
case let .renewing(task):
// A new token will come soon, wait
Expand All @@ -89,7 +89,7 @@ actor AuthenticationManager: AuthenticationManagerProtocol {
///
/// - Returns: A new access token.

func refreshAccessToken() async throws -> AccessToken {
public func refreshAccessToken() async throws -> AccessToken {
if case let .renewing(task) = currentToken {
// A new token will come soon, wait
return try await task.value
Expand Down
10 changes: 5 additions & 5 deletions WireAPI/Sources/WireAPI/Authentication/CookieStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ import WireCrypto
import WireFoundation

// sourcery: AutoMockable
protocol CookieStorageProtocol: Sendable {
public protocol CookieStorageProtocol: Sendable {

func storeCookies(_ cookies: [HTTPCookie]) async throws
func fetchCookies() async throws -> [HTTPCookie]

}

actor CookieStorage: CookieStorageProtocol {
public actor CookieStorage: CookieStorageProtocol {

enum Failure: Error {

Expand Down Expand Up @@ -68,7 +68,7 @@ actor CookieStorage: CookieStorageProtocol {
return result
}

init(
public init(
userID: UUID,
cookieEncryptionKey: Data,
keychain: any KeychainProtocol
Expand All @@ -86,7 +86,7 @@ actor CookieStorage: CookieStorageProtocol {
///
/// - Parameter cookies: The cookies to store.

func storeCookies(_ cookies: [HTTPCookie]) async throws {
public func storeCookies(_ cookies: [HTTPCookie]) async throws {
let cookieData = try HTTPCookieCodec.encodeCookies(cookies)
try await storeCookieData(cookieData)
}
Expand All @@ -99,7 +99,7 @@ actor CookieStorage: CookieStorageProtocol {
///
/// - Returns: The stored cookies.

func fetchCookies() async throws -> [HTTPCookie] {
public func fetchCookies() async throws -> [HTTPCookie] {
guard let cookieData = try await fetchCookieData() else {
return []
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ public struct BackendEnvironment {

/// The `URL` of the backend.

let url: URL
public let url: URL

/// The `URL` of the WebSocket endpoint.

let webSocketURL: URL

/// The pinned keys for the backend for use with certificate pinning.

let pinnedKeys: [PinnedKey]
public let pinnedKeys: [PinnedKey]

/// The proxy settings for the backend if any.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import Foundation
@preconcurrency import Security

struct ServerTrustValidator: Sendable {
public struct ServerTrustValidator: Sendable {

enum Failure: Error, Equatable {
case evaluatingServerTrustFailed
Expand All @@ -29,7 +29,7 @@ struct ServerTrustValidator: Sendable {

private let pinnedKeys: [PinnedKey]

init(pinnedKeys: [PinnedKey]) {
public init(pinnedKeys: [PinnedKey]) {
self.pinnedKeys = pinnedKeys
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public final class NetworkService: NSObject {
private var urlSession: URLSession?
private var webSocketsByTask = [URLSessionWebSocketTask: WebSocket]()

init(baseURL: URL, serverTrustValidator: ServerTrustValidator) {
public init(baseURL: URL, serverTrustValidator: ServerTrustValidator) {
self.baseURL = baseURL
self.serverTrustValidator = serverTrustValidator
}
Expand All @@ -34,7 +34,7 @@ public final class NetworkService: NSObject {
urlSession?.invalidateAndCancel()
}

func configure(with urlSession: URLSession) {
public func configure(with urlSession: URLSession) {
self.urlSession = urlSession
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,20 @@

import Foundation

struct URLSessionConfigurationFactory {
public struct URLSessionConfigurationFactory {

let minTLSVersion: TLSVersion
let proxySettings: ProxySettings?

func makeRESTAPISessionConfiguration() -> URLSessionConfiguration {
public init(
minTLSVersion: TLSVersion,
proxySettings: ProxySettings?
) {
self.minTLSVersion = minTLSVersion
self.proxySettings = proxySettings
}

public func makeRESTAPISessionConfiguration() -> URLSessionConfiguration {
let configuration = URLSessionConfiguration.ephemeral

// If no data is transmitted for this amount of time for a request, it will time out.
Expand Down
53 changes: 53 additions & 0 deletions WireDomain/Project/WireDomain Project.xcodeproj/project.pbxproj
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: is Needle part of WireDomain? I would expect it to be part of an NSE target.

Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
59EA774F2D00CE0C002CA0B8 /* WireLogging in Frameworks */ = {isa = PBXBuildFile; productRef = 59EA774E2D00CE0C002CA0B8 /* WireLogging */; };
766BE3C52D036D5000148CB6 /* WireDomainAPI in Frameworks */ = {isa = PBXBuildFile; productRef = 766BE3C42D036D5000148CB6 /* WireDomainAPI */; };
C97BCCAA2C98704B004F2D0D /* WireDomain.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 01D0DCA62C1C8C870076CB1C /* WireDomain.framework */; };
C9A6CCAD2D3E53D70058D4A4 /* NeedleFoundation in Frameworks */ = {isa = PBXBuildFile; productRef = C9A6CCAC2D3E53D70058D4A4 /* NeedleFoundation */; };
C9A6CCAF2D3E53D70058D4A4 /* NeedleFoundationTest in Frameworks */ = {isa = PBXBuildFile; productRef = C9A6CCAE2D3E53D70058D4A4 /* NeedleFoundationTest */; };
C9B4C1F72D4915F10072A0EE /* WireCrypto in Frameworks */ = {isa = PBXBuildFile; productRef = C9B4C1F62D4915F10072A0EE /* WireCrypto */; };
C9E0C9BB2C91B76F00CE6607 /* WireTestingPackage in Frameworks */ = {isa = PBXBuildFile; productRef = C9E0C9BA2C91B76F00CE6607 /* WireTestingPackage */; };
CB7979132C738508006FBA58 /* WireTransportSupport.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CB7979122C738508006FBA58 /* WireTransportSupport.framework */; };
/* End PBXBuildFile section */
Expand Down Expand Up @@ -88,8 +91,11 @@
598D042D2C89C63100B64D71 /* WireFoundation in Frameworks */,
591B6E452C8B09BA009F8A7B /* WireDataModel.framework in Frameworks */,
594904952D0710BF00238104 /* WireAnalytics in Frameworks */,
C9A6CCAD2D3E53D70058D4A4 /* NeedleFoundation in Frameworks */,
59EA774F2D00CE0C002CA0B8 /* WireLogging in Frameworks */,
C9B4C1F72D4915F10072A0EE /* WireCrypto in Frameworks */,
59909A5E2C5BBEA8009C41DE /* WireAPI in Frameworks */,
C9A6CCAF2D3E53D70058D4A4 /* NeedleFoundationTest in Frameworks */,
01D0DCC62C1C8CD90076CB1C /* WireTransport.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -194,6 +200,7 @@
01D0DCA22C1C8C870076CB1C /* Sources */,
01D0DCA32C1C8C870076CB1C /* Frameworks */,
01D0DCA42C1C8C870076CB1C /* Resources */,
C9A6CCA92D3E4BED0058D4A4 /* ShellScript */,
);
buildRules = (
);
Expand All @@ -209,6 +216,9 @@
59EA774E2D00CE0C002CA0B8 /* WireLogging */,
766BE3C42D036D5000148CB6 /* WireDomainAPI */,
594904942D0710BF00238104 /* WireAnalytics */,
C9A6CCAC2D3E53D70058D4A4 /* NeedleFoundation */,
C9A6CCAE2D3E53D70058D4A4 /* NeedleFoundationTest */,
C9B4C1F62D4915F10072A0EE /* WireCrypto */,
);
productName = WireDomain;
productReference = 01D0DCA62C1C8C870076CB1C /* WireDomain.framework */;
Expand Down Expand Up @@ -271,6 +281,7 @@
);
mainGroup = 01D0DC9C2C1C8C870076CB1C;
packageReferences = (
C9A6CCAB2D3E53D70058D4A4 /* XCRemoteSwiftPackageReference "needle" */,
);
productRefGroup = 01D0DCA72C1C8C870076CB1C /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -327,6 +338,23 @@
shellPath = /bin/sh;
shellScript = "../../scripts/run-sourcery.sh --config ../Sources/WireDomainSupport/Sourcery/config.yml\n";
};
C9A6CCA92D3E4BED0058D4A4 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "export SOURCEKIT_LOGGING=0 && /opt/homebrew/bin/needle generate ../Sources/NeedleGenerated.swift ../Sources/\n";
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
Expand Down Expand Up @@ -724,6 +752,17 @@
};
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
C9A6CCAB2D3E53D70058D4A4 /* XCRemoteSwiftPackageReference "needle" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/uber/needle";
requirement = {
branch = master;
kind = branch;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
594904942D0710BF00238104 /* WireAnalytics */ = {
isa = XCSwiftPackageProductDependency;
Expand Down Expand Up @@ -753,6 +792,20 @@
isa = XCSwiftPackageProductDependency;
productName = WireDomainAPI;
};
C9A6CCAC2D3E53D70058D4A4 /* NeedleFoundation */ = {
isa = XCSwiftPackageProductDependency;
package = C9A6CCAB2D3E53D70058D4A4 /* XCRemoteSwiftPackageReference "needle" */;
productName = NeedleFoundation;
};
C9A6CCAE2D3E53D70058D4A4 /* NeedleFoundationTest */ = {
isa = XCSwiftPackageProductDependency;
package = C9A6CCAB2D3E53D70058D4A4 /* XCRemoteSwiftPackageReference "needle" */;
productName = NeedleFoundationTest;
};
C9B4C1F62D4915F10072A0EE /* WireCrypto */ = {
isa = XCSwiftPackageProductDependency;
productName = WireCrypto;
};
C9E0C9BA2C91B76F00CE6607 /* WireTestingPackage */ = {
isa = XCSwiftPackageProductDependency;
productName = WireTestingPackage;
Expand Down
Loading
Loading