diff --git a/Sources/ImperialAuth0/Auth0.swift b/Sources/ImperialAuth0/Auth0.swift index a09aba7..cc1b523 100644 --- a/Sources/ImperialAuth0/Auth0.swift +++ b/Sources/ImperialAuth0/Auth0.swift @@ -1,12 +1,12 @@ @_exported import ImperialCore import Vapor -final public class Auth0: FederatedService { +public struct Auth0: FederatedService { public let tokens: any FederatedServiceTokens public let router: any FederatedServiceRouter @discardableResult - public required init( + public init( routes: some RoutesBuilder, authenticate: String, authenticateCallback: (@Sendable (Request) async throws -> Void)?, diff --git a/Sources/ImperialAuth0/Auth0Router.swift b/Sources/ImperialAuth0/Auth0Router.swift index 78249cd..912b68b 100644 --- a/Sources/ImperialAuth0/Auth0Router.swift +++ b/Sources/ImperialAuth0/Auth0Router.swift @@ -1,7 +1,7 @@ import Foundation import Vapor -final public class Auth0Router: FederatedServiceRouter { +public struct Auth0Router: FederatedServiceRouter { public let baseURL: String public let tokens: any FederatedServiceTokens public let callbackCompletion: @Sendable (Request, String) async throws -> any AsyncResponseEncodable @@ -15,7 +15,7 @@ final public class Auth0Router: FederatedServiceRouter { return self.baseURL.finished(with: "/") + path } - public required init( + public init( callback: String, scope: [String], completion: @escaping @Sendable (Request, String) async throws -> some AsyncResponseEncodable ) throws { let auth = try Auth0Auth() diff --git a/Sources/ImperialCore/FederatedService.swift b/Sources/ImperialCore/FederatedService.swift index 23f7f60..b15ac75 100644 --- a/Sources/ImperialCore/FederatedService.swift +++ b/Sources/ImperialCore/FederatedService.swift @@ -8,12 +8,12 @@ import Vapor /// import ImperialCore /// import Vapor /// -/// public class Service: FederatedService { +/// public struct Service: FederatedService { /// public var tokens: any FederatedServiceTokens /// public var router: any FederatedServiceRouter /// /// @discardableResult -/// public required init( +/// public init( /// routes: some RoutesBuilder, /// authenticate: String, /// authenticateCallback: (@Sendable (Request) async throws -> Void)?, diff --git a/Sources/ImperialCore/FederatedServiceRouter.swift b/Sources/ImperialCore/FederatedServiceRouter.swift index 267159b..66695e4 100644 --- a/Sources/ImperialCore/FederatedServiceRouter.swift +++ b/Sources/ImperialCore/FederatedServiceRouter.swift @@ -4,7 +4,7 @@ import Vapor /// Defines a type that implements the routing to get an access token from an OAuth provider. /// See implementations in the `Services/(Google|GitHub)/$0Router.swift` files public protocol FederatedServiceRouter: Sendable { - /// A class that gets the client ID and secret from environment variables. + /// An object that gets the client ID and secret from environment variables. var tokens: any FederatedServiceTokens { get } /// The callback that is fired after the access token is fetched from the OAuth provider. diff --git a/Sources/ImperialDeviantArt/DeviantArt.swift b/Sources/ImperialDeviantArt/DeviantArt.swift index bb9ff7a..98d3eba 100644 --- a/Sources/ImperialDeviantArt/DeviantArt.swift +++ b/Sources/ImperialDeviantArt/DeviantArt.swift @@ -1,12 +1,12 @@ @_exported import ImperialCore import Vapor -final public class DeviantArt: FederatedService { +public struct DeviantArt: FederatedService { public let tokens: any FederatedServiceTokens public let router: any FederatedServiceRouter @discardableResult - public required init( + public init( routes: some RoutesBuilder, authenticate: String, authenticateCallback: (@Sendable (Request) async throws -> Void)?, diff --git a/Sources/ImperialDeviantArt/DeviantArtRouter.swift b/Sources/ImperialDeviantArt/DeviantArtRouter.swift index 5cb5f81..bd7037d 100644 --- a/Sources/ImperialDeviantArt/DeviantArtRouter.swift +++ b/Sources/ImperialDeviantArt/DeviantArtRouter.swift @@ -1,14 +1,14 @@ import Foundation import Vapor -final public class DeviantArtRouter: FederatedServiceRouter { +public struct DeviantArtRouter: FederatedServiceRouter { public let tokens: any FederatedServiceTokens public let callbackCompletion: @Sendable (Request, String) async throws -> any AsyncResponseEncodable public let scope: [String] public let callbackURL: String public let accessTokenURL: String = "https://www.deviantart.com/oauth2/token" - public required init( + public init( callback: String, scope: [String], completion: @escaping @Sendable (Request, String) async throws -> some AsyncResponseEncodable ) throws { self.tokens = try DeviantArtAuth() diff --git a/Sources/ImperialDiscord/Discord.swift b/Sources/ImperialDiscord/Discord.swift index 995a88c..53d0eef 100644 --- a/Sources/ImperialDiscord/Discord.swift +++ b/Sources/ImperialDiscord/Discord.swift @@ -1,12 +1,12 @@ @_exported import ImperialCore import Vapor -final public class Discord: FederatedService { +public struct Discord: FederatedService { public let tokens: any FederatedServiceTokens public let router: any FederatedServiceRouter @discardableResult - public required init( + public init( routes: some RoutesBuilder, authenticate: String, authenticateCallback: (@Sendable (Request) async throws -> Void)?, diff --git a/Sources/ImperialDiscord/DiscordRouter.swift b/Sources/ImperialDiscord/DiscordRouter.swift index 1d3a08c..fbe38a5 100644 --- a/Sources/ImperialDiscord/DiscordRouter.swift +++ b/Sources/ImperialDiscord/DiscordRouter.swift @@ -1,7 +1,7 @@ import Foundation import Vapor -final public class DiscordRouter: FederatedServiceRouter { +public struct DiscordRouter: FederatedServiceRouter { public let tokens: any FederatedServiceTokens public let callbackCompletion: @Sendable (Request, String) async throws -> any AsyncResponseEncodable public let scope: [String] @@ -9,7 +9,7 @@ final public class DiscordRouter: FederatedServiceRouter { public let accessTokenURL: String = "https://discord.com/api/oauth2/token" public let callbackHeaders = HTTPHeaders([("Content-Type", "application/x-www-form-urlencoded")]) - public required init( + public init( callback: String, scope: [String], completion: @escaping @Sendable (Request, String) async throws -> some AsyncResponseEncodable ) throws { self.tokens = try DiscordAuth() diff --git a/Sources/ImperialDropbox/Dropbox.swift b/Sources/ImperialDropbox/Dropbox.swift index ce1f531..e16110a 100644 --- a/Sources/ImperialDropbox/Dropbox.swift +++ b/Sources/ImperialDropbox/Dropbox.swift @@ -1,12 +1,12 @@ @_exported import ImperialCore import Vapor -final public class Dropbox: FederatedService { +public struct Dropbox: FederatedService { public let tokens: any FederatedServiceTokens public let router: any FederatedServiceRouter @discardableResult - public required init( + public init( routes: some RoutesBuilder, authenticate: String, authenticateCallback: (@Sendable (Request) async throws -> Void)?, diff --git a/Sources/ImperialDropbox/DropboxRouter.swift b/Sources/ImperialDropbox/DropboxRouter.swift index a39b900..d5ce2fb 100644 --- a/Sources/ImperialDropbox/DropboxRouter.swift +++ b/Sources/ImperialDropbox/DropboxRouter.swift @@ -1,7 +1,7 @@ import Foundation import Vapor -final public class DropboxRouter: FederatedServiceRouter { +public struct DropboxRouter: FederatedServiceRouter { public let tokens: any FederatedServiceTokens public let callbackCompletion: @Sendable (Request, String) async throws -> any AsyncResponseEncodable public let scope: [String] @@ -15,7 +15,7 @@ final public class DropboxRouter: FederatedServiceRouter { return headers } - public required init( + public init( callback: String, scope: [String], completion: @escaping @Sendable (Request, String) async throws -> some AsyncResponseEncodable ) throws { self.tokens = try DropboxAuth() diff --git a/Sources/ImperialFacebook/Facebook.swift b/Sources/ImperialFacebook/Facebook.swift index 18a9f69..055c31d 100644 --- a/Sources/ImperialFacebook/Facebook.swift +++ b/Sources/ImperialFacebook/Facebook.swift @@ -1,12 +1,12 @@ @_exported import ImperialCore import Vapor -final public class Facebook: FederatedService { +public struct Facebook: FederatedService { public let tokens: any FederatedServiceTokens public let router: any FederatedServiceRouter @discardableResult - public required init( + public init( routes: some RoutesBuilder, authenticate: String, authenticateCallback: (@Sendable (Request) async throws -> Void)?, diff --git a/Sources/ImperialFacebook/FacebookRouter.swift b/Sources/ImperialFacebook/FacebookRouter.swift index 61fdc60..dc3ded6 100644 --- a/Sources/ImperialFacebook/FacebookRouter.swift +++ b/Sources/ImperialFacebook/FacebookRouter.swift @@ -1,7 +1,7 @@ import Foundation import Vapor -final public class FacebookRouter: FederatedServiceRouter { +public struct FacebookRouter: FederatedServiceRouter { public let tokens: any FederatedServiceTokens public let callbackCompletion: @Sendable (Request, String) async throws -> any AsyncResponseEncodable public let scope: [String] @@ -27,7 +27,7 @@ final public class FacebookRouter: FederatedServiceRouter { return url.absoluteString } - public required init( + public init( callback: String, scope: [String], completion: @escaping @Sendable (Request, String) async throws -> some AsyncResponseEncodable ) throws { self.tokens = try FacebookAuth() diff --git a/Sources/ImperialGitHub/GitHub.swift b/Sources/ImperialGitHub/GitHub.swift index f086cb1..9aed636 100644 --- a/Sources/ImperialGitHub/GitHub.swift +++ b/Sources/ImperialGitHub/GitHub.swift @@ -1,12 +1,12 @@ @_exported import ImperialCore import Vapor -final public class GitHub: FederatedService { +public struct GitHub: FederatedService { public let tokens: any FederatedServiceTokens public let router: any FederatedServiceRouter @discardableResult - public required init( + public init( routes: some RoutesBuilder, authenticate: String, authenticateCallback: (@Sendable (Request) async throws -> Void)?, diff --git a/Sources/ImperialGitHub/GitHubRouter.swift b/Sources/ImperialGitHub/GitHubRouter.swift index f586676..78d2546 100644 --- a/Sources/ImperialGitHub/GitHubRouter.swift +++ b/Sources/ImperialGitHub/GitHubRouter.swift @@ -1,7 +1,7 @@ import Foundation import Vapor -final public class GitHubRouter: FederatedServiceRouter { +public struct GitHubRouter: FederatedServiceRouter { public let tokens: any FederatedServiceTokens public let callbackCompletion: @Sendable (Request, String) async throws -> any AsyncResponseEncodable public let scope: [String] @@ -13,7 +13,7 @@ final public class GitHubRouter: FederatedServiceRouter { return headers }() - public required init( + public init( callback: String, scope: [String], completion: @escaping @Sendable (Request, String) async throws -> some AsyncResponseEncodable ) throws { self.tokens = try GitHubAuth() @@ -23,7 +23,6 @@ final public class GitHubRouter: FederatedServiceRouter { } public func authURL(_ request: Request) throws -> String { - var components = URLComponents() components.scheme = "https" components.host = "github.com" @@ -44,7 +43,8 @@ final public class GitHubRouter: FederatedServiceRouter { GitHubCallbackBody( clientId: tokens.clientID, clientSecret: tokens.clientSecret, - code: code) + code: code + ) } } diff --git a/Sources/ImperialGitlab/Gitlab.swift b/Sources/ImperialGitlab/Gitlab.swift index ce926d3..b4578d2 100644 --- a/Sources/ImperialGitlab/Gitlab.swift +++ b/Sources/ImperialGitlab/Gitlab.swift @@ -1,12 +1,12 @@ @_exported import ImperialCore import Vapor -final public class Gitlab: FederatedService { +public struct Gitlab: FederatedService { public let tokens: any FederatedServiceTokens public let router: any FederatedServiceRouter @discardableResult - public required init( + public init( routes: some RoutesBuilder, authenticate: String, authenticateCallback: (@Sendable (Request) async throws -> Void)?, diff --git a/Sources/ImperialGitlab/GitlabRouter.swift b/Sources/ImperialGitlab/GitlabRouter.swift index 876af9f..1753236 100644 --- a/Sources/ImperialGitlab/GitlabRouter.swift +++ b/Sources/ImperialGitlab/GitlabRouter.swift @@ -1,14 +1,14 @@ import Foundation import Vapor -final public class GitlabRouter: FederatedServiceRouter { +public struct GitlabRouter: FederatedServiceRouter { public let tokens: any FederatedServiceTokens public let callbackCompletion: @Sendable (Request, String) async throws -> any AsyncResponseEncodable public let scope: [String] public let callbackURL: String public let accessTokenURL: String = "https://gitlab.com/oauth/token" - public required init( + public init( callback: String, scope: [String], completion: @escaping @Sendable (Request, String) async throws -> some AsyncResponseEncodable ) throws { self.tokens = try GitlabAuth() diff --git a/Sources/ImperialGoogle/JWT/GoogleJWTRouter.swift b/Sources/ImperialGoogle/JWT/GoogleJWTRouter.swift index 12bf68d..70ce59d 100644 --- a/Sources/ImperialGoogle/JWT/GoogleJWTRouter.swift +++ b/Sources/ImperialGoogle/JWT/GoogleJWTRouter.swift @@ -3,7 +3,7 @@ import Foundation import JWTKit import Vapor -public final class GoogleJWTRouter: FederatedServiceRouter { +public struct GoogleJWTRouter: FederatedServiceRouter { public let tokens: any FederatedServiceTokens public let callbackCompletion: @Sendable (Request, String) async throws -> any AsyncResponseEncodable public let scope: [String] diff --git a/Sources/ImperialGoogle/Standard/Google.swift b/Sources/ImperialGoogle/Standard/Google.swift index 6a65a78..ace2258 100644 --- a/Sources/ImperialGoogle/Standard/Google.swift +++ b/Sources/ImperialGoogle/Standard/Google.swift @@ -1,12 +1,12 @@ @_exported import ImperialCore import Vapor -final public class Google: FederatedService { +public struct Google: FederatedService { public let tokens: any FederatedServiceTokens public let router: any FederatedServiceRouter @discardableResult - public required init( + public init( routes: some RoutesBuilder, authenticate: String, authenticateCallback: (@Sendable (Request) async throws -> Void)?, diff --git a/Sources/ImperialGoogle/Standard/GoogleRouter.swift b/Sources/ImperialGoogle/Standard/GoogleRouter.swift index e880215..8543843 100644 --- a/Sources/ImperialGoogle/Standard/GoogleRouter.swift +++ b/Sources/ImperialGoogle/Standard/GoogleRouter.swift @@ -1,7 +1,7 @@ import Foundation import Vapor -final public class GoogleRouter: FederatedServiceRouter { +public struct GoogleRouter: FederatedServiceRouter { public let tokens: any FederatedServiceTokens public let callbackCompletion: @Sendable (Request, String) async throws -> any AsyncResponseEncodable public let scope: [String] @@ -13,7 +13,7 @@ final public class GoogleRouter: FederatedServiceRouter { return headers }() - public required init( + public init( callback: String, scope: [String], completion: @escaping @Sendable (Request, String) async throws -> some AsyncResponseEncodable ) throws { self.tokens = try GoogleAuth() diff --git a/Sources/ImperialImgur/Imgur.swift b/Sources/ImperialImgur/Imgur.swift index 8a9be0f..19fc3f3 100644 --- a/Sources/ImperialImgur/Imgur.swift +++ b/Sources/ImperialImgur/Imgur.swift @@ -1,12 +1,12 @@ @_exported import ImperialCore import Vapor -final public class Imgur: FederatedService { +public struct Imgur: FederatedService { public let tokens: any FederatedServiceTokens public let router: any FederatedServiceRouter @discardableResult - public required init( + public init( routes: some RoutesBuilder, authenticate: String, authenticateCallback: (@Sendable (Request) async throws -> Void)?, diff --git a/Sources/ImperialImgur/ImgurRouter.swift b/Sources/ImperialImgur/ImgurRouter.swift index c9b6cc7..0639dac 100644 --- a/Sources/ImperialImgur/ImgurRouter.swift +++ b/Sources/ImperialImgur/ImgurRouter.swift @@ -1,14 +1,14 @@ import Foundation import Vapor -final public class ImgurRouter: FederatedServiceRouter { +public struct ImgurRouter: FederatedServiceRouter { public let tokens: any FederatedServiceTokens public let callbackCompletion: @Sendable (Request, String) async throws -> any AsyncResponseEncodable public let scope: [String] public let callbackURL: String public let accessTokenURL: String = "https://api.imgur.com/oauth2/token" - public required init( + public init( callback: String, scope: [String], completion: @escaping @Sendable (Request, String) async throws -> some AsyncResponseEncodable diff --git a/Sources/ImperialKeycloak/Keycloak.swift b/Sources/ImperialKeycloak/Keycloak.swift index 679551c..fbcef0a 100644 --- a/Sources/ImperialKeycloak/Keycloak.swift +++ b/Sources/ImperialKeycloak/Keycloak.swift @@ -1,12 +1,12 @@ @_exported import ImperialCore import Vapor -final public class Keycloak: FederatedService { +public struct Keycloak: FederatedService { public let tokens: any FederatedServiceTokens public let router: any FederatedServiceRouter @discardableResult - public required init( + public init( routes: some RoutesBuilder, authenticate: String, authenticateCallback: (@Sendable (Request) async throws -> Void)?, diff --git a/Sources/ImperialKeycloak/KeycloakRouter.swift b/Sources/ImperialKeycloak/KeycloakRouter.swift index 1855936..7d2e534 100644 --- a/Sources/ImperialKeycloak/KeycloakRouter.swift +++ b/Sources/ImperialKeycloak/KeycloakRouter.swift @@ -1,7 +1,7 @@ import Foundation import Vapor -final public class KeycloakRouter: FederatedServiceRouter { +public struct KeycloakRouter: FederatedServiceRouter { public let tokens: any FederatedServiceTokens public let callbackCompletion: @Sendable (Request, String) async throws -> any AsyncResponseEncodable public let scope: [String] @@ -9,7 +9,7 @@ final public class KeycloakRouter: FederatedServiceRouter { public let accessTokenURL: String let authURL: String // This is an additional property of `tokens` that is not in the protocol - public required init( + public init( callback: String, scope: [String], completion: @escaping @Sendable (Request, String) async throws -> some AsyncResponseEncodable ) throws { self.tokens = try KeycloakAuth() diff --git a/Sources/ImperialMicrosoft/Microsoft.swift b/Sources/ImperialMicrosoft/Microsoft.swift index 90ddcae..85ea32d 100644 --- a/Sources/ImperialMicrosoft/Microsoft.swift +++ b/Sources/ImperialMicrosoft/Microsoft.swift @@ -1,12 +1,12 @@ @_exported import ImperialCore import Vapor -final public class Microsoft: FederatedService { +public struct Microsoft: FederatedService { public let tokens: any FederatedServiceTokens public let router: any FederatedServiceRouter @discardableResult - public required init( + public init( routes: some RoutesBuilder, authenticate: String, authenticateCallback: (@Sendable (Request) async throws -> Void)?, diff --git a/Sources/ImperialMicrosoft/MicrosoftRouter.swift b/Sources/ImperialMicrosoft/MicrosoftRouter.swift index 2812e34..76416a1 100644 --- a/Sources/ImperialMicrosoft/MicrosoftRouter.swift +++ b/Sources/ImperialMicrosoft/MicrosoftRouter.swift @@ -1,7 +1,7 @@ import Foundation import Vapor -final public class MicrosoftRouter: FederatedServiceRouter { +public struct MicrosoftRouter: FederatedServiceRouter { public static let tenantIDEnvKey: String = "MICROSOFT_TENANT_ID" public let tokens: any FederatedServiceTokens @@ -12,7 +12,7 @@ final public class MicrosoftRouter: FederatedServiceRouter { public var accessTokenURL: String { "https://login.microsoftonline.com/\(self.tenantID)/oauth2/v2.0/token" } public let errorKey = "error_description" - public required init( + public init( callback: String, scope: [String], completion: @escaping @Sendable (Request, String) async throws -> some AsyncResponseEncodable diff --git a/Sources/ImperialMixcloud/Mixcloud.swift b/Sources/ImperialMixcloud/Mixcloud.swift index 90f7b9c..21de24a 100644 --- a/Sources/ImperialMixcloud/Mixcloud.swift +++ b/Sources/ImperialMixcloud/Mixcloud.swift @@ -1,12 +1,12 @@ @_exported import ImperialCore import Vapor -final public class Mixcloud: FederatedService { +public struct Mixcloud: FederatedService { public let tokens: any FederatedServiceTokens public let router: any FederatedServiceRouter @discardableResult - public required init( + public init( routes: some RoutesBuilder, authenticate: String, authenticateCallback: (@Sendable (Request) async throws -> Void)?, diff --git a/Sources/ImperialMixcloud/MixcloudRouter.swift b/Sources/ImperialMixcloud/MixcloudRouter.swift index 0ec6df3..5391532 100644 --- a/Sources/ImperialMixcloud/MixcloudRouter.swift +++ b/Sources/ImperialMixcloud/MixcloudRouter.swift @@ -1,14 +1,14 @@ import Foundation import Vapor -final public class MixcloudRouter: FederatedServiceRouter { +public struct MixcloudRouter: FederatedServiceRouter { public let tokens: any FederatedServiceTokens public let callbackCompletion: @Sendable (Request, String) async throws -> any AsyncResponseEncodable public let scope: [String] public let callbackURL: String public let accessTokenURL: String = "https://www.mixcloud.com/oauth/access_token" - public required init( + public init( callback: String, scope: [String], completion: @escaping @Sendable (Request, String) async throws -> some AsyncResponseEncodable diff --git a/Sources/ImperialShopify/Shopify.swift b/Sources/ImperialShopify/Shopify.swift index b4ca40d..5466ba3 100644 --- a/Sources/ImperialShopify/Shopify.swift +++ b/Sources/ImperialShopify/Shopify.swift @@ -1,7 +1,7 @@ @_exported import ImperialCore import Vapor -public final class Shopify: FederatedService { +public struct Shopify: FederatedService { public let tokens: any FederatedServiceTokens public let router: any FederatedServiceRouter diff --git a/Sources/ImperialShopify/ShopifyRouter.swift b/Sources/ImperialShopify/ShopifyRouter.swift index 5d196dd..ce9a268 100644 --- a/Sources/ImperialShopify/ShopifyRouter.swift +++ b/Sources/ImperialShopify/ShopifyRouter.swift @@ -1,6 +1,6 @@ import Vapor -final public class ShopifyRouter: FederatedServiceRouter { +public struct ShopifyRouter: FederatedServiceRouter { public let tokens: any FederatedServiceTokens public let callbackCompletion: @Sendable (Request, String) async throws -> any AsyncResponseEncodable public let scope: [String] @@ -10,7 +10,7 @@ final public class ShopifyRouter: FederatedServiceRouter { // but the property is still required by the protocol, so it's set to an empty string public let accessTokenURL: String = "" - required public init( + public init( callback: String, scope: [String], completion: @escaping @Sendable (Request, String) async throws -> some AsyncResponseEncodable ) throws { self.tokens = try ShopifyAuth()