diff --git a/Sources/ATProtoKit/APIReference/ComAtprotoAPI/GetServiceAuthentication.swift b/Sources/ATProtoKit/APIReference/ComAtprotoAPI/GetServiceAuthentication.swift index cf9ae50e41..4e79dcca6f 100644 --- a/Sources/ATProtoKit/APIReference/ComAtprotoAPI/GetServiceAuthentication.swift +++ b/Sources/ATProtoKit/APIReference/ComAtprotoAPI/GetServiceAuthentication.swift @@ -18,12 +18,20 @@ extension ATProtoKit { /// /// [github]: https://github.com/bluesky-social/atproto/blob/main/lexicons/com/atproto/server/getServiceAuth.json /// - /// - Parameter serviceDID: The decentralized identifier (DID) of the service. + /// - Parameters: + /// - serviceDID: The decentralized identifier (DID) of the service. + /// - expirationTime: The exporation date of the session tokens expire. Optional. + /// Defaults to 60 seconds in the Unix Epoch format. + /// - lexiconMethod: The Namespaced Identifier (NSID) of the lexicon that the token is bound to. Optional. /// - Returns: The signed token from the service that matches `serviceDID`. /// /// - Throws: An ``ATProtoError``-conforming error type, depending on the issue. Go to /// ``ATAPIError`` and ``ATRequestPrepareError`` for more details. - public func getServiceAuthentication(from serviceDID: String) async throws -> ComAtprotoLexicon.Server.GetServiceAuthOutput { + public func getServiceAuthentication( + from serviceDID: String, + expirationTime: Int? = 60, + lexiconMethod: String? + ) async throws -> ComAtprotoLexicon.Server.GetServiceAuthOutput { guard session != nil, let accessToken = session?.accessToken else { throw ATRequestPrepareError.missingActiveSession @@ -34,10 +42,18 @@ extension ATProtoKit { throw ATRequestPrepareError.invalidRequestURL } - let queryItems = [ + var queryItems = [ ("aud", serviceDID) ] + if let expirationTime { + queryItems.append(("exp", "\(expirationTime)")) + } + + if let lexiconMethod { + queryItems.append(("lxm", lexiconMethod)) + } + let queryURL: URL do { diff --git a/Sources/ATProtoKit/Errors/ATProtoError.swift b/Sources/ATProtoKit/Errors/ATProtoError.swift index a0b617d6a8..ede9899eb3 100644 --- a/Sources/ATProtoKit/Errors/ATProtoError.swift +++ b/Sources/ATProtoKit/Errors/ATProtoError.swift @@ -106,7 +106,8 @@ public enum ATAPIError: ATProtoError, Decodable { "AuthFactorTokenRequired", "MemberAlreadyExists", "MemberNotFound", - "CannotDeleteSelf": + "CannotDeleteSelf", + "BadExpiration": self = .badRequest(message: message) case "Unauthorized": self = .unauthorized(message: message) diff --git a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedDefs.swift b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedDefs.swift index 6880572ec2..6c217fe5b1 100644 --- a/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedDefs.swift +++ b/Sources/ATProtoKit/Models/Lexicons/app.bsky/Feed/AppBskyFeedDefs.swift @@ -601,7 +601,7 @@ extension AppBskyLexicon.Feed { /// The feed generator's context. Optional. /// /// - Note: According to the AT Protocol specifications: "Context on a feed item that was - /// orginally supplied by the feed generator on getFeedSkeleton." + /// originally supplied by the feed generator on getFeedSkeleton." public let feedContext: String? public init(item: String, event: Event, feedContext: String) { diff --git a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Label/ComAtprotoLabelDefs.swift b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Label/ComAtprotoLabelDefs.swift index bb512aa2e6..779b0aaea0 100644 --- a/Sources/ATProtoKit/Models/Lexicons/com.atproto/Label/ComAtprotoLabelDefs.swift +++ b/Sources/ATProtoKit/Models/Lexicons/com.atproto/Label/ComAtprotoLabelDefs.swift @@ -210,7 +210,7 @@ extension ComAtprotoLexicon.Label { /// A definition model for labeler-created labels. /// /// - Note: According to the AT Protocol specifications: "Declares a label value and its expected - /// interpertations and behaviors." + /// interpretations and behaviors." /// /// - SeeAlso: This is based on the [`com.atproto.label.defs`][github] lexicon. ///