Skip to content

Commit fc43f1e

Browse files
authored
Internal import JWTKit (#824)
To wait for the corresponding ffi impl. (Non-breaking narrowing of the new token source feature)
1 parent 06a007f commit fc43f1e

File tree

2 files changed

+37
-36
lines changed

2 files changed

+37
-36
lines changed

Sources/LiveKit/Token/CachingTokenSource.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public extension TokenSourceResponse {
161161
/// Extracts the JWT payload from the participant token.
162162
///
163163
/// - Returns: The JWT payload if successfully parsed, nil otherwise
164-
func jwt() -> LiveKitJWTPayload? {
164+
internal func jwt() -> LiveKitJWTPayload? {
165165
LiveKitJWTPayload.fromUnverified(token: participantToken)
166166
}
167167
}

Sources/LiveKit/Token/JWT.swift

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -14,50 +14,51 @@
1414
* limitations under the License.
1515
*/
1616

17-
import JWTKit
17+
// To be swapped with ffi
18+
internal import JWTKit
1819

1920
/// JWT payload structure for LiveKit authentication tokens.
20-
public struct LiveKitJWTPayload: JWTPayload, Codable, Equatable {
21+
struct LiveKitJWTPayload: JWTPayload, Codable, Equatable {
2122
/// Video-specific permissions and room access grants for the participant.
22-
public struct VideoGrant: Codable, Equatable {
23+
struct VideoGrant: Codable, Equatable {
2324
/// Name of the room. Required for admin or join permissions.
24-
public let room: String?
25+
let room: String?
2526
/// Permission to create new rooms.
26-
public let roomCreate: Bool?
27+
let roomCreate: Bool?
2728
/// Permission to join a room as a participant. Requires `room` to be set.
28-
public let roomJoin: Bool?
29+
let roomJoin: Bool?
2930
/// Permission to list available rooms.
30-
public let roomList: Bool?
31+
let roomList: Bool?
3132
/// Permission to start recording sessions.
32-
public let roomRecord: Bool?
33+
let roomRecord: Bool?
3334
/// Permission to control a specific room. Requires `room` to be set.
34-
public let roomAdmin: Bool?
35+
let roomAdmin: Bool?
3536

3637
/// Allow participant to publish tracks. If neither `canPublish` or `canSubscribe` is set, both are enabled.
37-
public let canPublish: Bool?
38+
let canPublish: Bool?
3839
/// Allow participant to subscribe to other participants' tracks.
39-
public let canSubscribe: Bool?
40+
let canSubscribe: Bool?
4041
/// Allow participant to publish data messages. Defaults to `true` if not set.
41-
public let canPublishData: Bool?
42+
let canPublishData: Bool?
4243
/// Allowed track sources for publishing (e.g., "camera", "microphone", "screen_share").
43-
public let canPublishSources: [String]?
44+
let canPublishSources: [String]?
4445
/// Hide participant from other participants in the room.
45-
public let hidden: Bool?
46+
let hidden: Bool?
4647
/// Mark participant as a recorder. When set, allows room to indicate it's being recorded.
47-
public let recorder: Bool?
48+
let recorder: Bool?
4849

49-
public init(room: String? = nil,
50-
roomCreate: Bool? = nil,
51-
roomJoin: Bool? = nil,
52-
roomList: Bool? = nil,
53-
roomRecord: Bool? = nil,
54-
roomAdmin: Bool? = nil,
55-
canPublish: Bool? = nil,
56-
canSubscribe: Bool? = nil,
57-
canPublishData: Bool? = nil,
58-
canPublishSources: [String]? = nil,
59-
hidden: Bool? = nil,
60-
recorder: Bool? = nil)
50+
init(room: String? = nil,
51+
roomCreate: Bool? = nil,
52+
roomJoin: Bool? = nil,
53+
roomList: Bool? = nil,
54+
roomRecord: Bool? = nil,
55+
roomAdmin: Bool? = nil,
56+
canPublish: Bool? = nil,
57+
canSubscribe: Bool? = nil,
58+
canPublishData: Bool? = nil,
59+
canPublishSources: [String]? = nil,
60+
hidden: Bool? = nil,
61+
recorder: Bool? = nil)
6162
{
6263
self.room = room
6364
self.roomCreate = roomCreate
@@ -75,23 +76,23 @@ public struct LiveKitJWTPayload: JWTPayload, Codable, Equatable {
7576
}
7677

7778
/// JWT expiration time claim (when the token expires).
78-
public let exp: ExpirationClaim
79+
let exp: ExpirationClaim
7980
/// JWT issuer claim (who issued the token).
80-
public let iss: IssuerClaim
81+
let iss: IssuerClaim
8182
/// JWT not-before claim (when the token becomes valid).
82-
public let nbf: NotBeforeClaim
83+
let nbf: NotBeforeClaim
8384
/// JWT subject claim (the participant identity).
84-
public let sub: SubjectClaim
85+
let sub: SubjectClaim
8586

8687
/// Display name for the participant in the room.
87-
public let name: String?
88+
let name: String?
8889
/// Custom metadata associated with the participant.
89-
public let metadata: String?
90+
let metadata: String?
9091
/// Video-specific permissions and room access grants.
91-
public let video: VideoGrant?
92+
let video: VideoGrant?
9293

9394
/// Verifies the JWT token's validity by checking expiration and not-before claims.
94-
public func verify(using _: JWTSigner) throws {
95+
func verify(using _: JWTSigner) throws {
9596
try nbf.verifyNotBefore()
9697
try exp.verifyNotExpired()
9798
}

0 commit comments

Comments
 (0)