From 33e75e5cb9b49e46f25debdbf7e39b8192c5739b Mon Sep 17 00:00:00 2001 From: Kaien Date: Sat, 4 Apr 2026 16:16:14 +0300 Subject: [PATCH] feat: add AuthWithTelegramToken RPC for new Telegram Login widget Co-Authored-By: Claude Sonnet 4.6 --- auth.pb.go | 175 +++++++++++++++++++++++++++++++----------------- auth.proto | 8 +++ auth_grpc.pb.go | 52 ++++++++++++-- 3 files changed, 167 insertions(+), 68 deletions(-) diff --git a/auth.pb.go b/auth.pb.go index f03b70b..812f4a9 100644 --- a/auth.pb.go +++ b/auth.pb.go @@ -21,6 +21,51 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +// TelegramTokenRequest contains the id_token JWT from the new Telegram Login +type TelegramTokenRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + IdToken string `protobuf:"bytes,1,opt,name=id_token,json=idToken,proto3" json:"id_token,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *TelegramTokenRequest) Reset() { + *x = TelegramTokenRequest{} + mi := &file_proto_l_ai_core_proto_auth_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *TelegramTokenRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TelegramTokenRequest) ProtoMessage() {} + +func (x *TelegramTokenRequest) ProtoReflect() protoreflect.Message { + mi := &file_proto_l_ai_core_proto_auth_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 TelegramTokenRequest.ProtoReflect.Descriptor instead. +func (*TelegramTokenRequest) Descriptor() ([]byte, []int) { + return file_proto_l_ai_core_proto_auth_proto_rawDescGZIP(), []int{0} +} + +func (x *TelegramTokenRequest) GetIdToken() string { + if x != nil { + return x.IdToken + } + return "" +} + // TelegramAuthRequest contains the data sent by the Telegram Login Widget type TelegramAuthRequest struct { state protoimpl.MessageState `protogen:"open.v1"` @@ -37,7 +82,7 @@ type TelegramAuthRequest struct { func (x *TelegramAuthRequest) Reset() { *x = TelegramAuthRequest{} - mi := &file_proto_l_ai_core_proto_auth_proto_msgTypes[0] + mi := &file_proto_l_ai_core_proto_auth_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -49,7 +94,7 @@ func (x *TelegramAuthRequest) String() string { func (*TelegramAuthRequest) ProtoMessage() {} func (x *TelegramAuthRequest) ProtoReflect() protoreflect.Message { - mi := &file_proto_l_ai_core_proto_auth_proto_msgTypes[0] + mi := &file_proto_l_ai_core_proto_auth_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -62,7 +107,7 @@ func (x *TelegramAuthRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use TelegramAuthRequest.ProtoReflect.Descriptor instead. func (*TelegramAuthRequest) Descriptor() ([]byte, []int) { - return file_proto_l_ai_core_proto_auth_proto_rawDescGZIP(), []int{0} + return file_proto_l_ai_core_proto_auth_proto_rawDescGZIP(), []int{1} } func (x *TelegramAuthRequest) GetId() int64 { @@ -124,7 +169,7 @@ type GetDiscordOAuthURLRequest struct { func (x *GetDiscordOAuthURLRequest) Reset() { *x = GetDiscordOAuthURLRequest{} - mi := &file_proto_l_ai_core_proto_auth_proto_msgTypes[1] + mi := &file_proto_l_ai_core_proto_auth_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -136,7 +181,7 @@ func (x *GetDiscordOAuthURLRequest) String() string { func (*GetDiscordOAuthURLRequest) ProtoMessage() {} func (x *GetDiscordOAuthURLRequest) ProtoReflect() protoreflect.Message { - mi := &file_proto_l_ai_core_proto_auth_proto_msgTypes[1] + mi := &file_proto_l_ai_core_proto_auth_proto_msgTypes[2] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -149,7 +194,7 @@ func (x *GetDiscordOAuthURLRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetDiscordOAuthURLRequest.ProtoReflect.Descriptor instead. func (*GetDiscordOAuthURLRequest) Descriptor() ([]byte, []int) { - return file_proto_l_ai_core_proto_auth_proto_rawDescGZIP(), []int{1} + return file_proto_l_ai_core_proto_auth_proto_rawDescGZIP(), []int{2} } func (x *GetDiscordOAuthURLRequest) GetRedirectUri() string { @@ -170,7 +215,7 @@ type OAuthURLResponse struct { func (x *OAuthURLResponse) Reset() { *x = OAuthURLResponse{} - mi := &file_proto_l_ai_core_proto_auth_proto_msgTypes[2] + mi := &file_proto_l_ai_core_proto_auth_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -182,7 +227,7 @@ func (x *OAuthURLResponse) String() string { func (*OAuthURLResponse) ProtoMessage() {} func (x *OAuthURLResponse) ProtoReflect() protoreflect.Message { - mi := &file_proto_l_ai_core_proto_auth_proto_msgTypes[2] + mi := &file_proto_l_ai_core_proto_auth_proto_msgTypes[3] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -195,7 +240,7 @@ func (x *OAuthURLResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use OAuthURLResponse.ProtoReflect.Descriptor instead. func (*OAuthURLResponse) Descriptor() ([]byte, []int) { - return file_proto_l_ai_core_proto_auth_proto_rawDescGZIP(), []int{2} + return file_proto_l_ai_core_proto_auth_proto_rawDescGZIP(), []int{3} } func (x *OAuthURLResponse) GetUrl() string { @@ -224,7 +269,7 @@ type DiscordExchangeRequest struct { func (x *DiscordExchangeRequest) Reset() { *x = DiscordExchangeRequest{} - mi := &file_proto_l_ai_core_proto_auth_proto_msgTypes[3] + mi := &file_proto_l_ai_core_proto_auth_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -236,7 +281,7 @@ func (x *DiscordExchangeRequest) String() string { func (*DiscordExchangeRequest) ProtoMessage() {} func (x *DiscordExchangeRequest) ProtoReflect() protoreflect.Message { - mi := &file_proto_l_ai_core_proto_auth_proto_msgTypes[3] + mi := &file_proto_l_ai_core_proto_auth_proto_msgTypes[4] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -249,7 +294,7 @@ func (x *DiscordExchangeRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use DiscordExchangeRequest.ProtoReflect.Descriptor instead. func (*DiscordExchangeRequest) Descriptor() ([]byte, []int) { - return file_proto_l_ai_core_proto_auth_proto_rawDescGZIP(), []int{3} + return file_proto_l_ai_core_proto_auth_proto_rawDescGZIP(), []int{4} } func (x *DiscordExchangeRequest) GetCode() string { @@ -287,7 +332,7 @@ type AuthResponse struct { func (x *AuthResponse) Reset() { *x = AuthResponse{} - mi := &file_proto_l_ai_core_proto_auth_proto_msgTypes[4] + mi := &file_proto_l_ai_core_proto_auth_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -299,7 +344,7 @@ func (x *AuthResponse) String() string { func (*AuthResponse) ProtoMessage() {} func (x *AuthResponse) ProtoReflect() protoreflect.Message { - mi := &file_proto_l_ai_core_proto_auth_proto_msgTypes[4] + mi := &file_proto_l_ai_core_proto_auth_proto_msgTypes[5] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -312,7 +357,7 @@ func (x *AuthResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use AuthResponse.ProtoReflect.Descriptor instead. func (*AuthResponse) Descriptor() ([]byte, []int) { - return file_proto_l_ai_core_proto_auth_proto_rawDescGZIP(), []int{4} + return file_proto_l_ai_core_proto_auth_proto_rawDescGZIP(), []int{5} } func (x *AuthResponse) GetAccessToken() string { @@ -359,7 +404,7 @@ type RefreshTokenRequest struct { func (x *RefreshTokenRequest) Reset() { *x = RefreshTokenRequest{} - mi := &file_proto_l_ai_core_proto_auth_proto_msgTypes[5] + mi := &file_proto_l_ai_core_proto_auth_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -371,7 +416,7 @@ func (x *RefreshTokenRequest) String() string { func (*RefreshTokenRequest) ProtoMessage() {} func (x *RefreshTokenRequest) ProtoReflect() protoreflect.Message { - mi := &file_proto_l_ai_core_proto_auth_proto_msgTypes[5] + mi := &file_proto_l_ai_core_proto_auth_proto_msgTypes[6] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -384,7 +429,7 @@ func (x *RefreshTokenRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use RefreshTokenRequest.ProtoReflect.Descriptor instead. func (*RefreshTokenRequest) Descriptor() ([]byte, []int) { - return file_proto_l_ai_core_proto_auth_proto_rawDescGZIP(), []int{5} + return file_proto_l_ai_core_proto_auth_proto_rawDescGZIP(), []int{6} } func (x *RefreshTokenRequest) GetRefreshToken() string { @@ -403,7 +448,7 @@ type RevokeTokenRequest struct { func (x *RevokeTokenRequest) Reset() { *x = RevokeTokenRequest{} - mi := &file_proto_l_ai_core_proto_auth_proto_msgTypes[6] + mi := &file_proto_l_ai_core_proto_auth_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -415,7 +460,7 @@ func (x *RevokeTokenRequest) String() string { func (*RevokeTokenRequest) ProtoMessage() {} func (x *RevokeTokenRequest) ProtoReflect() protoreflect.Message { - mi := &file_proto_l_ai_core_proto_auth_proto_msgTypes[6] + mi := &file_proto_l_ai_core_proto_auth_proto_msgTypes[7] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -428,7 +473,7 @@ func (x *RevokeTokenRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use RevokeTokenRequest.ProtoReflect.Descriptor instead. func (*RevokeTokenRequest) Descriptor() ([]byte, []int) { - return file_proto_l_ai_core_proto_auth_proto_rawDescGZIP(), []int{6} + return file_proto_l_ai_core_proto_auth_proto_rawDescGZIP(), []int{7} } func (x *RevokeTokenRequest) GetToken() string { @@ -447,7 +492,7 @@ type RevokeTokenResponse struct { func (x *RevokeTokenResponse) Reset() { *x = RevokeTokenResponse{} - mi := &file_proto_l_ai_core_proto_auth_proto_msgTypes[7] + mi := &file_proto_l_ai_core_proto_auth_proto_msgTypes[8] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -459,7 +504,7 @@ func (x *RevokeTokenResponse) String() string { func (*RevokeTokenResponse) ProtoMessage() {} func (x *RevokeTokenResponse) ProtoReflect() protoreflect.Message { - mi := &file_proto_l_ai_core_proto_auth_proto_msgTypes[7] + mi := &file_proto_l_ai_core_proto_auth_proto_msgTypes[8] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -472,7 +517,7 @@ func (x *RevokeTokenResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use RevokeTokenResponse.ProtoReflect.Descriptor instead. func (*RevokeTokenResponse) Descriptor() ([]byte, []int) { - return file_proto_l_ai_core_proto_auth_proto_rawDescGZIP(), []int{7} + return file_proto_l_ai_core_proto_auth_proto_rawDescGZIP(), []int{8} } func (x *RevokeTokenResponse) GetSuccess() bool { @@ -491,7 +536,7 @@ type ValidateTokenRequest struct { func (x *ValidateTokenRequest) Reset() { *x = ValidateTokenRequest{} - mi := &file_proto_l_ai_core_proto_auth_proto_msgTypes[8] + mi := &file_proto_l_ai_core_proto_auth_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -503,7 +548,7 @@ func (x *ValidateTokenRequest) String() string { func (*ValidateTokenRequest) ProtoMessage() {} func (x *ValidateTokenRequest) ProtoReflect() protoreflect.Message { - mi := &file_proto_l_ai_core_proto_auth_proto_msgTypes[8] + mi := &file_proto_l_ai_core_proto_auth_proto_msgTypes[9] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -516,7 +561,7 @@ func (x *ValidateTokenRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ValidateTokenRequest.ProtoReflect.Descriptor instead. func (*ValidateTokenRequest) Descriptor() ([]byte, []int) { - return file_proto_l_ai_core_proto_auth_proto_rawDescGZIP(), []int{8} + return file_proto_l_ai_core_proto_auth_proto_rawDescGZIP(), []int{9} } func (x *ValidateTokenRequest) GetToken() string { @@ -538,7 +583,7 @@ type ValidateTokenResponse struct { func (x *ValidateTokenResponse) Reset() { *x = ValidateTokenResponse{} - mi := &file_proto_l_ai_core_proto_auth_proto_msgTypes[9] + mi := &file_proto_l_ai_core_proto_auth_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -550,7 +595,7 @@ func (x *ValidateTokenResponse) String() string { func (*ValidateTokenResponse) ProtoMessage() {} func (x *ValidateTokenResponse) ProtoReflect() protoreflect.Message { - mi := &file_proto_l_ai_core_proto_auth_proto_msgTypes[9] + mi := &file_proto_l_ai_core_proto_auth_proto_msgTypes[10] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -563,7 +608,7 @@ func (x *ValidateTokenResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ValidateTokenResponse.ProtoReflect.Descriptor instead. func (*ValidateTokenResponse) Descriptor() ([]byte, []int) { - return file_proto_l_ai_core_proto_auth_proto_rawDescGZIP(), []int{9} + return file_proto_l_ai_core_proto_auth_proto_rawDescGZIP(), []int{10} } func (x *ValidateTokenResponse) GetValid() bool { @@ -598,7 +643,9 @@ var File_proto_l_ai_core_proto_auth_proto protoreflect.FileDescriptor const file_proto_l_ai_core_proto_auth_proto_rawDesc = "" + "\n" + - " proto/l-ai-core-proto/auth.proto\x12\x04auth\"\xcb\x01\n" + + " proto/l-ai-core-proto/auth.proto\x12\x04auth\"1\n" + + "\x14TelegramTokenRequest\x12\x19\n" + + "\bid_token\x18\x01 \x01(\tR\aidToken\"\xcb\x01\n" + "\x13TelegramAuthRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x1d\n" + "\n" + @@ -636,9 +683,10 @@ const file_proto_l_ai_core_proto_auth_proto_rawDesc = "" + "\x05valid\x18\x01 \x01(\bR\x05valid\x12$\n" + "\x0eglobal_user_id\x18\x02 \x01(\x03R\fglobalUserId\x12!\n" + "\fdisplay_name\x18\x03 \x01(\tR\vdisplayName\x12)\n" + - "\x10linked_platforms\x18\x04 \x03(\tR\x0flinkedPlatforms2\xb5\x03\n" + + "\x10linked_platforms\x18\x04 \x03(\tR\x0flinkedPlatforms2\xfe\x03\n" + "\vAuthService\x12A\n" + - "\x10AuthWithTelegram\x12\x19.auth.TelegramAuthRequest\x1a\x12.auth.AuthResponse\x12M\n" + + "\x10AuthWithTelegram\x12\x19.auth.TelegramAuthRequest\x1a\x12.auth.AuthResponse\x12G\n" + + "\x15AuthWithTelegramToken\x12\x1a.auth.TelegramTokenRequest\x1a\x12.auth.AuthResponse\x12M\n" + "\x12GetDiscordOAuthURL\x12\x1f.auth.GetDiscordOAuthURLRequest\x1a\x16.auth.OAuthURLResponse\x12G\n" + "\x13ExchangeDiscordCode\x12\x1c.auth.DiscordExchangeRequest\x1a\x12.auth.AuthResponse\x12=\n" + "\fRefreshToken\x12\x19.auth.RefreshTokenRequest\x1a\x12.auth.AuthResponse\x12B\n" + @@ -657,37 +705,40 @@ func file_proto_l_ai_core_proto_auth_proto_rawDescGZIP() []byte { return file_proto_l_ai_core_proto_auth_proto_rawDescData } -var file_proto_l_ai_core_proto_auth_proto_msgTypes = make([]protoimpl.MessageInfo, 10) +var file_proto_l_ai_core_proto_auth_proto_msgTypes = make([]protoimpl.MessageInfo, 11) var file_proto_l_ai_core_proto_auth_proto_goTypes = []any{ - (*TelegramAuthRequest)(nil), // 0: auth.TelegramAuthRequest - (*GetDiscordOAuthURLRequest)(nil), // 1: auth.GetDiscordOAuthURLRequest - (*OAuthURLResponse)(nil), // 2: auth.OAuthURLResponse - (*DiscordExchangeRequest)(nil), // 3: auth.DiscordExchangeRequest - (*AuthResponse)(nil), // 4: auth.AuthResponse - (*RefreshTokenRequest)(nil), // 5: auth.RefreshTokenRequest - (*RevokeTokenRequest)(nil), // 6: auth.RevokeTokenRequest - (*RevokeTokenResponse)(nil), // 7: auth.RevokeTokenResponse - (*ValidateTokenRequest)(nil), // 8: auth.ValidateTokenRequest - (*ValidateTokenResponse)(nil), // 9: auth.ValidateTokenResponse + (*TelegramTokenRequest)(nil), // 0: auth.TelegramTokenRequest + (*TelegramAuthRequest)(nil), // 1: auth.TelegramAuthRequest + (*GetDiscordOAuthURLRequest)(nil), // 2: auth.GetDiscordOAuthURLRequest + (*OAuthURLResponse)(nil), // 3: auth.OAuthURLResponse + (*DiscordExchangeRequest)(nil), // 4: auth.DiscordExchangeRequest + (*AuthResponse)(nil), // 5: auth.AuthResponse + (*RefreshTokenRequest)(nil), // 6: auth.RefreshTokenRequest + (*RevokeTokenRequest)(nil), // 7: auth.RevokeTokenRequest + (*RevokeTokenResponse)(nil), // 8: auth.RevokeTokenResponse + (*ValidateTokenRequest)(nil), // 9: auth.ValidateTokenRequest + (*ValidateTokenResponse)(nil), // 10: auth.ValidateTokenResponse } var file_proto_l_ai_core_proto_auth_proto_depIdxs = []int32{ - 0, // 0: auth.AuthService.AuthWithTelegram:input_type -> auth.TelegramAuthRequest - 1, // 1: auth.AuthService.GetDiscordOAuthURL:input_type -> auth.GetDiscordOAuthURLRequest - 3, // 2: auth.AuthService.ExchangeDiscordCode:input_type -> auth.DiscordExchangeRequest - 5, // 3: auth.AuthService.RefreshToken:input_type -> auth.RefreshTokenRequest - 6, // 4: auth.AuthService.RevokeToken:input_type -> auth.RevokeTokenRequest - 8, // 5: auth.AuthService.ValidateToken:input_type -> auth.ValidateTokenRequest - 4, // 6: auth.AuthService.AuthWithTelegram:output_type -> auth.AuthResponse - 2, // 7: auth.AuthService.GetDiscordOAuthURL:output_type -> auth.OAuthURLResponse - 4, // 8: auth.AuthService.ExchangeDiscordCode:output_type -> auth.AuthResponse - 4, // 9: auth.AuthService.RefreshToken:output_type -> auth.AuthResponse - 7, // 10: auth.AuthService.RevokeToken:output_type -> auth.RevokeTokenResponse - 9, // 11: auth.AuthService.ValidateToken:output_type -> auth.ValidateTokenResponse - 6, // [6:12] is the sub-list for method output_type - 0, // [0:6] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name + 1, // 0: auth.AuthService.AuthWithTelegram:input_type -> auth.TelegramAuthRequest + 0, // 1: auth.AuthService.AuthWithTelegramToken:input_type -> auth.TelegramTokenRequest + 2, // 2: auth.AuthService.GetDiscordOAuthURL:input_type -> auth.GetDiscordOAuthURLRequest + 4, // 3: auth.AuthService.ExchangeDiscordCode:input_type -> auth.DiscordExchangeRequest + 6, // 4: auth.AuthService.RefreshToken:input_type -> auth.RefreshTokenRequest + 7, // 5: auth.AuthService.RevokeToken:input_type -> auth.RevokeTokenRequest + 9, // 6: auth.AuthService.ValidateToken:input_type -> auth.ValidateTokenRequest + 5, // 7: auth.AuthService.AuthWithTelegram:output_type -> auth.AuthResponse + 5, // 8: auth.AuthService.AuthWithTelegramToken:output_type -> auth.AuthResponse + 3, // 9: auth.AuthService.GetDiscordOAuthURL:output_type -> auth.OAuthURLResponse + 5, // 10: auth.AuthService.ExchangeDiscordCode:output_type -> auth.AuthResponse + 5, // 11: auth.AuthService.RefreshToken:output_type -> auth.AuthResponse + 8, // 12: auth.AuthService.RevokeToken:output_type -> auth.RevokeTokenResponse + 10, // 13: auth.AuthService.ValidateToken:output_type -> auth.ValidateTokenResponse + 7, // [7:14] is the sub-list for method output_type + 0, // [0:7] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name } func init() { file_proto_l_ai_core_proto_auth_proto_init() } @@ -701,7 +752,7 @@ func file_proto_l_ai_core_proto_auth_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_proto_l_ai_core_proto_auth_proto_rawDesc), len(file_proto_l_ai_core_proto_auth_proto_rawDesc)), NumEnums: 0, - NumMessages: 10, + NumMessages: 11, NumExtensions: 0, NumServices: 1, }, diff --git a/auth.proto b/auth.proto index 0456d4f..52714f2 100644 --- a/auth.proto +++ b/auth.proto @@ -10,6 +10,9 @@ service AuthService { // Telegram Login Widget — verify widget callback data and return JWT tokens rpc AuthWithTelegram(TelegramAuthRequest) returns (AuthResponse); + // Telegram new Login (id_token JWT) — verify JWT and return platform tokens + rpc AuthWithTelegramToken(TelegramTokenRequest) returns (AuthResponse); + // Discord OAuth — generate redirect URL (state stored server-side) rpc GetDiscordOAuthURL(GetDiscordOAuthURLRequest) returns (OAuthURLResponse); @@ -26,6 +29,11 @@ service AuthService { rpc ValidateToken(ValidateTokenRequest) returns (ValidateTokenResponse); } +// TelegramTokenRequest contains the id_token JWT from the new Telegram Login +message TelegramTokenRequest { + string id_token = 1; +} + // TelegramAuthRequest contains the data sent by the Telegram Login Widget message TelegramAuthRequest { int64 id = 1; diff --git a/auth_grpc.pb.go b/auth_grpc.pb.go index 8db6682..2f52806 100644 --- a/auth_grpc.pb.go +++ b/auth_grpc.pb.go @@ -19,12 +19,13 @@ import ( const _ = grpc.SupportPackageIsVersion9 const ( - AuthService_AuthWithTelegram_FullMethodName = "/auth.AuthService/AuthWithTelegram" - AuthService_GetDiscordOAuthURL_FullMethodName = "/auth.AuthService/GetDiscordOAuthURL" - AuthService_ExchangeDiscordCode_FullMethodName = "/auth.AuthService/ExchangeDiscordCode" - AuthService_RefreshToken_FullMethodName = "/auth.AuthService/RefreshToken" - AuthService_RevokeToken_FullMethodName = "/auth.AuthService/RevokeToken" - AuthService_ValidateToken_FullMethodName = "/auth.AuthService/ValidateToken" + AuthService_AuthWithTelegram_FullMethodName = "/auth.AuthService/AuthWithTelegram" + AuthService_AuthWithTelegramToken_FullMethodName = "/auth.AuthService/AuthWithTelegramToken" + AuthService_GetDiscordOAuthURL_FullMethodName = "/auth.AuthService/GetDiscordOAuthURL" + AuthService_ExchangeDiscordCode_FullMethodName = "/auth.AuthService/ExchangeDiscordCode" + AuthService_RefreshToken_FullMethodName = "/auth.AuthService/RefreshToken" + AuthService_RevokeToken_FullMethodName = "/auth.AuthService/RevokeToken" + AuthService_ValidateToken_FullMethodName = "/auth.AuthService/ValidateToken" ) // AuthServiceClient is the client API for AuthService service. @@ -36,6 +37,8 @@ const ( type AuthServiceClient interface { // Telegram Login Widget — verify widget callback data and return JWT tokens AuthWithTelegram(ctx context.Context, in *TelegramAuthRequest, opts ...grpc.CallOption) (*AuthResponse, error) + // Telegram new Login (id_token JWT) — verify JWT and return platform tokens + AuthWithTelegramToken(ctx context.Context, in *TelegramTokenRequest, opts ...grpc.CallOption) (*AuthResponse, error) // Discord OAuth — generate redirect URL (state stored server-side) GetDiscordOAuthURL(ctx context.Context, in *GetDiscordOAuthURLRequest, opts ...grpc.CallOption) (*OAuthURLResponse, error) // Discord OAuth — exchange authorization code for JWT tokens @@ -66,6 +69,16 @@ func (c *authServiceClient) AuthWithTelegram(ctx context.Context, in *TelegramAu return out, nil } +func (c *authServiceClient) AuthWithTelegramToken(ctx context.Context, in *TelegramTokenRequest, opts ...grpc.CallOption) (*AuthResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(AuthResponse) + err := c.cc.Invoke(ctx, AuthService_AuthWithTelegramToken_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *authServiceClient) GetDiscordOAuthURL(ctx context.Context, in *GetDiscordOAuthURLRequest, opts ...grpc.CallOption) (*OAuthURLResponse, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(OAuthURLResponse) @@ -125,6 +138,8 @@ func (c *authServiceClient) ValidateToken(ctx context.Context, in *ValidateToken type AuthServiceServer interface { // Telegram Login Widget — verify widget callback data and return JWT tokens AuthWithTelegram(context.Context, *TelegramAuthRequest) (*AuthResponse, error) + // Telegram new Login (id_token JWT) — verify JWT and return platform tokens + AuthWithTelegramToken(context.Context, *TelegramTokenRequest) (*AuthResponse, error) // Discord OAuth — generate redirect URL (state stored server-side) GetDiscordOAuthURL(context.Context, *GetDiscordOAuthURLRequest) (*OAuthURLResponse, error) // Discord OAuth — exchange authorization code for JWT tokens @@ -148,6 +163,9 @@ type UnimplementedAuthServiceServer struct{} func (UnimplementedAuthServiceServer) AuthWithTelegram(context.Context, *TelegramAuthRequest) (*AuthResponse, error) { return nil, status.Error(codes.Unimplemented, "method AuthWithTelegram not implemented") } +func (UnimplementedAuthServiceServer) AuthWithTelegramToken(context.Context, *TelegramTokenRequest) (*AuthResponse, error) { + return nil, status.Error(codes.Unimplemented, "method AuthWithTelegramToken not implemented") +} func (UnimplementedAuthServiceServer) GetDiscordOAuthURL(context.Context, *GetDiscordOAuthURLRequest) (*OAuthURLResponse, error) { return nil, status.Error(codes.Unimplemented, "method GetDiscordOAuthURL not implemented") } @@ -202,6 +220,24 @@ func _AuthService_AuthWithTelegram_Handler(srv interface{}, ctx context.Context, return interceptor(ctx, in, info, handler) } +func _AuthService_AuthWithTelegramToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(TelegramTokenRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(AuthServiceServer).AuthWithTelegramToken(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: AuthService_AuthWithTelegramToken_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(AuthServiceServer).AuthWithTelegramToken(ctx, req.(*TelegramTokenRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _AuthService_GetDiscordOAuthURL_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(GetDiscordOAuthURLRequest) if err := dec(in); err != nil { @@ -303,6 +339,10 @@ var AuthService_ServiceDesc = grpc.ServiceDesc{ MethodName: "AuthWithTelegram", Handler: _AuthService_AuthWithTelegram_Handler, }, + { + MethodName: "AuthWithTelegramToken", + Handler: _AuthService_AuthWithTelegramToken_Handler, + }, { MethodName: "GetDiscordOAuthURL", Handler: _AuthService_GetDiscordOAuthURL_Handler,