Skip to content

Commit

Permalink
Update lexicon models and fix typos
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterJ93 committed Aug 8, 2024
1 parent a847330 commit bba9e5c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion Sources/ATProtoKit/Errors/ATProtoError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down

0 comments on commit bba9e5c

Please sign in to comment.