| | | 1 | | using System; |
| | | 2 | | using System.Collections.Generic; |
| | | 3 | | |
| | | 4 | | namespace Livekit.Server.Sdk.Dotnet |
| | | 5 | | { |
| | | 6 | | /// <summary> |
| | | 7 | | /// Default values shared by the SDK. |
| | | 8 | | /// </summary> |
| | | 9 | | public static class Constants |
| | | 10 | | { |
| | | 11 | | /// <summary> |
| | | 12 | | /// Default lifetime of the tokens the SDK signs: 6 hours. |
| | | 13 | | /// </summary> |
| | 1 | 14 | | public static readonly TimeSpan DefaultTtl = TimeSpan.FromHours(6); |
| | | 15 | | |
| | | 16 | | /// <summary> |
| | | 17 | | /// Default clock tolerance when verifying a token: 1 minute. |
| | | 18 | | /// </summary> |
| | 1 | 19 | | public static readonly TimeSpan DefaultLeeway = TimeSpan.FromMinutes(1); |
| | | 20 | | } |
| | | 21 | | |
| | | 22 | | /// <summary> |
| | | 23 | | /// The <c>video</c> grant of an access token: what its holder may do in rooms. |
| | | 24 | | /// </summary> |
| | | 25 | | public class VideoGrants |
| | | 26 | | { |
| | | 27 | | /// <summary> |
| | | 28 | | /// Participant allowed to connect to LiveKit as Agent Framework worker. |
| | | 29 | | /// </summary> |
| | | 30 | | public bool Agent { get; set; } = false; |
| | | 31 | | |
| | | 32 | | /// <summary> |
| | | 33 | | /// Permission to publish tracks. Defaults to true. |
| | | 34 | | /// </summary> |
| | | 35 | | public bool CanPublish { get; set; } = true; |
| | | 36 | | |
| | | 37 | | /// <summary> |
| | | 38 | | /// Permission to publish data messages. Defaults to true. |
| | | 39 | | /// </summary> |
| | | 40 | | public bool CanPublishData { get; set; } = true; |
| | | 41 | | |
| | | 42 | | /// <summary> |
| | | 43 | | /// TrackSource types that the participant is allowed to publish. When set, it supersedes <c>CanPublish</c>. Onl |
| | | 44 | | /// </summary> |
| | | 45 | | public List<string> CanPublishSources { get; set; } = new List<string>(); |
| | | 46 | | |
| | | 47 | | /// <summary> |
| | | 48 | | /// Permission to subscribe to the tracks of other participants. Defaults to true. |
| | | 49 | | /// </summary> |
| | | 50 | | public bool CanSubscribe { get; set; } = true; |
| | | 51 | | |
| | | 52 | | /// <summary> |
| | | 53 | | /// Allow participant to subscribe to metrics. |
| | | 54 | | /// </summary> |
| | | 55 | | public bool CanSubscribeMetrics { get; set; } = false; |
| | | 56 | | |
| | | 57 | | /// <summary> |
| | | 58 | | /// Allow participant to manage an agent session via RemoteSession. |
| | | 59 | | /// </summary> |
| | | 60 | | public bool CanManageAgentSession { get; set; } = false; |
| | | 61 | | |
| | | 62 | | /// <summary> |
| | | 63 | | /// Permission to update its own name, metadata and attributes. Defaults to false. |
| | | 64 | | /// </summary> |
| | | 65 | | public bool CanUpdateOwnMetadata { get; set; } = false; |
| | | 66 | | |
| | | 67 | | /// <summary> |
| | | 68 | | /// Destination room which this participant can forward to. |
| | | 69 | | /// </summary> |
| | | 70 | | public string DestinationRoom { get; set; } = ""; |
| | | 71 | | |
| | | 72 | | /// <summary> |
| | | 73 | | /// Participant isn't visible to others. |
| | | 74 | | /// </summary> |
| | | 75 | | public bool Hidden { get; set; } = false; |
| | | 76 | | |
| | | 77 | | /// <summary> |
| | | 78 | | /// Permissions to control ingress, not specific to any room or ingress. |
| | | 79 | | /// </summary> |
| | | 80 | | public bool IngressAdmin { get; set; } = false; |
| | | 81 | | |
| | | 82 | | /// <summary> |
| | | 83 | | /// Participant is recording the room, when set, allows room to indicate it's being recorded. |
| | | 84 | | /// </summary> |
| | | 85 | | public bool Recorder { get; set; } = false; |
| | | 86 | | |
| | | 87 | | /// <summary> |
| | | 88 | | /// Name of the room, must be set for <c>RoomAdmin</c> or <c>RoomJoin</c> permissions. |
| | | 89 | | /// </summary> |
| | | 90 | | public string Room { get; set; } = ""; |
| | | 91 | | |
| | | 92 | | /// <summary> |
| | | 93 | | /// Permission to control a specific room, <c>Room</c> must be set. |
| | | 94 | | /// </summary> |
| | | 95 | | public bool RoomAdmin { get; set; } = false; |
| | | 96 | | |
| | | 97 | | /// <summary> |
| | | 98 | | /// Permission to create a room. |
| | | 99 | | /// </summary> |
| | | 100 | | public bool RoomCreate { get; set; } = false; |
| | | 101 | | |
| | | 102 | | /// <summary> |
| | | 103 | | /// Permission to join a room as a participant, <c>Room</c> must be set. |
| | | 104 | | /// </summary> |
| | | 105 | | public bool RoomJoin { get; set; } = false; |
| | | 106 | | |
| | | 107 | | /// <summary> |
| | | 108 | | /// Permission to list rooms. |
| | | 109 | | /// </summary> |
| | | 110 | | public bool RoomList { get; set; } = false; |
| | | 111 | | |
| | | 112 | | /// <summary> |
| | | 113 | | /// Permission to start a recording. |
| | | 114 | | /// </summary> |
| | | 115 | | public bool RoomRecord { get; set; } = false; |
| | | 116 | | } |
| | | 117 | | |
| | | 118 | | /// <summary> |
| | | 119 | | /// The <c>sip</c> grant of an access token: what its holder may do with the SIP service. |
| | | 120 | | /// </summary> |
| | | 121 | | public class SIPGrants |
| | | 122 | | { |
| | | 123 | | /// <summary> |
| | | 124 | | /// Permission to manage SIP trunks and dispatch rules. |
| | | 125 | | /// </summary> |
| | | 126 | | public bool Admin { get; set; } = false; |
| | | 127 | | |
| | | 128 | | /// <summary> |
| | | 129 | | /// Permission to make outbound calls. |
| | | 130 | | /// </summary> |
| | | 131 | | public bool Call { get; set; } = false; |
| | | 132 | | } |
| | | 133 | | |
| | | 134 | | /// <summary> |
| | | 135 | | /// The <c>inference</c> grant of an access token. |
| | | 136 | | /// </summary> |
| | | 137 | | public class InferenceGrants |
| | | 138 | | { |
| | | 139 | | /// <summary> |
| | | 140 | | /// Permission to perform inference. |
| | | 141 | | /// </summary> |
| | | 142 | | public bool Perform { get; set; } = false; |
| | | 143 | | } |
| | | 144 | | |
| | | 145 | | /// <summary> |
| | | 146 | | /// The <c>observability</c> grant of an access token. |
| | | 147 | | /// </summary> |
| | | 148 | | public class ObservabilityGrants |
| | | 149 | | { |
| | | 150 | | /// <summary> |
| | | 151 | | /// Permission to publish observability data. |
| | | 152 | | /// </summary> |
| | | 153 | | public bool Write { get; set; } = false; |
| | | 154 | | } |
| | | 155 | | |
| | | 156 | | /// <summary> |
| | | 157 | | /// All the claims of an access token, as built by <see cref="AccessToken"/> and read back by |
| | | 158 | | /// <see cref="TokenVerifier.Verify"/>. |
| | | 159 | | /// </summary> |
| | | 160 | | public class ClaimsModel |
| | | 161 | | { |
| | | 162 | | /// <summary> |
| | | 163 | | /// Participant identity (the <c>sub</c> claim). |
| | | 164 | | /// </summary> |
| | | 165 | | public string Identity { get; set; } = ""; |
| | | 166 | | |
| | | 167 | | /// <summary> |
| | | 168 | | /// Display name of the participant. |
| | | 169 | | /// </summary> |
| | | 170 | | public string Name { get; set; } = ""; |
| | | 171 | | |
| | | 172 | | /// <summary> |
| | | 173 | | /// Room grants (the <c>video</c> claim). |
| | | 174 | | /// </summary> |
| | | 175 | | public VideoGrants Video { get; set; } = new VideoGrants(); |
| | | 176 | | |
| | | 177 | | /// <summary> |
| | | 178 | | /// SIP grants (the <c>sip</c> claim). |
| | | 179 | | /// </summary> |
| | | 180 | | public SIPGrants Sip { get; set; } = new SIPGrants(); |
| | | 181 | | |
| | | 182 | | /// <summary> |
| | | 183 | | /// Inference grants, null when the token has none. |
| | | 184 | | /// </summary> |
| | | 185 | | public InferenceGrants Inference { get; set; } |
| | | 186 | | |
| | | 187 | | /// <summary> |
| | | 188 | | /// Observability grants, null when the token has none. |
| | | 189 | | /// </summary> |
| | | 190 | | public ObservabilityGrants Observability { get; set; } |
| | | 191 | | |
| | | 192 | | /// <summary> |
| | | 193 | | /// Participant metadata, visible to the other participants. |
| | | 194 | | /// </summary> |
| | | 195 | | public string Metadata { get; set; } = ""; |
| | | 196 | | |
| | | 197 | | /// <summary> |
| | | 198 | | /// SHA-256 of the request body, which webhooks use to verify the body. |
| | | 199 | | /// </summary> |
| | | 200 | | public string Sha256 { get; set; } = ""; |
| | | 201 | | |
| | | 202 | | /// <summary> |
| | | 203 | | /// Kind of participant: <c>standard</c>, <c>egress</c>, <c>ingress</c>, <c>agent</c> or <c>sip</c>. |
| | | 204 | | /// </summary> |
| | | 205 | | public string Kind { get; set; } = ""; |
| | | 206 | | |
| | | 207 | | /// <summary> |
| | | 208 | | /// Participant attributes. |
| | | 209 | | /// </summary> |
| | | 210 | | public Dictionary<string, string> Attributes { get; set; } = |
| | | 211 | | new Dictionary<string, string>(); |
| | | 212 | | |
| | | 213 | | /// <summary> |
| | | 214 | | /// Room configuration preset applied when the token creates the room. |
| | | 215 | | /// </summary> |
| | | 216 | | public string RoomPreset { get; set; } = ""; |
| | | 217 | | |
| | | 218 | | /// <summary> |
| | | 219 | | /// Room configuration applied when the token creates the room; empty (never null) when not set. |
| | | 220 | | /// </summary> |
| | | 221 | | public RoomConfiguration RoomConfig { get; set; } = new RoomConfiguration(); |
| | | 222 | | } |
| | | 223 | | } |