@@ -18,6 +18,8 @@ import Foundation
1818
1919#warning("Fix camel case after deploying backend")
2020
21+ // MARK: - Token
22+
2123/// `Token` represent the credentials needed for connecting to a new Room.
2224/// - SeeAlso: [LiveKit's Authentication Documentation](https://docs.livekit.io/home/get-started/authentication/) for more information.
2325public enum Token {
@@ -85,7 +87,7 @@ public enum Token {
8587 public typealias Literal = Response
8688}
8789
88- // MARK: - Provider
90+ // MARK: - Source
8991
9092/// Protocol for types that can provide connection credentials.
9193/// Implement this protocol to create custom credential providers (e.g., fetching from your backend API).
@@ -94,14 +96,13 @@ public protocol TokenSource: Sendable {
9496}
9597
9698/// `Token.Literal` contains a single set of credentials, hard-coded or acquired from a static source.
97- /// - Note: It does not support refreshing credentials.
9899extension Token . Literal : TokenSource {
99100 public func fetch( _: Token . Request ) async throws -> Token . Response {
100101 self
101102 }
102103}
103104
104- // MARK: - Token Server
105+ // MARK: - Endpoint
105106
106107/// Protocol for token servers that fetch credentials via HTTP requests.
107108/// Provides a default implementation of `fetch` that can be used to integrate with custom backend token generation endpoints.
@@ -142,24 +143,6 @@ public extension TokenEndpoint {
142143 }
143144}
144145
145- /// `Sandbox` queries LiveKit Sandbox token server for credentials,
146- /// which supports quick prototyping/getting started types of use cases.
147- /// - Warning: This token endpoint is **INSECURE** and should **NOT** be used in production.
148- public struct Sandbox : TokenEndpoint {
149- public let url = URL ( string: " https://cloud-api.livekit.io/api/sandbox/connection-details " ) !
150- public var headers : [ String : String ] {
151- [ " X-Sandbox-ID " : id]
152- }
153-
154- /// The sandbox ID provided by LiveKit Cloud.
155- public let id : String
156-
157- /// Initialize with a sandbox ID from LiveKit Cloud.
158- public init ( id: String ) {
159- self . id = id. trimmingCharacters ( in: CharacterSet ( charactersIn: " \" " ) )
160- }
161- }
162-
163146// MARK: - Cache
164147
165148/// `CachingTokenSource` handles caching of credentials from any other `TokenSource` using configurable store.
0 commit comments