@types/telegram-web-app 7.3.0 → 7.8.0

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.
@@ -8,7 +8,7 @@ This package contains type definitions for telegram-web-app (https://telegram.or
8
8
  Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/telegram-web-app.
9
9
 
10
10
  ### Additional Details
11
- * Last updated: Sun, 07 Jul 2024 15:07:38 GMT
11
+ * Last updated: Wed, 31 Jul 2024 21:35:43 GMT
12
12
  * Dependencies: none
13
13
 
14
14
  # Credits
@@ -9,14 +9,14 @@ interface Telegram {
9
9
  interface WebApp {
10
10
  /**
11
11
  * A string with raw data transferred to the Web App, convenient for
12
- * validating data. WARNING: Validate data from this field before using it on
13
- * the bot's server.
12
+ * validating data. WARNING: Validate data from this field before using it
13
+ * on the bot's server.
14
14
  */
15
15
  initData: string;
16
16
  /**
17
17
  * An object with input data transferred to the Web App. WARNING: Data from
18
- * this field should not be trusted. You should only use data from initData on
19
- * the bot's server and only after it has been validated.
18
+ * this field should not be trusted. You should only use data from initData
19
+ * on the bot's server and only after it has been validated.
20
20
  */
21
21
  initDataUnsafe: WebAppInitData;
22
22
  /**
@@ -37,9 +37,9 @@ interface WebApp {
37
37
  */
38
38
  themeParams: ThemeParams;
39
39
  /**
40
- * True if the Web App is expanded to the maximum available height. False, if
41
- * the Web App occupies part of the screen and can be expanded to the full
42
- * height using the expand() method.
40
+ * True if the Web App is expanded to the maximum available height. False,
41
+ * if the Web App occupies part of the screen and can be expanded to the
42
+ * full height using the expand() method.
43
43
  */
44
44
  isExpanded: boolean;
45
45
  /**
@@ -47,10 +47,11 @@ interface WebApp {
47
47
  * CSS as the variable var(--tg-viewport-height).
48
48
  *
49
49
  * The application can display just the top part of the Web App, with its
50
- * lower part remaining outside the screen area. From this position, the user
51
- * can “pull” the Web App to its maximum height, while the bot can do the same
52
- * by calling the expand() method. As the position of the Web App changes, the
53
- * current height value of the visible area will be updated in real time.
50
+ * lower part remaining outside the screen area. From this position, the
51
+ * user can “pull” the Web App to its maximum height, while the bot can do
52
+ * the same by calling the expand() method. As the position of the Web App
53
+ * changes, the current height value of the visible area will be updated in
54
+ * real time.
54
55
  *
55
56
  * Please note that the refresh rate of this value is not sufficient to
56
57
  * smoothly follow the lower border of the window. It should not be used to
@@ -64,17 +65,17 @@ interface WebApp {
64
65
  * Also available in CSS as a variable var(--tg-viewport-stable-height).
65
66
  *
66
67
  * The application can display just the top part of the Web App, with its
67
- * lower part remaining outside the screen area. From this position, the user
68
- * can “pull” the Web App to its maximum height, while the bot can do the same
69
- * by calling the expand() method. Unlike the value of viewportHeight, the
70
- * value of viewportStableHeight does not change as the position of the Web
71
- * App changes with user gestures or during animations. The value of
72
- * viewportStableHeight will be updated after all gestures and animations are
73
- * completed and the Web App reaches its final size.
68
+ * lower part remaining outside the screen area. From this position, the
69
+ * user can “pull” the Web App to its maximum height, while the bot can do
70
+ * the same by calling the expand() method. Unlike the value of
71
+ * viewportHeight, the value of viewportStableHeight does not change as the
72
+ * position of the Web App changes with user gestures or during animations.
73
+ * The value of viewportStableHeight will be updated after all gestures and
74
+ * animations are completed and the Web App reaches its final size.
74
75
  *
75
76
  * Note the event viewportChanged with the passed parameter
76
- * isStateStable=true, which will allow you to track when the stable state of
77
- * the height of the visible area changes.
77
+ * isStateStable=true, which will allow you to track when the stable state
78
+ * of the height of the visible area changes.
78
79
  */
79
80
  viewportStableHeight: number;
80
81
  /**
@@ -86,8 +87,8 @@ interface WebApp {
86
87
  */
87
88
  backgroundColor: string;
88
89
  /**
89
- * True, if the confirmation dialog is enabled while the user is trying to close the Web App.
90
- * False, if the confirmation dialog is disabled.
90
+ * True, if the confirmation dialog is enabled while the user is trying to
91
+ * close the Web App. False, if the confirmation dialog is disabled.
91
92
  */
92
93
  isClosingConfirmationEnabled: boolean;
93
94
  /**
@@ -101,8 +102,8 @@ interface WebApp {
101
102
  */
102
103
  MainButton: MainButton;
103
104
  /**
104
- * An object for controlling the Settings item in the context menu of the Mini App
105
- * in the Telegram interface.
105
+ * An object for controlling the Settings item in the context menu of the
106
+ * Mini App in the Telegram interface.
106
107
  */
107
108
  SettingsButton: SettingsButton;
108
109
  /**
@@ -123,8 +124,8 @@ interface WebApp {
123
124
  */
124
125
  isVersionAtLeast(version: string): boolean;
125
126
  /**
126
- * A method that sets the app header color in the `#RRGGBB` format.
127
- * You can also use keywords bg_color and secondary_bg_color.
127
+ * A method that sets the app header color in the `#RRGGBB` format. You can
128
+ * also use keywords bg_color and secondary_bg_color.
128
129
  */
129
130
  // string & {} prevents this from eagerly collapsing into just string
130
131
  setHeaderColor(color: "bg_color" | "secondary_bg_color" | (string & {})): void;
@@ -134,11 +135,13 @@ interface WebApp {
134
135
  */
135
136
  setBackgroundColor(color: "bg_color" | "secondary_bg_color" | (string & {})): void;
136
137
  /**
137
- * A method that enables a confirmation dialog while the user is trying to close the Web App.
138
+ * A method that enables a confirmation dialog while the user is trying to
139
+ * close the Web App.
138
140
  */
139
141
  enableClosingConfirmation(): void;
140
142
  /**
141
- * A method that disables the confirmation dialog while the user is trying to close the Web App.
143
+ * A method that disables the confirmation dialog while the user is trying
144
+ * to close the Web App.
142
145
  */
143
146
  disableClosingConfirmation(): void;
144
147
  /**
@@ -181,29 +184,33 @@ interface WebApp {
181
184
  /**
182
185
  * A method used to send data to the bot. When this method is called, a
183
186
  * service message is sent to the bot containing the data data of the length
184
- * up to 4096 bytes, and the Web App is closed. See the field web_app_data in
185
- * the class Message.
187
+ * up to 4096 bytes, and the Web App is closed. See the field web_app_data
188
+ * in the class Message.
186
189
  *
187
- * This method is only available for Web Apps launched via a Keyboard button.
190
+ * This method is only available for Web Apps launched via a Keyboard
191
+ * button.
188
192
  */
189
193
  sendData(data: string): void;
190
194
  /**
191
- * A method that inserts the bot's username and the specified inline query in the current chat's input field.
192
- * Query may be empty, in which case only the bot's username will be inserted.
193
- * If an optional choose_chat_types parameter was passed, the client prompts the user to choose a specific chat,
194
- * then opens that chat and inserts the bot's username and the specified inline query in the input field.
195
- * You can specify which types of chats the user will be able to choose from.
196
- * It can be one or more of the following types: users, bots, groups, channels.
195
+ * A method that inserts the bot's username and the specified inline query
196
+ * in the current chat's input field. Query may be empty, in which case only
197
+ * the bot's username will be inserted. If an optional choose_chat_types
198
+ * parameter was passed, the client prompts the user to choose a specific
199
+ * chat, then opens that chat and inserts the bot's username and the
200
+ * specified inline query in the input field. You can specify which types of
201
+ * chats the user will be able to choose from. It can be one or more of the
202
+ * following types: users, bots, groups, channels.
197
203
  */
198
204
  switchInlineQuery(query: string, choose_chat_types?: Array<"users" | "bots" | "groups" | "channels">): void;
199
205
  /**
200
- * A method that opens a link in an external browser.
201
- * The Web App will not be closed.
202
- * If the optional options parameter is passed with the field
203
- * @param try_instant_view the link will be opened in Instant View mode if possible.
206
+ * A method that opens a link in an external browser. The Web App will not
207
+ * be closed. If the optional options parameter is passed with the field
208
+ * @param try_instant_view the link will be opened in Instant View mode if
209
+ * possible.
204
210
  *
205
- * Note that this method can be called only in response to user interaction with
206
- * the Web App interface (e.g. a click inside the Web App or on the main button)
211
+ * Note that this method can be called only in response to user interaction
212
+ * with the Web App interface (e.g. a click inside the Web App or on the
213
+ * main button)
207
214
  */
208
215
  openLink(url: string, options?: { try_instant_view?: boolean }): void;
209
216
  /**
@@ -222,44 +229,58 @@ interface WebApp {
222
229
  callback: (url: string, status: "paid" | "cancelled" | "failed" | "pending") => void,
223
230
  ): void;
224
231
  /**
225
- * A method that shows a native popup described by the params argument of the type PopupParams.
226
- * The Web App will receive the event popupClosed when the popup is closed. If an optional
227
- * callback parameter was passed, the callback function will be called and the field id of the
228
- * pressed button will be passed as the first argument.
232
+ * A method that shows a native popup described by the params argument of
233
+ * the type PopupParams. The Web App will receive the event popupClosed when
234
+ * the popup is closed. If an optional callback parameter was passed, the
235
+ * callback function will be called and the field id of the pressed button
236
+ * will be passed as the first argument.
229
237
  */
230
238
  showPopup(params: PopupParams, callback?: (button_id: string) => void): void;
231
239
  /**
232
- * A method that shows message in a simple alert with a 'Close' button. If an optional callback
233
- * parameter was passed, the callback function will be called when the popup is closed.
240
+ * A method that shows message in a simple alert with a 'Close' button. If
241
+ * an optional callback parameter was passed, the callback function will be
242
+ * called when the popup is closed.
234
243
  */
235
244
  showAlert(message: string, callback?: () => void): void;
236
245
  /**
237
- * A method that shows message in a simple confirmation window with 'OK' and 'Cancel' buttons.
238
- * If an optional callback parameter was passed, the callback function will be called when the
239
- * popup is closed and the first argument will be a boolean indicating whether the user
240
- * pressed the 'OK' button.
246
+ * A method that shows message in a simple confirmation window with 'OK' and
247
+ * 'Cancel' buttons. If an optional callback parameter was passed, the
248
+ * callback function will be called when the popup is closed and the first
249
+ * argument will be a boolean indicating whether the user pressed the 'OK'
250
+ * button.
241
251
  */
242
252
  showConfirm(message: string, callback?: (ok: boolean) => void): void;
243
253
  /**
244
- * A method that shows a native popup for scanning a QR code described by the params argument of the type ScanQrPopupParams.
245
- * The Web App will receive the event qrTextReceived every time the scanner catches a code with text data.
246
- * If an optional callback parameter was passed, the callback function will be called and the text from the QR
247
- * code will be passed as the first argument. Returning true inside this callback function causes the popup to be closed.
248
- * Starting from **Bot API 7.7**, the Mini App will receive the scanQrPopupClosed event if the user closes the native popup for scanning a QR code.
254
+ * A method that shows a native popup for scanning a QR code described by
255
+ * the params argument of the type ScanQrPopupParams. The Web App will
256
+ * receive the event qrTextReceived every time the scanner catches a code
257
+ * with text data. If an optional callback parameter was passed, the
258
+ * callback function will be called and the text from the QR code will be
259
+ * passed as the first argument. Returning true inside this callback
260
+ * function causes the popup to be closed. Starting from **Bot API 7.7**,
261
+ * the Mini App will receive the scanQrPopupClosed event if the user closes
262
+ * the native popup for scanning a QR code.
249
263
  */
250
264
  showScanQrPopup(params: ScanQrPopupParams, callback?: (data: string) => void): void;
251
265
  /**
252
- * A method that closes the native popup for scanning a QR code opened with the
253
- * showScanQrPopup method. Run it if you received valid data in the event qrTextReceived.
266
+ * A method that closes the native popup for scanning a QR code opened with
267
+ * the showScanQrPopup method. Run it if you received valid data in the
268
+ * event qrTextReceived.
254
269
  */
255
270
  closeScanQrPopup(): void;
256
- /**
257
- * A method that requests text from the clipboard. The Web App will receive the event clipboardTextReceived.
258
- * If an optional callback parameter was passed, the callback function will be
259
- * called and the text from the clipboard will be passed as the first argument.
271
+ /** A method that opens the native story editor with the media specified in
272
+ * the media_url parameter as an HTTPS URL. An optional params argument of
273
+ * the type StoryShareParams describes additional sharing settings. */
274
+ shareToStory(media_url: string, params?: StoryShareParams): void;
275
+ /**
276
+ * A method that requests text from the clipboard. The Web App will receive
277
+ * the event clipboardTextReceived. If an optional callback parameter was
278
+ * passed, the callback function will be called and the text from the
279
+ * clipboard will be passed as the first argument.
260
280
  *
261
- * Note: this method can be called only for Web Apps launched from the attachment menu and only
262
- * in response to a user interaction with the Web App interface (e.g. a click inside the Web App or on the main button).
281
+ * Note: this method can be called only for Web Apps launched from the
282
+ * attachment menu and only in response to a user interaction with the Web
283
+ * App interface (e.g. a click inside the Web App or on the main button).
263
284
  */
264
285
  readTextFromClipboard(callback?: (data: string | null) => void): void;
265
286
  /**
@@ -278,9 +299,9 @@ interface WebApp {
278
299
  *
279
300
  * @param callback If an optional callback parameter was passed, the
280
301
  * callback function will be called when the popup is closed and the first
281
- * argument will be a boolean indicating whether the user shared its
282
- * phone number. The second argument, contingent upon success, will be
283
- * an object detailing the shared contact information or a cancellation response.
302
+ * argument will be a boolean indicating whether the user shared its phone
303
+ * number. The second argument, contingent upon success, will be an object
304
+ * detailing the shared contact information or a cancellation response.
284
305
  */
285
306
  requestContact(
286
307
  callback?: (success: boolean, response: RequestContactResponse) => void,
@@ -289,33 +310,37 @@ interface WebApp {
289
310
  * A method that informs the Telegram app that the Web App is ready to be
290
311
  * displayed. It is recommended to call this method as early as possible, as
291
312
  * soon as all essential interface elements are loaded. Once this method is
292
- * called, the loading placeholder is hidden and the Web App is shown. If the
293
- * method is not called, the placeholder will be hidden only when the page is
294
- * fully loaded.
313
+ * called, the loading placeholder is hidden and the Web App is shown. If
314
+ * the method is not called, the placeholder will be hidden only when the
315
+ * page is fully loaded.
295
316
  */
296
317
  ready(): void;
297
318
  /**
298
- * A method that expands the Web App to the maximum available height. To find
299
- * out if the Web App is expanded to the maximum height, refer to the value of
300
- * the Telegram.WebApp.isExpanded parameter
319
+ * A method that expands the Web App to the maximum available height. To
320
+ * find out if the Web App is expanded to the maximum height, refer to the
321
+ * value of the Telegram.WebApp.isExpanded parameter
301
322
  */
302
323
  expand(): void;
303
324
  /** A method that closes the Web App. */
304
325
  close(): void;
305
326
  /**
306
327
  * `True`, if vertical swipes to close or minimize the Mini App are enabled.
307
- * `False`, if vertical swipes to close or minimize the Mini App are disabled.
308
- * In any case, the user will still be able to minimize and close the Mini App by swiping the Mini App's header.
328
+ * `False`, if vertical swipes to close or minimize the Mini App are
329
+ * disabled. In any case, the user will still be able to minimize and close
330
+ * the Mini App by swiping the Mini App's header.
309
331
  */
310
332
  isVerticalSwipesEnabled: boolean;
311
333
  /**
312
- * **Bot API 7.7+** A method that enables vertical swipes to close or minimize the Mini App.
313
- * For user convenience, it is recommended to always enable swipes unless they conflict with the Mini App's own gestures.
334
+ * **Bot API 7.7+** A method that enables vertical swipes to close or
335
+ * minimize the Mini App. For user convenience, it is recommended to always
336
+ * enable swipes unless they conflict with the Mini App's own gestures.
314
337
  */
315
338
  enableVerticalSwipes(): void;
316
339
  /**
317
- * **Bot API 7.7+** A method that disables vertical swipes to close or minimize the Mini App.
318
- * This method is useful if your Mini App uses swipe gestures that may conflict with the gestures for minimizing and closing the app.
340
+ * **Bot API 7.7+** A method that disables vertical swipes to close or
341
+ * minimize the Mini App. This method is useful if your Mini App uses swipe
342
+ * gestures that may conflict with the gestures for minimizing and closing
343
+ * the app.
319
344
  */
320
345
  disableVerticalSwipes(): void;
321
346
  }
@@ -343,74 +368,77 @@ type BiometricTokenUpdatedCallback = (eventData: { isUpdated: boolean }) => void
343
368
  */
344
369
  interface ThemeParams {
345
370
  /**
346
- * Background color in the `#RRGGBB` format.
347
- * Also available as the CSS variable `var(--tg-theme-bg-color)`.
371
+ * Background color in the `#RRGGBB` format. Also available as the CSS
372
+ * variable `var(--tg-theme-bg-color)`.
348
373
  */
349
374
  bg_color?: string;
350
375
  /**
351
- * Main text color in the `#RRGGBB` format.
352
- * Also available as the CSS variable `var(--tg-theme-text-color)`.
376
+ * Main text color in the `#RRGGBB` format. Also available as the CSS
377
+ * variable `var(--tg-theme-text-color)`.
353
378
  */
354
379
  text_color?: string;
355
380
  /**
356
- * Hint text color in the `#RRGGBB` format.
357
- * Also available as the CSS variable `var(--tg-theme-hint-color)`.
381
+ * Hint text color in the `#RRGGBB` format. Also available as the CSS
382
+ * variable `var(--tg-theme-hint-color)`.
358
383
  */
359
384
  hint_color?: string;
360
385
  /**
361
- * Link color in the `#RRGGBB` format.
362
- * Also available as the CSS variable `var(--tg-theme-link-color)`.
386
+ * Link color in the `#RRGGBB` format. Also available as the CSS variable
387
+ * `var(--tg-theme-link-color)`.
363
388
  */
364
389
  link_color?: string;
365
390
  /**
366
- * Button color in the `#RRGGBB` format.
367
- * Also available as the CSS variable `var(--tg-theme-button-color)`.
391
+ * Button color in the `#RRGGBB` format. Also available as the CSS variable
392
+ * `var(--tg-theme-button-color)`.
368
393
  */
369
394
  button_color?: string;
370
395
  /**
371
- * Button text color in the `#RRGGBB` format.
372
- * Also available as the CSS variable `var(--tg-theme-button-text-color)`.
396
+ * Button text color in the `#RRGGBB` format. Also available as the CSS
397
+ * variable `var(--tg-theme-button-text-color)`.
373
398
  */
374
399
  button_text_color?: string;
375
400
  /**
376
- * **Bot API 6.1+** Secondary background color in the `#RRGGBB` format.
377
- * Also available as the CSS variable `var(--tg-theme-secondary-bg-color)`.
401
+ * **Bot API 6.1+** Secondary background color in the `#RRGGBB` format. Also
402
+ * available as the CSS variable `var(--tg-theme-secondary-bg-color)`.
378
403
  */
379
404
  secondary_bg_color?: string;
380
405
  /**
381
- * **Bot API 7.0+** Header background color in the `#RRGGBB` format.
382
- * Also available as the CSS variable `var(--tg-theme-header-bg-color)`.
406
+ * **Bot API 7.0+** Header background color in the `#RRGGBB` format. Also
407
+ * available as the CSS variable `var(--tg-theme-header-bg-color)`.
383
408
  */
384
409
  header_bg_color?: string;
385
410
  /**
386
- * **Bot API 7.0+** Accent text color in the `#RRGGBB` format.
387
- * Also available as the CSS variable `var(--tg-theme-accent-text-color)`.
411
+ * **Bot API 7.0+** Accent text color in the `#RRGGBB` format. Also
412
+ * available as the CSS variable `var(--tg-theme-accent-text-color)`.
388
413
  */
389
414
  accent_text_color?: string;
390
415
  /**
391
- * **Bot API 7.0+** Background color for the section in the `#RRGGBB` format. It is
392
- * recommended to use this in conjunction with *secondary_bg_color*.
393
- * Also available as the CSS variable `var(--tg-theme-section-bg-color)`.
416
+ * **Bot API 7.0+** Background color for the section in the `#RRGGBB`
417
+ * format. It is recommended to use this in conjunction with
418
+ * *secondary_bg_color*. Also available as the CSS variable
419
+ * `var(--tg-theme-section-bg-color)`.
394
420
  */
395
421
  section_bg_color?: string;
396
422
  /**
397
- * **Bot API 7.0+** Header text color for the section in the `#RRGGBB` format.
398
- * Also available as the CSS variable `var(--tg-theme-section-header-text-color)`.
423
+ * **Bot API 7.0+** Header text color for the section in the `#RRGGBB`
424
+ * format. Also available as the CSS variable
425
+ * `var(--tg-theme-section-header-text-color)`.
399
426
  */
400
427
  section_header_text_color?: `#${string}`;
401
428
  /**
402
- * **Bot API 7.6+** Section separator color in the `#RRGGBB` format.
403
- * Also available as the CSS variable `var(--tg-theme-section-separator-color)`.
429
+ * **Bot API 7.6+** Section separator color in the `#RRGGBB` format. Also
430
+ * available as the CSS variable `var(--tg-theme-section-separator-color)`.
404
431
  */
405
432
  section_separator_color?: string;
406
433
  /**
407
- * **Bot API 7.0+** Subtitle text color in the `#RRGGBB` format.
408
- * Also available as the CSS variable `var(--tg-theme-subtitle-text-color)`.
434
+ * **Bot API 7.0+** Subtitle text color in the `#RRGGBB` format. Also
435
+ * available as the CSS variable `var(--tg-theme-subtitle-text-color)`.
409
436
  */
410
437
  subtitle_text_color?: string;
411
438
  /**
412
- * **Bot API 7.0+** Text color for destructive actions in the `#RRGGBB` format.
413
- * Also available as the CSS variable `var(--tg-theme-destructive-text-color)`.
439
+ * **Bot API 7.0+** Text color for destructive actions in the `#RRGGBB`
440
+ * format. Also available as the CSS variable
441
+ * `var(--tg-theme-destructive-text-color)`.
414
442
  */
415
443
  destructive_text_color?: string;
416
444
  }
@@ -428,7 +456,8 @@ interface PopupParams {
428
456
  */
429
457
  message: string;
430
458
  /**
431
- * List of buttons to be displayed in the popup, 1-3 buttons. Set to [{“type”:“close”}] by default.
459
+ * List of buttons to be displayed in the popup, 1-3 buttons. Set to
460
+ * [{“type”:“close”}] by default.
432
461
  */
433
462
  buttons?: PopupButton[];
434
463
  }
@@ -439,23 +468,25 @@ interface PopupParams {
439
468
  type PopupButton =
440
469
  & {
441
470
  /**
442
- * Identifier of the button, 0-64 characters. Set to empty string by default.
443
- * If the button is pressed, its id is returned in the callback and the popupClosed event.
471
+ * Identifier of the button, 0-64 characters. Set to empty string by
472
+ * default. If the button is pressed, its id is returned in the callback
473
+ * and the popupClosed event.
444
474
  */
445
475
  id?: string;
446
476
  /**
447
- * Type of the button. Set to default by default.
448
- * Can be one of these values:
477
+ * Type of the button. Set to default by default. Can be one of these
478
+ * values:
449
479
  * - `default`, a button with the default style,
450
480
  * - `ok`, a button with the localized text “OK”,
451
481
  * - `close`, a button with the localized text “Close”,
452
482
  * - `cancel`, a button with the localized text “Cancel”,
453
- * - `destructive`, a button with a style that indicates a destructive action (e.g. “Remove”, “Delete”, etc.).
483
+ * - `destructive`, a button with a style that indicates a destructive
484
+ * action (e.g. “Remove”, “Delete”, etc.).
454
485
  */
455
486
  type?: "default" | "ok" | "close" | "cancel" | "destructive";
456
487
  /**
457
- * The text to be displayed on the button, 0-64 characters.
458
- * Required if type is default or destructive. Irrelevant for other types.
488
+ * The text to be displayed on the button, 0-64 characters. Required if
489
+ * type is default or destructive. Irrelevant for other types.
459
490
  */
460
491
  text?: string;
461
492
  }
@@ -509,7 +540,8 @@ interface MainButton {
509
540
  /** Current button color. Set to themeParams.button_color by default. */
510
541
  color: string;
511
542
  /**
512
- * Current button text color. Set to themeParams.button_text_color by default.
543
+ * Current button text color. Set to themeParams.button_text_color by
544
+ * default.
513
545
  */
514
546
  textColor: string;
515
547
  /** Shows whether the button is visible. Set to false by default. */
@@ -528,9 +560,9 @@ interface MainButton {
528
560
  /** A method that deletes a previously set handler */
529
561
  offClick(callback: () => void): MainButton;
530
562
  /**
531
- * A method to make the button visible. Note that opening the Web App from the
532
- * attachment menu hides the main button until the user interacts with the
533
- * Web App interface.
563
+ * A method to make the button visible. Note that opening the Web App from
564
+ * the attachment menu hides the main button until the user interacts with
565
+ * the Web App interface.
534
566
  */
535
567
  show(): MainButton;
536
568
  /** A method to hide the button. */
@@ -574,8 +606,8 @@ interface MainButtonParams {
574
606
  }
575
607
 
576
608
  /**
577
- * This object controls the Settings item in the context menu of the Mini App in the
578
- * Telegram interface.
609
+ * This object controls the Settings item in the context menu of the Mini App in
610
+ * the Telegram interface.
579
611
  */
580
612
  interface SettingsButton {
581
613
  /**
@@ -583,19 +615,20 @@ interface SettingsButton {
583
615
  */
584
616
  isVisible: boolean;
585
617
  /**
586
- * **Bot API 7.0+** A method that sets the press event handler for the Settings item in
587
- * the context menu. An alias for
618
+ * **Bot API 7.0+** A method that sets the press event handler for the
619
+ * Settings item in the context menu. An alias for
588
620
  * `Telegram.WebApp.onEvent('settingsButtonClicked', callback)`
589
621
  */
590
622
  onClick(callback: () => void): SettingsButton;
591
623
  /**
592
- * **Bot API 7.0+** A method that removes the press event handler from the Settings item
593
- * in the context menu. An alias for
624
+ * **Bot API 7.0+** A method that removes the press event handler from the
625
+ * Settings item in the context menu. An alias for
594
626
  * `Telegram.WebApp.offEvent('settingsButtonClicked', callback)`
595
627
  */
596
628
  offClick(callback: () => void): SettingsButton;
597
629
  /**
598
- * **Bot API 7.0+** A method to make the Settings item in the context menu visible.
630
+ * **Bot API 7.0+** A method to make the Settings item in the context menu
631
+ * visible.
599
632
  */
600
633
  show(): SettingsButton;
601
634
  /**
@@ -641,13 +674,13 @@ interface HapticFeedback {
641
674
 
642
675
  interface CloudStorage {
643
676
  /**
644
- * A method that stores a value in the cloud storage using the
645
- * specified key.
677
+ * A method that stores a value in the cloud storage using the specified
678
+ * key.
646
679
  *
647
- * @param key The key should contain 1-128 characters, only A-Z, a-z, 0-9,
648
- * _ and - are allowed.
649
- * @param value The value should contain 0-4096 characters. You can store
650
- * up to 1024 keys in the cloud storage.
680
+ * @param key The key should contain 1-128 characters, only A-Z, a-z, 0-9, _
681
+ * and - are allowed.
682
+ * @param value The value should contain 0-4096 characters. You can store up
683
+ * to 1024 keys in the cloud storage.
651
684
  * @param callback If an optional callback parameter was passed, the
652
685
  * callback function will be called. In case of an error, the first argument
653
686
  * will contain the error. In case of success, the first argument will be
@@ -656,15 +689,15 @@ interface CloudStorage {
656
689
  */
657
690
  setItem(key: string, value: string, callback?: CloudStorageSetItemCallback): CloudStorage;
658
691
  /**
659
- * A method that receives a value from the cloud storage using
660
- * the specified key.
692
+ * A method that receives a value from the cloud storage using the specified
693
+ * key.
661
694
  *
662
- * @param key The key should contain 1-128 characters, only A-Z, a-z, 0-9,
663
- * _ and - are allowed.
664
- * @param callback In case of an error, the callback function will
665
- * be called and the first argument will contain the error. In case of
666
- * success, the first argument will be null and the value will be passed
667
- * as the second argument.
695
+ * @param key The key should contain 1-128 characters, only A-Z, a-z, 0-9, _
696
+ * and - are allowed.
697
+ * @param callback In case of an error, the callback function will be called
698
+ * and the first argument will contain the error. In case of success, the
699
+ * first argument will be null and the value will be passed as the second
700
+ * argument.
668
701
  */
669
702
  getItem(key: string, callback?: CloudStorageGetItemCallback): CloudStorage;
670
703
  /**
@@ -674,22 +707,22 @@ interface CloudStorage {
674
707
  * @param key The keys should contain 1-128 characters, only A-Z, a-z, 0-9,
675
708
  * _ and - are allowed.
676
709
  * @param callback In case of an error, the callback? function will be
677
- * called and the first argument will contain the error. In case of
678
- * success, the first argument will be null and the values will be passed
679
- * as the second argument.
710
+ * called and the first argument will contain the error. In case of success,
711
+ * the first argument will be null and the values will be passed as the
712
+ * second argument.
680
713
  */
681
714
  getItems(keys: string[], callback?: CloudStorageGetItemsCallback): CloudStorage;
682
715
  /**
683
716
  * A method that removes a value from the cloud storage using the specified
684
717
  * key.
685
718
  *
686
- * @param key The key should contain 1-128 characters, only A-Z, a-z, 0-9,
687
- * _ and - are allowed.
719
+ * @param key The key should contain 1-128 characters, only A-Z, a-z, 0-9, _
720
+ * and - are allowed.
688
721
  * @param callback If an optional callback parameter was passed, the
689
- * callback function will be called. In case of an error, the first
690
- * argument will contain the error. In case of success, the first
691
- * argument will be null and the second argument will be a boolean
692
- * indicating whether the value was removed.
722
+ * callback function will be called. In case of an error, the first argument
723
+ * will contain the error. In case of success, the first argument will be
724
+ * null and the second argument will be a boolean indicating whether the
725
+ * value was removed.
693
726
  */
694
727
  removeItem(key: string, callback?: CloudStorageRemoveItemCallback): CloudStorage;
695
728
  /**
@@ -699,10 +732,10 @@ interface CloudStorage {
699
732
  * @param key The keys should contain 1-128 characters, only A-Z, a-z, 0-9,
700
733
  * _ and - are allowed.
701
734
  * @param callback If an optional callback parameter was passed, the
702
- * callback function will be called. In case of an error, the first
703
- * argument will contain the error. In case of success, the first
704
- * argument will be null and the second argument will be a boolean
705
- * indicating whether the values were removed.
735
+ * callback function will be called. In case of an error, the first argument
736
+ * will contain the error. In case of success, the first argument will be
737
+ * null and the second argument will be a boolean indicating whether the
738
+ * values were removed.
706
739
  */
707
740
  removeItems(keys: string[], callback?: CloudStorageRemoveItemsCallback): CloudStorage;
708
741
  /**
@@ -724,8 +757,8 @@ type CloudStorageRemoveItemsCallback = (error: string | null, success: null | tr
724
757
  type CloudStorageGetKeysCallback = (error: string | null, keys: null | string[]) => void;
725
758
 
726
759
  /**
727
- * This object controls biometrics on the device. Before the first use
728
- * of this object, it needs to be initialized using the init method.
760
+ * This object controls biometrics on the device. Before the first use of this
761
+ * object, it needs to be initialized using the init method.
729
762
  */
730
763
  interface BiometricManager {
731
764
  /**
@@ -737,7 +770,8 @@ interface BiometricManager {
737
770
  */
738
771
  isBiometricAvailable: boolean;
739
772
  /**
740
- * The type of biometrics currently available on the device. Can be one of these values:
773
+ * The type of biometrics currently available on the device. Can be one of
774
+ * these values:
741
775
  * - finger, fingerprint-based biometrics,
742
776
  * - face, face-based biometrics,
743
777
  * - unknown, biometrics of an unknown type.
@@ -756,30 +790,34 @@ interface BiometricManager {
756
790
  */
757
791
  isBiometricTokenSaved: boolean;
758
792
  /**
759
- * A unique device identifier that can be used to match the token to the device.
793
+ * A unique device identifier that can be used to match the token to the
794
+ * device.
760
795
  */
761
796
  deviceId: string;
762
797
  /**
763
- * A method that initializes the BiometricManager object. It should be called before
764
- * the object's first use. If an optional callback parameter was passed, the callback
765
- * function will be called when the object is initialized.
798
+ * A method that initializes the BiometricManager object. It should be
799
+ * called before the object's first use. If an optional callback parameter
800
+ * was passed, the callback function will be called when the object is
801
+ * initialized.
766
802
  */
767
803
  init: (callback?: () => void) => BiometricManager;
768
804
  /**
769
- * A method that requests permission to use biometrics according to the params
770
- * argument of type BiometricRequestAccessParams. If an optional callback
771
- * parameter was passed, the callback function will be called and the first argument
772
- * will be a boolean indicating whether the user granted access.
805
+ * A method that requests permission to use biometrics according to the
806
+ * params argument of type BiometricRequestAccessParams. If an optional
807
+ * callback parameter was passed, the callback function will be called and
808
+ * the first argument will be a boolean indicating whether the user granted
809
+ * access.
773
810
  */
774
811
  requestAccess: (
775
812
  params: BiometricRequestAccessParams,
776
813
  callback?: BiometricRequestAccessCallback,
777
814
  ) => BiometricManager;
778
815
  /**
779
- * A method that authenticates the user using biometrics according to the params
780
- * argument of type BiometricAuthenticateParams. If an optional callback parameter
781
- * was passed, the callback function will be called and the first argument will be
782
- * a boolean indicating whether the user authenticated successfully.
816
+ * A method that authenticates the user using biometrics according to the
817
+ * params argument of type BiometricAuthenticateParams. If an optional
818
+ * callback parameter was passed, the callback function will be called and
819
+ * the first argument will be a boolean indicating whether the user
820
+ * authenticated successfully.
783
821
  *
784
822
  * If so, the second argument will be a biometric token.
785
823
  */
@@ -788,21 +826,24 @@ interface BiometricManager {
788
826
  callback?: BiometricAuthenticateCallback,
789
827
  ) => BiometricManager;
790
828
  /**
791
- * A method that updates the biometric token in secure storage on the device.
792
- * To remove the token, pass an empty string. If an optional callback parameter
793
- * was passed, the callback function will be called and the first argument will be
794
- * a boolean indicating whether the token was updated.
829
+ * A method that updates the biometric token in secure storage on the
830
+ * device. To remove the token, pass an empty string. If an optional
831
+ * callback parameter was passed, the callback function will be called and
832
+ * the first argument will be a boolean indicating whether the token was
833
+ * updated.
795
834
  */
796
835
  updateBiometricToken: (
797
836
  token: string,
798
837
  callback?: BiometricUpdateBiometricTokenCallback,
799
838
  ) => BiometricManager;
800
839
  /**
801
- * A method that opens the biometric access settings for bots. Useful when you
802
- * need to request biometrics access to users who haven't granted it yet.
840
+ * A method that opens the biometric access settings for bots. Useful when
841
+ * you need to request biometrics access to users who haven't granted it
842
+ * yet.
803
843
  *
804
- * Note that this method can be called only in response to user interaction with
805
- * the Mini App interface (e.g. a click inside the Mini App or on the main button)
844
+ * Note that this method can be called only in response to user interaction
845
+ * with the Mini App interface (e.g. a click inside the Mini App or on the
846
+ * main button)
806
847
  */
807
848
  openSettings: () => BiometricManager;
808
849
  }
@@ -812,24 +853,26 @@ type BiometricAuthenticateCallback = (isAuthenticated: boolean, biometricToken?:
812
853
  type BiometricUpdateBiometricTokenCallback = (applied: boolean) => void;
813
854
 
814
855
  /**
815
- * This object describes the native popup for requesting permission to use biometrics.
856
+ * This object describes the native popup for requesting permission to use
857
+ * biometrics.
816
858
  */
817
859
  interface BiometricRequestAccessParams {
818
860
  /**
819
- * The text to be displayed to a user in the popup describing why the bot needs
820
- * access to biometrics, 0-128 characters.
861
+ * The text to be displayed to a user in the popup describing why the bot
862
+ * needs access to biometrics, 0-128 characters.
821
863
  */
822
864
  reason?: string;
823
865
  }
824
866
 
825
867
  /**
826
- * This object describes the native popup for authenticating the user using biometrics.
868
+ * This object describes the native popup for authenticating the user using
869
+ * biometrics.
827
870
  */
828
871
  interface BiometricAuthenticateParams {
829
872
  /**
830
- * The text to be displayed to a user in the popup describing why you are asking them
831
- * to authenticate and what action you will be taking based on that authentication,
832
- * 0-128 characters.
873
+ * The text to be displayed to a user in the popup describing why you are
874
+ * asking them to authenticate and what action you will be taking based on
875
+ * that authentication, 0-128 characters.
833
876
  */
834
877
  reason?: string;
835
878
  }
@@ -840,16 +883,16 @@ interface BiometricAuthenticateParams {
840
883
  */
841
884
  interface WebAppInitData {
842
885
  /**
843
- * A unique identifier for the Web App session, required for sending messages
844
- * via the answerWebAppQuery method.
886
+ * A unique identifier for the Web App session, required for sending
887
+ * messages via the answerWebAppQuery method.
845
888
  */
846
889
  query_id?: string;
847
890
  /** An object containing data about the current user. */
848
891
  user?: WebAppUser;
849
892
  /**
850
- * An object containing data about the chat partner of the current user in the
851
- * chat where the bot was launched via the attachment menu. Returned only for
852
- * Web Apps launched via the attachment menu.
893
+ * An object containing data about the chat partner of the current user in
894
+ * the chat where the bot was launched via the attachment menu. Returned
895
+ * only for Web Apps launched via the attachment menu.
853
896
  */
854
897
  receiver?: WebAppUser;
855
898
  /**
@@ -859,21 +902,21 @@ interface WebAppInitData {
859
902
  */
860
903
  chat?: WebAppChat;
861
904
  /**
862
- * Type of the chat from which the Web App was opened.
863
- * Can be either “sender” for a private chat with the user opening the link,
864
- * “private”, “group”, “supergroup”, or “channel”.
865
- * Returned only for Web Apps launched from direct links.
905
+ * Type of the chat from which the Web App was opened. Can be either
906
+ * “sender” for a private chat with the user opening the link, “private”,
907
+ * “group”, “supergroup”, or “channel”. Returned only for Web Apps launched
908
+ * from direct links.
866
909
  */
867
910
  chat_type?: "sender" | "private" | "group" | "supergroup" | "channel";
868
911
  /**
869
- * Global identifier, uniquely corresponding to the chat from which the Web App was opened.
870
- * Returned only for Web Apps launched from a direct link.
912
+ * Global identifier, uniquely corresponding to the chat from which the Web
913
+ * App was opened. Returned only for Web Apps launched from a direct link.
871
914
  */
872
915
  chat_instance?: string;
873
916
  /**
874
- * The value of the startattach parameter, passed via link. Only returned for
875
- * Web Apps when launched from the attachment menu via link. The value of the
876
- * start_param parameter will also be passed in the GET-parameter
917
+ * The value of the startattach parameter, passed via link. Only returned
918
+ * for Web Apps when launched from the attachment menu via link. The value
919
+ * of the start_param parameter will also be passed in the GET-parameter
877
920
  * tgWebAppStartParam, so the Web App can load the correct interface right
878
921
  * away.
879
922
  */
@@ -895,11 +938,11 @@ interface WebAppInitData {
895
938
  /** This object contains the data of the Web App user. */
896
939
  interface WebAppUser {
897
940
  /**
898
- * A unique identifier for the user or bot. This number may have more than 32
899
- * significant bits and some programming languages may have difficulty/silent
900
- * defects in interpreting it. It has at most 52 significant bits, so a 64-bit
901
- * integer or a double-precision float type is safe for storing this
902
- * identifier.
941
+ * A unique identifier for the user or bot. This number may have more than
942
+ * 32 significant bits and some programming languages may have
943
+ * difficulty/silent defects in interpreting it. It has at most 52
944
+ * significant bits, so a 64-bit integer or a double-precision float type is
945
+ * safe for storing this identifier.
903
946
  */
904
947
  id: number;
905
948
  /** True, if this user is a bot. Returns in the receiver field only. */
@@ -919,8 +962,8 @@ interface WebAppUser {
919
962
  /** True, if this user allowed the bot to message them. */
920
963
  allows_write_to_pm?: true;
921
964
  /**
922
- * URL of the user’s profile photo. The photo can be in .jpeg or .svg formats.
923
- * Only returned for Web Apps launched from the attachment menu.
965
+ * URL of the user’s profile photo. The photo can be in .jpeg or .svg
966
+ * formats. Only returned for Web Apps launched from the attachment menu.
924
967
  */
925
968
  photo_url?: string;
926
969
  }
@@ -967,16 +1010,17 @@ interface ScanQrPopupParams {
967
1010
  }
968
1011
 
969
1012
  /**
970
- * This object describes contact information shared when requestContact was approved by the user.
1013
+ * This object describes contact information shared when requestContact was
1014
+ * approved by the user.
971
1015
  */
972
1016
  interface RequestContactResponseSent {
973
1017
  /** Status 'sent' indicates that contact information has been shared. */
974
1018
  status: "sent";
975
1019
  /** A status message or result as a string. */
976
1020
  response: string;
977
- /** Contains sensitive information shared upon user consent. WARNING: Data from
978
- * this field should not be trusted. You should only use data from `response` on
979
- * the bot's server and only after it has been validated. */
1021
+ /** Contains sensitive information shared upon user consent. WARNING: Data
1022
+ * from this field should not be trusted. You should only use data from
1023
+ * `response` on the bot's server and only after it has been validated. */
980
1024
  responseUnsafe: {
981
1025
  /** Authorization date for sharing contact information. */
982
1026
  auth_date: string;
@@ -1000,8 +1044,28 @@ interface RequestContactResponseSent {
1000
1044
  * This object only contains a status to indicate the cancellation.
1001
1045
  */
1002
1046
  interface RequestContactResponseCancelled {
1003
- /** Status 'cancelled', indicates that user cancelled the contact share request. */
1047
+ /** Status 'cancelled', indicates that user cancelled the contact share
1048
+ * request. */
1004
1049
  status: "cancelled";
1005
1050
  }
1006
1051
 
1007
1052
  type RequestContactResponse = RequestContactResponseSent | RequestContactResponseCancelled;
1053
+
1054
+ /** This object describes additional sharing settings for the native story
1055
+ * editor. */
1056
+ interface StoryShareParams {
1057
+ /** The caption to be added to the media, 0-200 characters for regular users
1058
+ * and 0-2048 characters for premium subscribers. */
1059
+ text?: string;
1060
+ /** An object that describes a widget link to be included in the story. Note
1061
+ * that only premium subscribers can post stories with links. */
1062
+ widget_link?: StoryWidgetLink;
1063
+ }
1064
+
1065
+ /** This object describes a widget link to be included in the story. */
1066
+ interface StoryWidgetLink {
1067
+ /** The URL to be included in the story. */
1068
+ url: string;
1069
+ /** The name to be displayed for the widget link, 0-48 characters. */
1070
+ name?: string;
1071
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/telegram-web-app",
3
- "version": "7.3.0",
3
+ "version": "7.8.0",
4
4
  "description": "TypeScript definitions for telegram-web-app",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/telegram-web-app",
6
6
  "license": "MIT",
@@ -30,6 +30,6 @@
30
30
  },
31
31
  "scripts": {},
32
32
  "dependencies": {},
33
- "typesPublisherContentHash": "454635b3bca8c32e7748437927a9e968f86ea42b27df2ebebc933218e84373fa",
33
+ "typesPublisherContentHash": "40e04a535cf869443b04b0769fea07cd7a7d391643414bdddc0785e3f10585d3",
34
34
  "typeScriptVersion": "4.8"
35
35
  }