···11+//
22+// APActor.swift
33+// CoreATProtocol
44+//
55+// Created by Thomas Rademaker on 10/8/25.
66+//
77+88+@globalActor public actor APActor {
99+ public static let shared = APActor()
1010+}
+26
Sources/CoreATProtocol/APEnvironment.swift
···11+//
22+// APEnvironment.swift
33+// CoreATProtocol
44+//
55+// Created by Thomas Rademaker on 10/10/25.
66+//
77+88+@APActor
99+public class APEnvironment {
1010+ public static var current: APEnvironment = APEnvironment()
1111+1212+ public var host: String?
1313+ public var accessToken: String?
1414+ public var refreshToken: String?
1515+ public var atProtocoldelegate: CoreATProtocolDelegate?
1616+ public let routerDelegate = APRouterDelegate()
1717+1818+ private init() {}
1919+2020+// func setup(apiKey: String, apiSecret: String, userAgent: String) {
2121+// self.apiKey = apiKey
2222+// self.apiSecret = apiSecret
2323+// self.userAgent = userAgent
2424+// }
2525+}
2626+
···11+import Foundation
22+33+extension CharacterSet {
44+ /// Creates a CharacterSet from RFC 3986 allowed characters.
55+ ///
66+ /// RFC 3986 states that the following characters are "reserved" characters.
77+ ///
88+ /// - General Delimiters: ":", "#", "[", "]", "@", "?", "/"
99+ /// - Sub-Delimiters: "!", "$", "&", "'", "(", ")", "*", "+", ",", ";", "="
1010+ ///
1111+ /// In RFC 3986 - Section 3.4, it states that the "?" and "/" characters should not be escaped to allow
1212+ /// query strings to include a URL. Therefore, all "reserved" characters with the exception of "?" and "/"
1313+ /// should be percent-escaped in the query string.
1414+ static let apURLQueryAllowed: CharacterSet = {
1515+ let generalDelimitersToEncode = ":#[]@" // does not include "?" or "/" due to RFC 3986 - Section 3.4
1616+ let subDelimitersToEncode = "!$&'()*+,;="
1717+ let encodableDelimiters = CharacterSet(charactersIn: "\(generalDelimitersToEncode)\(subDelimitersToEncode)")
1818+1919+ return CharacterSet.urlQueryAllowed.subtracting(encodableDelimiters)
2020+ }()
2121+}
···11+import Foundation
22+33+public protocol EndpointType: Sendable {
44+ var baseURL: URL { get async }
55+ var path: String { get }
66+ var httpMethod: HTTPMethod { get }
77+ var task: HTTPTask { get async }
88+ var headers: HTTPHeaders? { get async }
99+}
···11+public enum HTTPMethod : String {
22+ case get = "GET"
33+ case post = "POST"
44+ case put = "PUT"
55+ case patch = "PATCH"
66+ case delete = "DELETE"
77+}