@effect-ak/tg-bot-api 1.3.1 → 1.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -3,6 +3,10 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
6
10
  var __copyProps = (to, from, except, desc) => {
7
11
  if (from && typeof from === "object" || typeof from === "function") {
8
12
  for (let key of __getOwnPropNames(from))
@@ -15,4 +19,28 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
15
19
 
16
20
  // src/index.ts
17
21
  var index_exports = {};
22
+ __export(index_exports, {
23
+ verifyLoginData: () => verifyLoginData
24
+ });
18
25
  module.exports = __toCommonJS(index_exports);
26
+
27
+ // src/login-widget.ts
28
+ var toHex = (buffer) => Array.from(new Uint8Array(buffer)).map((b) => b.toString(16).padStart(2, "0")).join("");
29
+ var verifyLoginData = async (input) => {
30
+ const dataCheckString = Object.entries(input.data).filter(([key]) => key !== "hash").sort(([a], [b]) => a.localeCompare(b)).map(([key, value]) => `${key}=${value}`).join("\n");
31
+ const encoder = new TextEncoder();
32
+ const secretKey = await crypto.subtle.digest("SHA-256", encoder.encode(input.botToken));
33
+ const signingKey = await crypto.subtle.importKey(
34
+ "raw",
35
+ secretKey,
36
+ { name: "HMAC", hash: "SHA-256" },
37
+ false,
38
+ ["sign"]
39
+ );
40
+ const signature = await crypto.subtle.sign("HMAC", signingKey, encoder.encode(dataCheckString));
41
+ return toHex(signature) === input.data.hash;
42
+ };
43
+ // Annotate the CommonJS export names for ESM import in node:
44
+ 0 && (module.exports = {
45
+ verifyLoginData
46
+ });
package/dist/index.d.ts CHANGED
@@ -112,6 +112,7 @@ interface BiometricRequestAccessParams {
112
112
  }
113
113
  interface BottomButton {
114
114
  type: string;
115
+ iconCustomEmojiId: string;
115
116
  text: string;
116
117
  color: string;
117
118
  textColor: string;
@@ -389,6 +390,109 @@ interface EventHandlers {
389
390
  }) => void;
390
391
  }
391
392
 
393
+ /**
394
+ * User data returned by Telegram Login Widget after successful authentication.
395
+ *
396
+ * @see https://core.telegram.org/widgets/login#receiving-authorization-data
397
+ */
398
+ interface TelegramLoginData {
399
+ /** Unique Telegram user identifier */
400
+ id: number;
401
+ /** User's first name */
402
+ first_name: string;
403
+ /** User's last name (optional) */
404
+ last_name?: string;
405
+ /** Telegram username (optional) */
406
+ username?: string;
407
+ /** URL of the user's profile photo (optional) */
408
+ photo_url?: string;
409
+ /** Unix timestamp of the authentication */
410
+ auth_date: number;
411
+ /** HMAC-SHA-256 signature for data verification */
412
+ hash: string;
413
+ }
414
+ /**
415
+ * Options for `Telegram.Login.auth` and `Telegram.Login.init`.
416
+ */
417
+ interface TelegramLoginOptions {
418
+ /** Numeric bot ID (not the username) */
419
+ bot_id: number;
420
+ /** Request permission to send messages to the user from your bot */
421
+ request_access?: boolean;
422
+ /** Language code for the login popup (e.g. "en", "ru") */
423
+ lang?: string;
424
+ }
425
+ /**
426
+ * Programmatic API exposed by `telegram-widget.js` at `window.Telegram.Login`.
427
+ *
428
+ * Load the script to make this available:
429
+ * ```html
430
+ * <script src="https://telegram.org/js/telegram-widget.js?22"></script>
431
+ * ```
432
+ *
433
+ * @see https://core.telegram.org/widgets/login
434
+ */
435
+ interface TelegramLoginService {
436
+ /** OAuth origin URL (`https://oauth.telegram.org`) */
437
+ widgetsOrigin: string;
438
+ /**
439
+ * Store options and register the auth callback.
440
+ * If auth data is already present in the URL hash, the callback fires immediately.
441
+ */
442
+ init: (options: TelegramLoginOptions, callback: (data: TelegramLoginData | false) => void) => void;
443
+ /**
444
+ * Open the login popup using options previously set by {@link init}.
445
+ */
446
+ open: (callback?: (data: TelegramLoginData | false) => void) => void;
447
+ /**
448
+ * Full auth flow — opens a popup for Telegram OAuth.
449
+ * Self-contained, does not require a prior {@link init} call.
450
+ */
451
+ auth: (options: TelegramLoginOptions, callback: (data: TelegramLoginData | false) => void) => void;
452
+ /**
453
+ * Retrieve previously stored auth data from the server via POST request.
454
+ *
455
+ * @param options - `bot_id` is passed as a string here (server-side lookup key)
456
+ * @param callback - receives the widget origin and auth data (or `false`)
457
+ */
458
+ getAuthData: (options: {
459
+ bot_id: string;
460
+ lang?: string;
461
+ }, callback: (origin: string, data: TelegramLoginData | false) => void) => void;
462
+ }
463
+ declare global {
464
+ interface Window {
465
+ Telegram: {
466
+ /** Telegram Login Widget API */
467
+ Login: TelegramLoginService;
468
+ /** Query an embedded iframe widget for its metadata */
469
+ getWidgetInfo: (el: string | HTMLElement, callback: (info: Record<string, unknown>) => void) => void;
470
+ /** Send runtime configuration to widget iframe(s) */
471
+ setWidgetOptions: (options: Record<string, unknown>, el?: string | HTMLElement) => void;
472
+ };
473
+ }
474
+ }
475
+ /**
476
+ * Verify the authenticity of data received from Telegram Login Widget.
477
+ *
478
+ * Uses the algorithm described in the
479
+ * {@link https://core.telegram.org/widgets/login#checking-authorization | official docs}:
480
+ * 1. Build `data_check_string` from all fields except `hash`, sorted alphabetically
481
+ * 2. `secret_key = SHA-256(bot_token)`
482
+ * 3. Compare `HMAC-SHA-256(secret_key, data_check_string)` with `hash`
483
+ *
484
+ * Uses Web Crypto API — works in Node.js, Deno, Bun, and edge runtimes.
485
+ *
486
+ * @param input - Auth data and bot token
487
+ * @param input.data - Auth data received from the widget callback
488
+ * @param input.botToken - Your bot's token from \@BotFather
489
+ * @returns `true` if the data is authentic
490
+ */
491
+ declare const verifyLoginData: (input: {
492
+ data: TelegramLoginData;
493
+ botToken: string;
494
+ }) => Promise<boolean>;
495
+
392
496
  type AllowedUpdateName = Exclude<keyof Update, "update_id">;
393
497
  interface AcceptedGiftTypes {
394
498
  unlimited_gifts: boolean;
@@ -593,6 +697,7 @@ interface ChatAdministratorRights {
593
697
  can_pin_messages?: boolean;
594
698
  can_manage_topics?: boolean;
595
699
  can_manage_direct_messages?: boolean;
700
+ can_manage_tags?: boolean;
596
701
  }
597
702
  interface ChatBackground {
598
703
  type: BackgroundType;
@@ -731,6 +836,7 @@ interface ChatMemberAdministrator {
731
836
  can_pin_messages?: boolean;
732
837
  can_manage_topics?: boolean;
733
838
  can_manage_direct_messages?: boolean;
839
+ can_manage_tags?: boolean;
734
840
  custom_title?: string;
735
841
  }
736
842
  interface ChatMemberBanned {
@@ -745,6 +851,7 @@ interface ChatMemberLeft {
745
851
  interface ChatMemberMember {
746
852
  status: "member";
747
853
  user: User;
854
+ tag?: string;
748
855
  until_date?: number;
749
856
  }
750
857
  interface ChatMemberOwner {
@@ -767,11 +874,13 @@ interface ChatMemberRestricted {
767
874
  can_send_polls: boolean;
768
875
  can_send_other_messages: boolean;
769
876
  can_add_web_page_previews: boolean;
877
+ can_edit_tag: boolean;
770
878
  can_change_info: boolean;
771
879
  can_invite_users: boolean;
772
880
  can_pin_messages: boolean;
773
881
  can_manage_topics: boolean;
774
882
  until_date: number;
883
+ tag?: string;
775
884
  }
776
885
  interface ChatMemberUpdated {
777
886
  chat: Chat;
@@ -800,6 +909,7 @@ interface ChatPermissions {
800
909
  can_send_polls?: boolean;
801
910
  can_send_other_messages?: boolean;
802
911
  can_add_web_page_previews?: boolean;
912
+ can_edit_tag?: boolean;
803
913
  can_change_info?: boolean;
804
914
  can_invite_users?: boolean;
805
915
  can_pin_messages?: boolean;
@@ -1620,6 +1730,7 @@ interface Message {
1620
1730
  sender_chat?: Chat;
1621
1731
  sender_boost_count?: number;
1622
1732
  sender_business_bot?: User;
1733
+ sender_tag?: string;
1623
1734
  business_connection_id?: string;
1624
1735
  forward_origin?: MessageOrigin;
1625
1736
  is_topic_message?: boolean;
@@ -1721,13 +1832,15 @@ interface MessageAutoDeleteTimerChanged {
1721
1832
  message_auto_delete_time: number;
1722
1833
  }
1723
1834
  interface MessageEntity {
1724
- type: "mention" | "hashtag" | "cashtag" | "bot_command" | "url" | "email" | "phone_number" | "bold" | "italic" | "underline" | "strikethrough" | "spoiler" | "blockquote" | "expandable_blockquote" | "code" | "pre" | "text_link" | "text_mention" | "custom_emoji";
1835
+ type: "mention" | "hashtag" | "cashtag" | "bot_command" | "url" | "email" | "phone_number" | "bold" | "italic" | "underline" | "strikethrough" | "spoiler" | "blockquote" | "expandable_blockquote" | "code" | "pre" | "text_link" | "text_mention" | "custom_emoji" | "date_time";
1725
1836
  offset: number;
1726
1837
  length: number;
1727
1838
  url?: string;
1728
1839
  user?: User;
1729
1840
  language?: string;
1730
1841
  custom_emoji_id?: string;
1842
+ unix_time?: number;
1843
+ date_time_format?: string;
1731
1844
  }
1732
1845
  interface MessageId {
1733
1846
  message_id: number;
@@ -2550,6 +2663,7 @@ interface Api {
2550
2663
  set_business_account_username(_: SetBusinessAccountUsernameInput): boolean;
2551
2664
  set_chat_administrator_custom_title(_: SetChatAdministratorCustomTitleInput): boolean;
2552
2665
  set_chat_description(_: SetChatDescriptionInput): boolean;
2666
+ set_chat_member_tag(_: SetChatMemberTagInput): boolean;
2553
2667
  set_chat_menu_button(_: SetChatMenuButtonInput): boolean;
2554
2668
  set_chat_permissions(_: SetChatPermissionsInput): boolean;
2555
2669
  set_chat_photo(_: SetChatPhotoInput): boolean;
@@ -3078,6 +3192,7 @@ interface PromoteChatMemberInput {
3078
3192
  can_pin_messages?: boolean;
3079
3193
  can_manage_topics?: boolean;
3080
3194
  can_manage_direct_messages?: boolean;
3195
+ can_manage_tags?: boolean;
3081
3196
  }
3082
3197
  interface ReadBusinessMessageInput {
3083
3198
  business_connection_id: string;
@@ -3552,6 +3667,11 @@ interface SetChatDescriptionInput {
3552
3667
  chat_id: number | string;
3553
3668
  description?: string;
3554
3669
  }
3670
+ interface SetChatMemberTagInput {
3671
+ chat_id: number | string;
3672
+ user_id: number;
3673
+ tag?: string;
3674
+ }
3555
3675
  interface SetChatMenuButtonInput {
3556
3676
  chat_id?: number;
3557
3677
  menu_button?: MenuButton;
@@ -3730,4 +3850,4 @@ interface VerifyUserInput {
3730
3850
  custom_description?: string;
3731
3851
  }
3732
3852
 
3733
- export type { Accelerometer, AccelerometerStartParams, AcceptedGiftTypes, AddStickerToSetInput, AffiliateInfo, AllowedUpdateName, Animation, AnswerCallbackQueryInput, AnswerInlineQueryInput, AnswerPreCheckoutQueryInput, AnswerShippingQueryInput, AnswerWebAppQueryInput, Api, ApproveChatJoinRequestInput, ApproveSuggestedPostInput, Audio, BackButton, BackgroundFill, BackgroundFillFreeformGradient, BackgroundFillGradient, BackgroundFillSolid, BackgroundType, BackgroundTypeChatTheme, BackgroundTypeFill, BackgroundTypePattern, BackgroundTypeWallpaper, BanChatMemberInput, BanChatSenderChatInput, BindOrUnbindEventHandler, BiometricAuthenticateParams, BiometricManager, BiometricRequestAccessParams, Birthdate, BotCommand, BotCommandScope, BotCommandScopeAllChatAdministrators, BotCommandScopeAllGroupChats, BotCommandScopeAllPrivateChats, BotCommandScopeChat, BotCommandScopeChatAdministrators, BotCommandScopeChatMember, BotCommandScopeDefault, BotDescription, BotName, BotShortDescription, BottomButton, BusinessBotRights, BusinessConnection, BusinessIntro, BusinessLocation, BusinessMessagesDeleted, BusinessOpeningHours, BusinessOpeningHoursInterval, CallbackGame, CallbackQuery, Chat, ChatAdministratorRights, ChatBackground, ChatBoost, ChatBoostAdded, ChatBoostRemoved, ChatBoostSource, ChatBoostSourceGiftCode, ChatBoostSourceGiveaway, ChatBoostSourcePremium, ChatBoostUpdated, ChatFullInfo, ChatInviteLink, ChatJoinRequest, ChatLocation, ChatMember, ChatMemberAdministrator, ChatMemberBanned, ChatMemberLeft, ChatMemberMember, ChatMemberOwner, ChatMemberRestricted, ChatMemberUpdated, ChatOwnerChanged, ChatOwnerLeft, ChatPermissions, ChatPhoto, ChatShared, Checklist, ChecklistTask, ChecklistTasksAdded, ChecklistTasksDone, ChosenInlineResult, CloseForumTopicInput, CloseGeneralForumTopicInput, CloseInput, CloudStorage, Contact, ContentSafeAreaInset, ConvertGiftToStarsInput, CopyMessageInput, CopyMessagesInput, CopyTextButton, CreateChatInviteLinkInput, CreateChatSubscriptionInviteLinkInput, CreateForumTopicInput, CreateInvoiceLinkInput, CreateNewStickerSetInput, DeclineChatJoinRequestInput, DeclineSuggestedPostInput, DeleteBusinessMessagesInput, DeleteChatPhotoInput, DeleteChatStickerSetInput, DeleteForumTopicInput, DeleteMessageInput, DeleteMessagesInput, DeleteMyCommandsInput, DeleteStickerFromSetInput, DeleteStickerSetInput, DeleteStoryInput, DeleteWebhookInput, DeviceOrientation, DeviceOrientationStartParams, DeviceStorage, Dice, DirectMessagePriceChanged, DirectMessagesTopic, Document, DownloadFileParams, EditChatInviteLinkInput, EditChatSubscriptionInviteLinkInput, EditForumTopicInput, EditGeneralForumTopicInput, EditMessageCaptionInput, EditMessageChecklistInput, EditMessageLiveLocationInput, EditMessageMediaInput, EditMessageReplyMarkupInput, EditMessageTextInput, EditStoryInput, EditUserStarSubscriptionInput, EmojiStatusParams, EncryptedCredentials, EncryptedPassportElement, EventHandlers, ExportChatInviteLinkInput, ExternalReplyInfo, File, ForceReply, ForumTopic, ForumTopicClosed, ForumTopicCreated, ForumTopicEdited, ForumTopicReopened, ForwardMessageInput, ForwardMessagesInput, Game, GameHighScore, GeneralForumTopicHidden, GeneralForumTopicUnhidden, GetAvailableGiftsInput, GetBusinessAccountGiftsInput, GetBusinessAccountStarBalanceInput, GetBusinessConnectionInput, GetChatAdministratorsInput, GetChatGiftsInput, GetChatInput, GetChatMemberCountInput, GetChatMemberInput, GetChatMenuButtonInput, GetCustomEmojiStickersInput, GetFileInput, GetForumTopicIconStickersInput, GetGameHighScoresInput, GetMeInput, GetMyCommandsInput, GetMyDefaultAdministratorRightsInput, GetMyDescriptionInput, GetMyNameInput, GetMyShortDescriptionInput, GetMyStarBalanceInput, GetStarTransactionsInput, GetStickerSetInput, GetUpdatesInput, GetUserChatBoostsInput, GetUserGiftsInput, GetUserProfileAudiosInput, GetUserProfilePhotosInput, GetWebhookInfoInput, Gift, GiftBackground, GiftInfo, GiftPremiumSubscriptionInput, Gifts, Giveaway, GiveawayCompleted, GiveawayCreated, GiveawayWinners, Gyroscope, GyroscopeStartParams, HapticFeedback, HideGeneralForumTopicInput, InaccessibleMessage, InlineKeyboardButton, InlineKeyboardMarkup, InlineQuery, InlineQueryResult, InlineQueryResultArticle, InlineQueryResultAudio, InlineQueryResultCachedAudio, InlineQueryResultCachedDocument, InlineQueryResultCachedGif, InlineQueryResultCachedMpeg4Gif, InlineQueryResultCachedPhoto, InlineQueryResultCachedSticker, InlineQueryResultCachedVideo, InlineQueryResultCachedVoice, InlineQueryResultContact, InlineQueryResultDocument, InlineQueryResultGame, InlineQueryResultGif, InlineQueryResultLocation, InlineQueryResultMpeg4Gif, InlineQueryResultPhoto, InlineQueryResultVenue, InlineQueryResultVideo, InlineQueryResultVoice, InlineQueryResultsButton, InputChecklist, InputChecklistTask, InputContactMessageContent, InputFile, InputInvoiceMessageContent, InputLocationMessageContent, InputMedia, InputMediaAnimation, InputMediaAudio, InputMediaDocument, InputMediaPhoto, InputMediaVideo, InputMessageContent, InputPaidMedia, InputPaidMediaPhoto, InputPaidMediaVideo, InputPollOption, InputProfilePhoto, InputProfilePhotoAnimated, InputProfilePhotoStatic, InputSticker, InputStoryContent, InputStoryContentPhoto, InputStoryContentVideo, InputTextMessageContent, InputVenueMessageContent, Invoice, KeyboardButton, KeyboardButtonPollType, KeyboardButtonRequestChat, KeyboardButtonRequestUsers, LabeledPrice, LeaveChatInput, LinkPreviewOptions, Location, LocationAddress, LocationData, LocationManager, LogOutInput, LoginUrl, MaskPosition, MaybeInaccessibleMessage, MenuButton, MenuButtonCommands, MenuButtonDefault, MenuButtonWebApp, Message, MessageAutoDeleteTimerChanged, MessageEntity, MessageId, MessageOrigin, MessageOriginChannel, MessageOriginChat, MessageOriginHiddenUser, MessageOriginUser, MessageReactionCountUpdated, MessageReactionUpdated, OrderInfo, OwnedGift, OwnedGiftRegular, OwnedGiftUnique, OwnedGifts, PaidMedia, PaidMediaInfo, PaidMediaPhoto, PaidMediaPreview, PaidMediaPurchased, PaidMediaVideo, PaidMessagePriceChanged, PassportData, PassportElementError, PassportElementErrorDataField, PassportElementErrorFile, PassportElementErrorFiles, PassportElementErrorFrontSide, PassportElementErrorReverseSide, PassportElementErrorSelfie, PassportElementErrorTranslationFile, PassportElementErrorTranslationFiles, PassportElementErrorUnspecified, PassportFile, PhotoSize, PinChatMessageInput, Poll, PollAnswer, PollOption, PopupButton, PopupParams, PostStoryInput, PreCheckoutQuery, PreparedInlineMessage, PromoteChatMemberInput, ProximityAlertTriggered, ReactionCount, ReactionType, ReactionTypeCustomEmoji, ReactionTypeEmoji, ReactionTypePaid, ReadBusinessMessageInput, RefundStarPaymentInput, RefundedPayment, RemoveBusinessAccountProfilePhotoInput, RemoveChatVerificationInput, RemoveMyProfilePhotoInput, RemoveUserVerificationInput, ReopenForumTopicInput, ReopenGeneralForumTopicInput, ReplaceStickerInSetInput, ReplyKeyboardMarkup, ReplyKeyboardRemove, ReplyParameters, RepostStoryInput, ResponseParameters, RestrictChatMemberInput, RevenueWithdrawalState, RevenueWithdrawalStateFailed, RevenueWithdrawalStatePending, RevenueWithdrawalStateSucceeded, RevokeChatInviteLinkInput, SafeAreaInset, SavePreparedInlineMessageInput, ScanQrPopupParams, SecureStorage, SendAnimationInput, SendAudioInput, SendChatActionInput, SendChecklistInput, SendContactInput, SendDiceInput, SendDocumentInput, SendGameInput, SendGiftInput, SendInvoiceInput, SendLocationInput, SendMediaGroupInput, SendMessageDraftInput, SendMessageInput, SendPaidMediaInput, SendPhotoInput, SendPollInput, SendStickerInput, SendVenueInput, SendVideoInput, SendVideoNoteInput, SendVoiceInput, SentWebAppMessage, SetBusinessAccountBioInput, SetBusinessAccountGiftSettingsInput, SetBusinessAccountNameInput, SetBusinessAccountProfilePhotoInput, SetBusinessAccountUsernameInput, SetChatAdministratorCustomTitleInput, SetChatDescriptionInput, SetChatMenuButtonInput, SetChatPermissionsInput, SetChatPhotoInput, SetChatStickerSetInput, SetChatTitleInput, SetCustomEmojiStickerSetThumbnailInput, SetGameScoreInput, SetMessageReactionInput, SetMyCommandsInput, SetMyDefaultAdministratorRightsInput, SetMyDescriptionInput, SetMyNameInput, SetMyProfilePhotoInput, SetMyShortDescriptionInput, SetPassportDataErrorsInput, SetStickerEmojiListInput, SetStickerKeywordsInput, SetStickerMaskPositionInput, SetStickerPositionInSetInput, SetStickerSetThumbnailInput, SetStickerSetTitleInput, SetUserEmojiStatusInput, SetWebhookInput, SettingsButton, SharedUser, ShippingAddress, ShippingOption, ShippingQuery, StarAmount, StarTransaction, StarTransactions, Sticker, StickerSet, StopMessageLiveLocationInput, StopPollInput, Story, StoryArea, StoryAreaPosition, StoryAreaType, StoryAreaTypeLink, StoryAreaTypeLocation, StoryAreaTypeSuggestedReaction, StoryAreaTypeUniqueGift, StoryAreaTypeWeather, StoryShareParams, StoryWidgetLink, SuccessfulPayment, SuggestedPostApprovalFailed, SuggestedPostApproved, SuggestedPostDeclined, SuggestedPostInfo, SuggestedPostPaid, SuggestedPostParameters, SuggestedPostPrice, SuggestedPostRefunded, SwitchInlineQueryChosenChat, TextQuote, ThemeParams, TransactionPartner, TransactionPartnerAffiliateProgram, TransactionPartnerChat, TransactionPartnerFragment, TransactionPartnerOther, TransactionPartnerTelegramAds, TransactionPartnerTelegramApi, TransactionPartnerUser, TransferBusinessAccountStarsInput, TransferGiftInput, UnbanChatMemberInput, UnbanChatSenderChatInput, UnhideGeneralForumTopicInput, UniqueGift, UniqueGiftBackdrop, UniqueGiftBackdropColors, UniqueGiftColors, UniqueGiftInfo, UniqueGiftModel, UniqueGiftSymbol, UnpinAllChatMessagesInput, UnpinAllForumTopicMessagesInput, UnpinAllGeneralForumTopicMessagesInput, UnpinChatMessageInput, Update, UpgradeGiftInput, UploadStickerFileInput, User, UserChatBoosts, UserProfileAudios, UserProfilePhotos, UserRating, UsersShared, Venue, VerifyChatInput, VerifyUserInput, Video, VideoChatEnded, VideoChatParticipantsInvited, VideoChatScheduled, VideoChatStarted, VideoNote, VideoQuality, Voice, WebApp, WebAppChat, WebAppData, WebAppInfo, WebAppInitData, WebAppUser, WebhookInfo, WriteAccessAllowed };
3853
+ export { type Accelerometer, type AccelerometerStartParams, type AcceptedGiftTypes, type AddStickerToSetInput, type AffiliateInfo, type AllowedUpdateName, type Animation, type AnswerCallbackQueryInput, type AnswerInlineQueryInput, type AnswerPreCheckoutQueryInput, type AnswerShippingQueryInput, type AnswerWebAppQueryInput, type Api, type ApproveChatJoinRequestInput, type ApproveSuggestedPostInput, type Audio, type BackButton, type BackgroundFill, type BackgroundFillFreeformGradient, type BackgroundFillGradient, type BackgroundFillSolid, type BackgroundType, type BackgroundTypeChatTheme, type BackgroundTypeFill, type BackgroundTypePattern, type BackgroundTypeWallpaper, type BanChatMemberInput, type BanChatSenderChatInput, type BindOrUnbindEventHandler, type BiometricAuthenticateParams, type BiometricManager, type BiometricRequestAccessParams, type Birthdate, type BotCommand, type BotCommandScope, type BotCommandScopeAllChatAdministrators, type BotCommandScopeAllGroupChats, type BotCommandScopeAllPrivateChats, type BotCommandScopeChat, type BotCommandScopeChatAdministrators, type BotCommandScopeChatMember, type BotCommandScopeDefault, type BotDescription, type BotName, type BotShortDescription, type BottomButton, type BusinessBotRights, type BusinessConnection, type BusinessIntro, type BusinessLocation, type BusinessMessagesDeleted, type BusinessOpeningHours, type BusinessOpeningHoursInterval, type CallbackGame, type CallbackQuery, type Chat, type ChatAdministratorRights, type ChatBackground, type ChatBoost, type ChatBoostAdded, type ChatBoostRemoved, type ChatBoostSource, type ChatBoostSourceGiftCode, type ChatBoostSourceGiveaway, type ChatBoostSourcePremium, type ChatBoostUpdated, type ChatFullInfo, type ChatInviteLink, type ChatJoinRequest, type ChatLocation, type ChatMember, type ChatMemberAdministrator, type ChatMemberBanned, type ChatMemberLeft, type ChatMemberMember, type ChatMemberOwner, type ChatMemberRestricted, type ChatMemberUpdated, type ChatOwnerChanged, type ChatOwnerLeft, type ChatPermissions, type ChatPhoto, type ChatShared, type Checklist, type ChecklistTask, type ChecklistTasksAdded, type ChecklistTasksDone, type ChosenInlineResult, type CloseForumTopicInput, type CloseGeneralForumTopicInput, type CloseInput, type CloudStorage, type Contact, type ContentSafeAreaInset, type ConvertGiftToStarsInput, type CopyMessageInput, type CopyMessagesInput, type CopyTextButton, type CreateChatInviteLinkInput, type CreateChatSubscriptionInviteLinkInput, type CreateForumTopicInput, type CreateInvoiceLinkInput, type CreateNewStickerSetInput, type DeclineChatJoinRequestInput, type DeclineSuggestedPostInput, type DeleteBusinessMessagesInput, type DeleteChatPhotoInput, type DeleteChatStickerSetInput, type DeleteForumTopicInput, type DeleteMessageInput, type DeleteMessagesInput, type DeleteMyCommandsInput, type DeleteStickerFromSetInput, type DeleteStickerSetInput, type DeleteStoryInput, type DeleteWebhookInput, type DeviceOrientation, type DeviceOrientationStartParams, type DeviceStorage, type Dice, type DirectMessagePriceChanged, type DirectMessagesTopic, type Document, type DownloadFileParams, type EditChatInviteLinkInput, type EditChatSubscriptionInviteLinkInput, type EditForumTopicInput, type EditGeneralForumTopicInput, type EditMessageCaptionInput, type EditMessageChecklistInput, type EditMessageLiveLocationInput, type EditMessageMediaInput, type EditMessageReplyMarkupInput, type EditMessageTextInput, type EditStoryInput, type EditUserStarSubscriptionInput, type EmojiStatusParams, type EncryptedCredentials, type EncryptedPassportElement, type EventHandlers, type ExportChatInviteLinkInput, type ExternalReplyInfo, type File, type ForceReply, type ForumTopic, type ForumTopicClosed, type ForumTopicCreated, type ForumTopicEdited, type ForumTopicReopened, type ForwardMessageInput, type ForwardMessagesInput, type Game, type GameHighScore, type GeneralForumTopicHidden, type GeneralForumTopicUnhidden, type GetAvailableGiftsInput, type GetBusinessAccountGiftsInput, type GetBusinessAccountStarBalanceInput, type GetBusinessConnectionInput, type GetChatAdministratorsInput, type GetChatGiftsInput, type GetChatInput, type GetChatMemberCountInput, type GetChatMemberInput, type GetChatMenuButtonInput, type GetCustomEmojiStickersInput, type GetFileInput, type GetForumTopicIconStickersInput, type GetGameHighScoresInput, type GetMeInput, type GetMyCommandsInput, type GetMyDefaultAdministratorRightsInput, type GetMyDescriptionInput, type GetMyNameInput, type GetMyShortDescriptionInput, type GetMyStarBalanceInput, type GetStarTransactionsInput, type GetStickerSetInput, type GetUpdatesInput, type GetUserChatBoostsInput, type GetUserGiftsInput, type GetUserProfileAudiosInput, type GetUserProfilePhotosInput, type GetWebhookInfoInput, type Gift, type GiftBackground, type GiftInfo, type GiftPremiumSubscriptionInput, type Gifts, type Giveaway, type GiveawayCompleted, type GiveawayCreated, type GiveawayWinners, type Gyroscope, type GyroscopeStartParams, type HapticFeedback, type HideGeneralForumTopicInput, type InaccessibleMessage, type InlineKeyboardButton, type InlineKeyboardMarkup, type InlineQuery, type InlineQueryResult, type InlineQueryResultArticle, type InlineQueryResultAudio, type InlineQueryResultCachedAudio, type InlineQueryResultCachedDocument, type InlineQueryResultCachedGif, type InlineQueryResultCachedMpeg4Gif, type InlineQueryResultCachedPhoto, type InlineQueryResultCachedSticker, type InlineQueryResultCachedVideo, type InlineQueryResultCachedVoice, type InlineQueryResultContact, type InlineQueryResultDocument, type InlineQueryResultGame, type InlineQueryResultGif, type InlineQueryResultLocation, type InlineQueryResultMpeg4Gif, type InlineQueryResultPhoto, type InlineQueryResultVenue, type InlineQueryResultVideo, type InlineQueryResultVoice, type InlineQueryResultsButton, type InputChecklist, type InputChecklistTask, type InputContactMessageContent, type InputFile, type InputInvoiceMessageContent, type InputLocationMessageContent, type InputMedia, type InputMediaAnimation, type InputMediaAudio, type InputMediaDocument, type InputMediaPhoto, type InputMediaVideo, type InputMessageContent, type InputPaidMedia, type InputPaidMediaPhoto, type InputPaidMediaVideo, type InputPollOption, type InputProfilePhoto, type InputProfilePhotoAnimated, type InputProfilePhotoStatic, type InputSticker, type InputStoryContent, type InputStoryContentPhoto, type InputStoryContentVideo, type InputTextMessageContent, type InputVenueMessageContent, type Invoice, type KeyboardButton, type KeyboardButtonPollType, type KeyboardButtonRequestChat, type KeyboardButtonRequestUsers, type LabeledPrice, type LeaveChatInput, type LinkPreviewOptions, type Location, type LocationAddress, type LocationData, type LocationManager, type LogOutInput, type LoginUrl, type MaskPosition, type MaybeInaccessibleMessage, type MenuButton, type MenuButtonCommands, type MenuButtonDefault, type MenuButtonWebApp, type Message, type MessageAutoDeleteTimerChanged, type MessageEntity, type MessageId, type MessageOrigin, type MessageOriginChannel, type MessageOriginChat, type MessageOriginHiddenUser, type MessageOriginUser, type MessageReactionCountUpdated, type MessageReactionUpdated, type OrderInfo, type OwnedGift, type OwnedGiftRegular, type OwnedGiftUnique, type OwnedGifts, type PaidMedia, type PaidMediaInfo, type PaidMediaPhoto, type PaidMediaPreview, type PaidMediaPurchased, type PaidMediaVideo, type PaidMessagePriceChanged, type PassportData, type PassportElementError, type PassportElementErrorDataField, type PassportElementErrorFile, type PassportElementErrorFiles, type PassportElementErrorFrontSide, type PassportElementErrorReverseSide, type PassportElementErrorSelfie, type PassportElementErrorTranslationFile, type PassportElementErrorTranslationFiles, type PassportElementErrorUnspecified, type PassportFile, type PhotoSize, type PinChatMessageInput, type Poll, type PollAnswer, type PollOption, type PopupButton, type PopupParams, type PostStoryInput, type PreCheckoutQuery, type PreparedInlineMessage, type PromoteChatMemberInput, type ProximityAlertTriggered, type ReactionCount, type ReactionType, type ReactionTypeCustomEmoji, type ReactionTypeEmoji, type ReactionTypePaid, type ReadBusinessMessageInput, type RefundStarPaymentInput, type RefundedPayment, type RemoveBusinessAccountProfilePhotoInput, type RemoveChatVerificationInput, type RemoveMyProfilePhotoInput, type RemoveUserVerificationInput, type ReopenForumTopicInput, type ReopenGeneralForumTopicInput, type ReplaceStickerInSetInput, type ReplyKeyboardMarkup, type ReplyKeyboardRemove, type ReplyParameters, type RepostStoryInput, type ResponseParameters, type RestrictChatMemberInput, type RevenueWithdrawalState, type RevenueWithdrawalStateFailed, type RevenueWithdrawalStatePending, type RevenueWithdrawalStateSucceeded, type RevokeChatInviteLinkInput, type SafeAreaInset, type SavePreparedInlineMessageInput, type ScanQrPopupParams, type SecureStorage, type SendAnimationInput, type SendAudioInput, type SendChatActionInput, type SendChecklistInput, type SendContactInput, type SendDiceInput, type SendDocumentInput, type SendGameInput, type SendGiftInput, type SendInvoiceInput, type SendLocationInput, type SendMediaGroupInput, type SendMessageDraftInput, type SendMessageInput, type SendPaidMediaInput, type SendPhotoInput, type SendPollInput, type SendStickerInput, type SendVenueInput, type SendVideoInput, type SendVideoNoteInput, type SendVoiceInput, type SentWebAppMessage, type SetBusinessAccountBioInput, type SetBusinessAccountGiftSettingsInput, type SetBusinessAccountNameInput, type SetBusinessAccountProfilePhotoInput, type SetBusinessAccountUsernameInput, type SetChatAdministratorCustomTitleInput, type SetChatDescriptionInput, type SetChatMemberTagInput, type SetChatMenuButtonInput, type SetChatPermissionsInput, type SetChatPhotoInput, type SetChatStickerSetInput, type SetChatTitleInput, type SetCustomEmojiStickerSetThumbnailInput, type SetGameScoreInput, type SetMessageReactionInput, type SetMyCommandsInput, type SetMyDefaultAdministratorRightsInput, type SetMyDescriptionInput, type SetMyNameInput, type SetMyProfilePhotoInput, type SetMyShortDescriptionInput, type SetPassportDataErrorsInput, type SetStickerEmojiListInput, type SetStickerKeywordsInput, type SetStickerMaskPositionInput, type SetStickerPositionInSetInput, type SetStickerSetThumbnailInput, type SetStickerSetTitleInput, type SetUserEmojiStatusInput, type SetWebhookInput, type SettingsButton, type SharedUser, type ShippingAddress, type ShippingOption, type ShippingQuery, type StarAmount, type StarTransaction, type StarTransactions, type Sticker, type StickerSet, type StopMessageLiveLocationInput, type StopPollInput, type Story, type StoryArea, type StoryAreaPosition, type StoryAreaType, type StoryAreaTypeLink, type StoryAreaTypeLocation, type StoryAreaTypeSuggestedReaction, type StoryAreaTypeUniqueGift, type StoryAreaTypeWeather, type StoryShareParams, type StoryWidgetLink, type SuccessfulPayment, type SuggestedPostApprovalFailed, type SuggestedPostApproved, type SuggestedPostDeclined, type SuggestedPostInfo, type SuggestedPostPaid, type SuggestedPostParameters, type SuggestedPostPrice, type SuggestedPostRefunded, type SwitchInlineQueryChosenChat, type TelegramLoginData, type TelegramLoginOptions, type TelegramLoginService, type TextQuote, type ThemeParams, type TransactionPartner, type TransactionPartnerAffiliateProgram, type TransactionPartnerChat, type TransactionPartnerFragment, type TransactionPartnerOther, type TransactionPartnerTelegramAds, type TransactionPartnerTelegramApi, type TransactionPartnerUser, type TransferBusinessAccountStarsInput, type TransferGiftInput, type UnbanChatMemberInput, type UnbanChatSenderChatInput, type UnhideGeneralForumTopicInput, type UniqueGift, type UniqueGiftBackdrop, type UniqueGiftBackdropColors, type UniqueGiftColors, type UniqueGiftInfo, type UniqueGiftModel, type UniqueGiftSymbol, type UnpinAllChatMessagesInput, type UnpinAllForumTopicMessagesInput, type UnpinAllGeneralForumTopicMessagesInput, type UnpinChatMessageInput, type Update, type UpgradeGiftInput, type UploadStickerFileInput, type User, type UserChatBoosts, type UserProfileAudios, type UserProfilePhotos, type UserRating, type UsersShared, type Venue, type VerifyChatInput, type VerifyUserInput, type Video, type VideoChatEnded, type VideoChatParticipantsInvited, type VideoChatScheduled, type VideoChatStarted, type VideoNote, type VideoQuality, type Voice, type WebApp, type WebAppChat, type WebAppData, type WebAppInfo, type WebAppInitData, type WebAppUser, type WebhookInfo, type WriteAccessAllowed, verifyLoginData };
package/dist/index.js CHANGED
@@ -0,0 +1,19 @@
1
+ // src/login-widget.ts
2
+ var toHex = (buffer) => Array.from(new Uint8Array(buffer)).map((b) => b.toString(16).padStart(2, "0")).join("");
3
+ var verifyLoginData = async (input) => {
4
+ const dataCheckString = Object.entries(input.data).filter(([key]) => key !== "hash").sort(([a], [b]) => a.localeCompare(b)).map(([key, value]) => `${key}=${value}`).join("\n");
5
+ const encoder = new TextEncoder();
6
+ const secretKey = await crypto.subtle.digest("SHA-256", encoder.encode(input.botToken));
7
+ const signingKey = await crypto.subtle.importKey(
8
+ "raw",
9
+ secretKey,
10
+ { name: "HMAC", hash: "SHA-256" },
11
+ false,
12
+ ["sign"]
13
+ );
14
+ const signature = await crypto.subtle.sign("HMAC", signingKey, encoder.encode(dataCheckString));
15
+ return toHex(signature) === input.data.hash;
16
+ };
17
+ export {
18
+ verifyLoginData
19
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect-ak/tg-bot-api",
3
- "version": "1.3.1",
3
+ "version": "1.3.3",
4
4
  "type": "module",
5
5
  "description": "TypeScript types for Telegram Bot Api and Telegram Mini Apps",
6
6
  "license": "MIT",
package/readme.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # @effect-ak/tg-bot-api
2
2
 
3
3
  [![NPM Version](https://img.shields.io/npm/v/%40effect-ak%2Ftg-bot-api)](https://www.npmjs.com/package/@effect-ak/tg-bot-api)
4
- ![Telegram Bot API](https://img.shields.io/badge/BotApi-9.4-blue)
5
- ![Telegram WebApp](https://img.shields.io/badge/Telegram.WebApp-9.1-blue)
4
+ ![Telegram Bot API](https://img.shields.io/badge/BotApi-9.5-blue)
5
+ ![Telegram WebApp](https://img.shields.io/badge/Telegram.WebApp-9.5-orange)
6
6
 
7
7
  Complete TypeScript types for Telegram Bot API and Mini Apps, auto-generated from official documentation.
8
8