Skip to content

Commit 6d8a2ec

Browse files
authored
URLProtocol Removal (#128)
1 parent 2e1fc5b commit 6d8a2ec

File tree

15 files changed

+4
-393
lines changed

15 files changed

+4
-393
lines changed

Sources/OAuthKit/OAuth+Provider.swift

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ extension OAuth {
4040
public var customUserAgent: String?
4141
/// Enables provider debugging. Off by default.
4242
public var debug: Bool
43-
/// An optional regex that can be used in conjuction with the ``OAuth/URLProtocol`` class to intercept outbound requests
44-
/// and inject an `Authorization: Bearer <<token>>` header into a request.
45-
public var authorizationPattern: String?
4643

4744
/// The coding keys.
4845
enum CodingKeys: String, CodingKey {
@@ -58,7 +55,6 @@ extension OAuth {
5855
case encodeHttpBody
5956
case customUserAgent
6057
case debug
61-
case authorizationPattern
6258
}
6359

6460
/// Public initializer.
@@ -75,7 +71,6 @@ extension OAuth {
7571
/// - encodeHttpBody: If the provider should encode the access token parameters into the http body (true by default)
7672
/// - customUserAgent: The custom user agent to send with browser requests.
7773
/// - debug: Boolean to pass debugging into to the standard output (false by default)
78-
/// - authorizationPattern: a regex pattern used to automatically match outbound url requests that should have authorization headers added
7974
public init(id: String,
8075
icon: URL? = nil,
8176
authorizationURL: URL,
@@ -87,8 +82,7 @@ extension OAuth {
8782
scope: [String]? = nil,
8883
encodeHttpBody: Bool = true,
8984
customUserAgent: String? = nil,
90-
debug: Bool = false,
91-
authorizationPattern: String? = nil) {
85+
debug: Bool = false) {
9286
self.id = id
9387
self.icon = icon
9488
self.authorizationURL = authorizationURL
@@ -101,7 +95,6 @@ extension OAuth {
10195
self.encodeHttpBody = encodeHttpBody
10296
self.customUserAgent = customUserAgent
10397
self.debug = debug
104-
self.authorizationPattern = authorizationPattern
10598
}
10699

107100
/// Custom decoder initializer.
@@ -121,7 +114,6 @@ extension OAuth {
121114
encodeHttpBody = try container.decodeIfPresent(Bool.self, forKey: .encodeHttpBody) ?? true
122115
customUserAgent = try container.decodeIfPresent(String.self, forKey: .customUserAgent)
123116
debug = try container.decodeIfPresent(Bool.self, forKey: .debug) ?? false
124-
authorizationPattern = try container.decodeIfPresent(String.self, forKey: .authorizationPattern)
125117
}
126118
}
127119
}

Sources/OAuthKit/OAuth+URLProtocol.swift

Lines changed: 0 additions & 158 deletions
This file was deleted.

Sources/OAuthKit/OAuth.swift

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ public extension OAuth {
157157
func clear() {
158158
debugPrint("⚠️ [Clearing oauth state]")
159159
keychain.clear()
160-
URLProtocol.clear()
161160
state = .empty
162161
}
163162
}
@@ -278,7 +277,6 @@ private extension OAuth {
278277
func publish(state: State) {
279278
switch state {
280279
case .authorized(let provider, let auth):
281-
addAuthorization(provider: provider, authorization: auth)
282280
schedule(provider: provider, auth: auth)
283281
case .receivedDeviceCode(let provider, let deviceCode):
284282
schedule(provider: provider, deviceCode: deviceCode)
@@ -288,14 +286,6 @@ private extension OAuth {
288286
self.state = state
289287
}
290288

291-
/// Adds a received authorization to the ``OAuth/URLProtocol`` class.
292-
/// - Parameters:
293-
/// - provider: the provider
294-
/// - authorization: the authorization issued by the provider
295-
func addAuthorization(provider: Provider, authorization: Authorization) {
296-
URLProtocol.addAuthorization(authorization, for: provider)
297-
}
298-
299289
/// Schedules the provider to be polled for authorization with the specified device token.
300290
/// - Parameters:
301291
/// - provider: the oauth provider

Sources/OAuthKit/OAuthKit.docc/Extensions/OAuth.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,3 @@ let oauth: OAuth = .init(.module, options: options)
4848

4949
- ``state``
5050
- ``providers``
51-
52-
### OAuth Authorization Headers
53-
- ``OAuthKit/OAuth/URLProtocol``

Sources/OAuthKit/OAuthKit.docc/Extensions/URLProtocol.md

Lines changed: 0 additions & 20 deletions
This file was deleted.

Sources/OAuthKit/OAuthKit.docc/Resources/tutorial-code-files/url-protocol-step-1.swift

Lines changed: 0 additions & 4 deletions
This file was deleted.

Sources/OAuthKit/OAuthKit.docc/Resources/tutorial-code-files/url-protocol-step-2.swift

Lines changed: 0 additions & 14 deletions
This file was deleted.

Sources/OAuthKit/OAuthKit.docc/Resources/tutorial-code-files/url-protocol-step-3.swift

Lines changed: 0 additions & 13 deletions
This file was deleted.

Sources/OAuthKit/OAuthKit.docc/Resources/tutorial-code-files/url-protocol-step-4.swift

Lines changed: 0 additions & 7 deletions
This file was deleted.

Sources/OAuthKit/OAuthKit.docc/Tutorials/Contents.tutorial

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
@Tutorials(name: "Tutorials") {
99
@Intro(title: "OAuthKit Tutorials") {
10-
Learn how to start OAuth flows, observe state changes, and use authorization tokens in API requests using URLProtocols.
10+
Learn how to start OAuth flows and observe state changes.
1111

1212
@Image(source: tutorial-card.jpg, alt: "tutorial")
1313
}
@@ -19,12 +19,4 @@
1919
Learn the basics of how to create observable ``OAuth`` instances and start authorization flows.
2020
@TutorialReference(tutorial: "doc:FlowsStates")
2121
}
22-
23-
@Chapter(name: "URLProtocols with OAuthKit") {
24-
25-
@Image(source: blueprint-card.jpg, alt: "OAuthKit")
26-
27-
Leverage the ``OAuth/URLProtocol`` class to automatically have `Authorization` header values injected into matching outbound `URLRequest`.
28-
@TutorialReference(tutorial: "doc:URLProtocol")
29-
}
3022
}

0 commit comments

Comments
 (0)