diff --git a/.changeset/slick-facts-shine.md b/.changeset/slick-facts-shine.md new file mode 100644 index 000000000..d42fa1206 --- /dev/null +++ b/.changeset/slick-facts-shine.md @@ -0,0 +1,5 @@ +--- +"@livekit/protocol": patch +--- + +Add new TokenSourceRequest / TokenSourceResponse message types diff --git a/livekit/livekit_token_source.pb.go b/livekit/livekit_token_source.pb.go new file mode 100644 index 000000000..42f6eb8af --- /dev/null +++ b/livekit/livekit_token_source.pb.go @@ -0,0 +1,262 @@ +// Copyright 2025 LiveKit, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.9 +// protoc v4.23.4 +// source: livekit_token_source.proto + +package livekit + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type TokenSourceRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The name of the room being requested when generating credentials + RoomName *string `protobuf:"bytes,1,opt,name=room_name,json=roomName,proto3,oneof" json:"room_name,omitempty"` + // The name of the participant being requested for this client when generating credentials + ParticipantName *string `protobuf:"bytes,2,opt,name=participant_name,json=participantName,proto3,oneof" json:"participant_name,omitempty"` + // The identity of the participant being requested for this client when generating credentials + ParticipantIdentity *string `protobuf:"bytes,3,opt,name=participant_identity,json=participantIdentity,proto3,oneof" json:"participant_identity,omitempty"` + // Any participant metadata being included along with the credentials generation operation + ParticipantMetadata *string `protobuf:"bytes,4,opt,name=participant_metadata,json=participantMetadata,proto3,oneof" json:"participant_metadata,omitempty"` + // Any participant attributes being included along with the credentials generation operation + ParticipantAttributes map[string]string `protobuf:"bytes,5,rep,name=participant_attributes,json=participantAttributes,proto3" json:"participant_attributes,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + // A RoomConfiguration object can be passed to request extra parameters should be included when + // generating connection credentials - dispatching agents, defining egress settings, etc + // More info: https://docs.livekit.io/home/get-started/authentication/#room-configuration + RoomConfig *RoomConfiguration `protobuf:"bytes,6,opt,name=room_config,json=roomConfig,proto3,oneof" json:"room_config,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *TokenSourceRequest) Reset() { + *x = TokenSourceRequest{} + mi := &file_livekit_token_source_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *TokenSourceRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TokenSourceRequest) ProtoMessage() {} + +func (x *TokenSourceRequest) ProtoReflect() protoreflect.Message { + mi := &file_livekit_token_source_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TokenSourceRequest.ProtoReflect.Descriptor instead. +func (*TokenSourceRequest) Descriptor() ([]byte, []int) { + return file_livekit_token_source_proto_rawDescGZIP(), []int{0} +} + +func (x *TokenSourceRequest) GetRoomName() string { + if x != nil && x.RoomName != nil { + return *x.RoomName + } + return "" +} + +func (x *TokenSourceRequest) GetParticipantName() string { + if x != nil && x.ParticipantName != nil { + return *x.ParticipantName + } + return "" +} + +func (x *TokenSourceRequest) GetParticipantIdentity() string { + if x != nil && x.ParticipantIdentity != nil { + return *x.ParticipantIdentity + } + return "" +} + +func (x *TokenSourceRequest) GetParticipantMetadata() string { + if x != nil && x.ParticipantMetadata != nil { + return *x.ParticipantMetadata + } + return "" +} + +func (x *TokenSourceRequest) GetParticipantAttributes() map[string]string { + if x != nil { + return x.ParticipantAttributes + } + return nil +} + +func (x *TokenSourceRequest) GetRoomConfig() *RoomConfiguration { + if x != nil { + return x.RoomConfig + } + return nil +} + +type TokenSourceResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + ServerUrl string `protobuf:"bytes,1,opt,name=server_url,json=serverUrl,proto3" json:"server_url,omitempty"` + ParticipantToken string `protobuf:"bytes,2,opt,name=participant_token,json=participantToken,proto3" json:"participant_token,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *TokenSourceResponse) Reset() { + *x = TokenSourceResponse{} + mi := &file_livekit_token_source_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *TokenSourceResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TokenSourceResponse) ProtoMessage() {} + +func (x *TokenSourceResponse) ProtoReflect() protoreflect.Message { + mi := &file_livekit_token_source_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TokenSourceResponse.ProtoReflect.Descriptor instead. +func (*TokenSourceResponse) Descriptor() ([]byte, []int) { + return file_livekit_token_source_proto_rawDescGZIP(), []int{1} +} + +func (x *TokenSourceResponse) GetServerUrl() string { + if x != nil { + return x.ServerUrl + } + return "" +} + +func (x *TokenSourceResponse) GetParticipantToken() string { + if x != nil { + return x.ParticipantToken + } + return "" +} + +var File_livekit_token_source_proto protoreflect.FileDescriptor + +const file_livekit_token_source_proto_rawDesc = "" + + "\n" + + "\x1alivekit_token_source.proto\x12\alivekit\x1a\x12livekit_room.proto\"\xb6\x04\n" + + "\x12TokenSourceRequest\x12 \n" + + "\troom_name\x18\x01 \x01(\tH\x00R\broomName\x88\x01\x01\x12.\n" + + "\x10participant_name\x18\x02 \x01(\tH\x01R\x0fparticipantName\x88\x01\x01\x126\n" + + "\x14participant_identity\x18\x03 \x01(\tH\x02R\x13participantIdentity\x88\x01\x01\x126\n" + + "\x14participant_metadata\x18\x04 \x01(\tH\x03R\x13participantMetadata\x88\x01\x01\x12m\n" + + "\x16participant_attributes\x18\x05 \x03(\v26.livekit.TokenSourceRequest.ParticipantAttributesEntryR\x15participantAttributes\x12@\n" + + "\vroom_config\x18\x06 \x01(\v2\x1a.livekit.RoomConfigurationH\x04R\n" + + "roomConfig\x88\x01\x01\x1aH\n" + + "\x1aParticipantAttributesEntry\x12\x10\n" + + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01B\f\n" + + "\n" + + "_room_nameB\x13\n" + + "\x11_participant_nameB\x17\n" + + "\x15_participant_identityB\x17\n" + + "\x15_participant_metadataB\x0e\n" + + "\f_room_config\"a\n" + + "\x13TokenSourceResponse\x12\x1d\n" + + "\n" + + "server_url\x18\x01 \x01(\tR\tserverUrl\x12+\n" + + "\x11participant_token\x18\x02 \x01(\tR\x10participantTokenBFZ#github.com/livekit/protocol/livekit\xaa\x02\rLiveKit.Proto\xea\x02\x0eLiveKit::Protob\x06proto3" + +var ( + file_livekit_token_source_proto_rawDescOnce sync.Once + file_livekit_token_source_proto_rawDescData []byte +) + +func file_livekit_token_source_proto_rawDescGZIP() []byte { + file_livekit_token_source_proto_rawDescOnce.Do(func() { + file_livekit_token_source_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_livekit_token_source_proto_rawDesc), len(file_livekit_token_source_proto_rawDesc))) + }) + return file_livekit_token_source_proto_rawDescData +} + +var file_livekit_token_source_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_livekit_token_source_proto_goTypes = []any{ + (*TokenSourceRequest)(nil), // 0: livekit.TokenSourceRequest + (*TokenSourceResponse)(nil), // 1: livekit.TokenSourceResponse + nil, // 2: livekit.TokenSourceRequest.ParticipantAttributesEntry + (*RoomConfiguration)(nil), // 3: livekit.RoomConfiguration +} +var file_livekit_token_source_proto_depIdxs = []int32{ + 2, // 0: livekit.TokenSourceRequest.participant_attributes:type_name -> livekit.TokenSourceRequest.ParticipantAttributesEntry + 3, // 1: livekit.TokenSourceRequest.room_config:type_name -> livekit.RoomConfiguration + 2, // [2:2] is the sub-list for method output_type + 2, // [2:2] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name +} + +func init() { file_livekit_token_source_proto_init() } +func file_livekit_token_source_proto_init() { + if File_livekit_token_source_proto != nil { + return + } + file_livekit_room_proto_init() + file_livekit_token_source_proto_msgTypes[0].OneofWrappers = []any{} + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_livekit_token_source_proto_rawDesc), len(file_livekit_token_source_proto_rawDesc)), + NumEnums: 0, + NumMessages: 3, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_livekit_token_source_proto_goTypes, + DependencyIndexes: file_livekit_token_source_proto_depIdxs, + MessageInfos: file_livekit_token_source_proto_msgTypes, + }.Build() + File_livekit_token_source_proto = out.File + file_livekit_token_source_proto_goTypes = nil + file_livekit_token_source_proto_depIdxs = nil +} diff --git a/magefile.go b/magefile.go index bd43baf37..f2a1f5238 100644 --- a/magefile.go +++ b/magefile.go @@ -59,6 +59,7 @@ func Proto() error { "livekit_rtc.proto", "livekit_webhook.proto", "livekit_metrics.proto", + "livekit_token_source.proto", } grpcProtoFiles := []string{ "infra/link.proto", diff --git a/packages/javascript/src/index.d.ts b/packages/javascript/src/index.d.ts index 094183bb0..b1d2d8232 100644 --- a/packages/javascript/src/index.d.ts +++ b/packages/javascript/src/index.d.ts @@ -8,5 +8,6 @@ export * from "./gen/livekit_models_pb.js"; export * from "./gen/livekit_room_pb.js"; export * from "./gen/livekit_rtc_pb.js"; export * from "./gen/livekit_sip_pb.js"; +export * from "./gen/livekit_token_source.js"; export * from "./gen/livekit_webhook_pb.js"; export * from "./gen/version.js"; diff --git a/packages/javascript/src/index.js b/packages/javascript/src/index.js index 4c20c1414..fa83fe9a7 100644 --- a/packages/javascript/src/index.js +++ b/packages/javascript/src/index.js @@ -9,5 +9,6 @@ export * from "./gen/livekit_models_pb.js"; export * from "./gen/livekit_room_pb.js"; export * from "./gen/livekit_rtc_pb.js"; export * from "./gen/livekit_sip_pb.js"; +export * from "./gen/livekit_token_source.js"; export * from "./gen/livekit_webhook_pb.js"; export * from "./gen/version.js"; diff --git a/protobufs/livekit_token_source.proto b/protobufs/livekit_token_source.proto new file mode 100644 index 000000000..4f9882e76 --- /dev/null +++ b/protobufs/livekit_token_source.proto @@ -0,0 +1,49 @@ +// Copyright 2025 LiveKit, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package livekit; +option go_package = "github.com/livekit/protocol/livekit"; +option csharp_namespace = "LiveKit.Proto"; +option ruby_package = "LiveKit::Proto"; + +import "livekit_room.proto"; + +message TokenSourceRequest { + // The name of the room being requested when generating credentials + optional string room_name = 1; + + // The name of the participant being requested for this client when generating credentials + optional string participant_name = 2; + + // The identity of the participant being requested for this client when generating credentials + optional string participant_identity = 3; + + // Any participant metadata being included along with the credentials generation operation + optional string participant_metadata = 4; + + // Any participant attributes being included along with the credentials generation operation + map participant_attributes = 5; + + // A RoomConfiguration object can be passed to request extra parameters should be included when + // generating connection credentials - dispatching agents, defining egress settings, etc + // More info: https://docs.livekit.io/home/get-started/authentication/#room-configuration + optional RoomConfiguration room_config = 6; +} + +message TokenSourceResponse { + string server_url = 1; + string participant_token = 2; +}