this repo has no description
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

use upstream OAuthenticator

+28 -21
+4 -4
Package.resolved
··· 1 1 { 2 - "originHash" : "1d85a62ed3cf11cb30641c7b4268569eb131f9e444c996901e1a6d31971ec3f3", 2 + "originHash" : "0bfda6ffc0ea7c8dd4ce38c35f7b56610491f4cbad85d36c6e9430ad607a2ce2", 3 3 "pins" : [ 4 4 { 5 5 "identity" : "jwt-kit", ··· 22 22 { 23 23 "identity" : "oauthenticator", 24 24 "kind" : "remoteSourceControl", 25 - "location" : "https://github.com/radmakr/OAuthenticator.git", 25 + "location" : "https://github.com/ChimeHQ/OAuthenticator.git", 26 26 "state" : { 27 - "branch" : "CoreAtProtocol", 28 - "revision" : "fec7d4a7d83d6e75d8573468bc51c3e0f5e39323" 27 + "branch" : "main", 28 + "revision" : "0962bcc02e8e5c0fc49771c0d0eff3d33433863e" 29 29 } 30 30 }, 31 31 {
+1 -5
Package.swift
··· 19 19 ), 20 20 ], 21 21 dependencies: [ 22 - // Using fork with fix for WebAuthenticationSession platform guards 23 - // PR pending at https://github.com/ChimeHQ/OAuthenticator 24 - // .package(url: "https://github.com/ChimeHQ/OAuthenticator.git", branch: "main"), 25 - .package(url: "https://github.com/radmakr/OAuthenticator.git", branch: "CoreAtProtocol"), 26 - // .package(path: "../OAuthenticator"), 22 + .package(url: "https://github.com/ChimeHQ/OAuthenticator.git", branch: "main"), 27 23 .package(url: "https://github.com/vapor/jwt-kit.git", from: "5.0.0"), 28 24 .package(url: "https://github.com/SparrowTek/NetworkingKit.git", branch: "main"), 29 25 ],
+23 -12
Sources/CoreATProtocol/OAuth/ATProtoOAuth.swift
··· 420 420 try await self.dpopRequestActor.response( 421 421 request: request, 422 422 jwtGenerator: jwtGenerator, 423 - provider: provider, 424 - issuingServer: issuer 423 + responseProvider: provider, 424 + isAuthServer: true 425 425 ) 426 426 } 427 427 ··· 429 429 try await self.dpopRequestActor.response( 430 430 request: request, 431 431 jwtGenerator: jwtGenerator, 432 - provider: baseProvider, 433 - issuingServer: issuer 432 + responseProvider: baseProvider, 433 + isAuthServer: true 434 434 ) 435 435 } 436 436 ··· 609 609 } 610 610 611 611 switch authError { 612 - case .refreshNotPossible, .unauthorizedRefreshFailed, .dpopTokenExpected, .httpResponseExpected: 612 + case .refreshNotPossible, .unauthorizedRefreshFailed, 613 + .dpopTokenExpected, .httpResponseExpected, 614 + .invalidGrant: 613 615 return true 614 616 default: 615 617 return false ··· 734 736 throw AuthenticatorError.httpResponseExpected 735 737 } 736 738 guard (200..<300).contains(httpResponse.statusCode) else { 739 + if let oauthError = try? JSONDecoder().decode(OAuthErrorResponse.self, from: data) { 740 + throw ATProtoOAuthError.tokenRequestFailed("\(oauthError.error): \(oauthError.errorDescription ?? "")") 741 + } 737 742 throw ATProtoOAuthError.tokenRequestFailed(String(decoding: data, as: UTF8.self)) 738 743 } 739 744 ··· 783 788 request.httpBody = try JSONEncoder().encode(tokenRequest) 784 789 785 790 let (data, response) = try await responseProvider(request) 786 - guard let httpResponse = response as? HTTPURLResponse, 787 - (200..<300).contains(httpResponse.statusCode) else { 791 + guard let httpResponse = response as? HTTPURLResponse else { 792 + throw AuthenticatorError.httpResponseExpected 793 + } 794 + guard (200..<300).contains(httpResponse.statusCode) else { 795 + if let oauthError = try? JSONDecoder().decode(OAuthErrorResponse.self, from: data) { 796 + throw ATProtoOAuthError.tokenRequestFailed("\(oauthError.error): \(oauthError.errorDescription ?? "")") 797 + } 788 798 throw AuthenticatorError.refreshNotPossible 789 799 } 790 800 ··· 850 860 func response( 851 861 request: URLRequest, 852 862 jwtGenerator: DPoPSigner.JWTGenerator, 853 - provider: URLResponseProvider, 854 - issuingServer: String? 863 + responseProvider: URLResponseProvider, 864 + isAuthServer: Bool? 855 865 ) async throws -> (Data, URLResponse) { 856 - try await signer.response( 866 + let (data, httpResponse) = try await signer.response( 857 867 isolation: self, 858 868 for: request, 859 869 using: jwtGenerator, 860 870 token: nil, 861 871 tokenHash: nil, 862 - issuingServer: issuingServer, 863 - provider: provider 872 + isAuthServer: isAuthServer, 873 + responseProvider: responseProvider 864 874 ) 875 + return (data, httpResponse as URLResponse) 865 876 } 866 877 } 867 878