@types/telegram-web-app 7.2.1 → 7.3.1
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.
- telegram-web-app/README.md +1 -1
- telegram-web-app/index.d.ts +334 -268
- telegram-web-app/package.json +3 -3
telegram-web-app/README.md
CHANGED
|
@@ -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:
|
|
11
|
+
* Last updated: Sun, 07 Jul 2024 16:36:47 GMT
|
|
12
12
|
* Dependencies: none
|
|
13
13
|
|
|
14
14
|
# Credits
|
telegram-web-app/index.d.ts
CHANGED
|
@@ -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
|
|
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
|
|
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,
|
|
41
|
-
* the Web App occupies part of the screen and can be expanded to the
|
|
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
|
|
51
|
-
* can “pull” the Web App to its maximum height, while the bot can do
|
|
52
|
-
* by calling the expand() method. As the position of the Web App
|
|
53
|
-
* current height value of the visible area will be updated in
|
|
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
|
|
68
|
-
* can “pull” the Web App to its maximum height, while the bot can do
|
|
69
|
-
* by calling the expand() method. Unlike the value of
|
|
70
|
-
* value of viewportStableHeight does not change as the
|
|
71
|
-
* App changes with user gestures or during animations.
|
|
72
|
-
* viewportStableHeight will be updated after all gestures and
|
|
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
|
|
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
|
|
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
|
|
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
|
-
*
|
|
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,100 +135,82 @@ 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
|
|
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
|
|
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
|
/**
|
|
145
148
|
* A method that sets the app event handler. Check the list of available
|
|
146
149
|
* events.
|
|
147
150
|
*/
|
|
148
|
-
onEvent(
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
): void;
|
|
157
|
-
onEvent(eventType: "
|
|
158
|
-
onEvent(eventType: "
|
|
159
|
-
onEvent(
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
): void;
|
|
163
|
-
onEvent(eventType: "qrTextReceived", eventHandler: (eventData: { data: string }) => void): void;
|
|
164
|
-
onEvent(eventType: "clipboardTextReceived", eventHandler: (eventData: { data: string | null }) => void): void;
|
|
165
|
-
onEvent(
|
|
166
|
-
eventType: "writeAccessRequested",
|
|
167
|
-
eventHandler: (eventData: { status: "allowed" | "cancelled" }) => void,
|
|
168
|
-
): void;
|
|
169
|
-
onEvent(eventType: "contactRequested", eventHandler: (eventData: RequestContactResponse) => void): void;
|
|
170
|
-
onEvent(
|
|
171
|
-
eventType: "biometricAuthRequested",
|
|
172
|
-
eventHandler: (eventData: { isAuthenticated: boolean; biometricToken?: string }) => void,
|
|
173
|
-
): void;
|
|
174
|
-
onEvent(eventType: "biometricTokenUpdated", eventHandler: (eventData: { isUpdated: boolean }) => void): void;
|
|
151
|
+
onEvent(eventType: "themeChanged", eventHandler: ThemeChangedCallback): void;
|
|
152
|
+
onEvent(eventType: "mainButtonClicked", eventHandler: MainButtonClickedCallback): void;
|
|
153
|
+
onEvent(eventType: "backButtonClicked", eventHandler: BackButtonClickedCallback): void;
|
|
154
|
+
onEvent(eventType: "settingsButtonClicked", eventHandler: SettingsButtonClickedCallback): void;
|
|
155
|
+
onEvent(eventType: "popupClosed", eventHandler: PopupClosedCallback): void;
|
|
156
|
+
onEvent(eventType: "viewportChanged", eventHandler: ViewportChangedCallback): void;
|
|
157
|
+
onEvent(eventType: "invoiceClosed", eventHandler: InvoiceClosedCallback): void;
|
|
158
|
+
onEvent(eventType: "qrTextReceived", eventHandler: QrTextReceivedCallback): void;
|
|
159
|
+
onEvent(eventType: "scanQrPopupClosed", eventHandler: ScanQrPopupClosedCallback): void;
|
|
160
|
+
onEvent(eventType: "clipboardTextReceived", eventHandler: ClipboardTextReceivedCallback): void;
|
|
161
|
+
onEvent(eventType: "writeAccessRequested", eventHandler: WriteAccessRequestedCallback): void;
|
|
162
|
+
onEvent(eventType: "contactRequested", eventHandler: ContactRequestedCallback): void;
|
|
163
|
+
onEvent(eventType: "biometricManagerUpdated", eventHandler: BiometricManagerUpdatedCallback): void;
|
|
164
|
+
onEvent(eventType: "biometricAuthRequested", eventHandler: BiometricAuthRequestedCallback): void;
|
|
165
|
+
onEvent(eventType: "biometricTokenUpdated", eventHandler: BiometricTokenUpdatedCallback): void;
|
|
175
166
|
|
|
176
167
|
/** A method that deletes a previously set event handler. */
|
|
177
|
-
offEvent(
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
): void;
|
|
186
|
-
offEvent(eventType: "
|
|
187
|
-
offEvent(eventType: "
|
|
188
|
-
offEvent(
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
): void;
|
|
192
|
-
offEvent(eventType: "qrTextReceived", eventHandler: (eventData: { data: string }) => void): void;
|
|
193
|
-
offEvent(eventType: "clipboardTextReceived", eventHandler: (eventData: { data: string | null }) => void): void;
|
|
194
|
-
offEvent(
|
|
195
|
-
eventType: "writeAccessRequested",
|
|
196
|
-
eventHandler: (eventData: { status: "allowed" | "cancelled" }) => void,
|
|
197
|
-
): void;
|
|
198
|
-
offEvent(eventType: "contactRequested", eventHandler: (eventData: RequestContactResponse) => void): void;
|
|
199
|
-
offEvent(
|
|
200
|
-
eventType: "biometricAuthRequested",
|
|
201
|
-
eventHandler: (eventData: { isAuthenticated: boolean; biometricToken?: string }) => void,
|
|
202
|
-
): void;
|
|
203
|
-
offEvent(eventType: "biometricTokenUpdated", eventHandler: (eventData: { isUpdated: boolean }) => void): void;
|
|
168
|
+
offEvent(eventType: "themeChanged", eventHandler: ThemeChangedCallback): void;
|
|
169
|
+
offEvent(eventType: "mainButtonClicked", eventHandler: MainButtonClickedCallback): void;
|
|
170
|
+
offEvent(eventType: "backButtonClicked", eventHandler: BackButtonClickedCallback): void;
|
|
171
|
+
offEvent(eventType: "settingsButtonClicked", eventHandler: SettingsButtonClickedCallback): void;
|
|
172
|
+
offEvent(eventType: "popupClosed", eventHandler: PopupClosedCallback): void;
|
|
173
|
+
offEvent(eventType: "viewportChanged", eventHandler: ViewportChangedCallback): void;
|
|
174
|
+
offEvent(eventType: "invoiceClosed", eventHandler: InvoiceClosedCallback): void;
|
|
175
|
+
offEvent(eventType: "qrTextReceived", eventHandler: QrTextReceivedCallback): void;
|
|
176
|
+
offEvent(eventType: "scanQrPopupClosed", eventHandler: ScanQrPopupClosedCallback): void;
|
|
177
|
+
offEvent(eventType: "clipboardTextReceived", eventHandler: ClipboardTextReceivedCallback): void;
|
|
178
|
+
offEvent(eventType: "writeAccessRequested", eventHandler: WriteAccessRequestedCallback): void;
|
|
179
|
+
offEvent(eventType: "contactRequested", eventHandler: ContactRequestedCallback): void;
|
|
180
|
+
offEvent(eventType: "biometricManagerUpdated", eventHandler: BiometricManagerUpdatedCallback): void;
|
|
181
|
+
offEvent(eventType: "biometricAuthRequested", eventHandler: BiometricAuthRequestedCallback): void;
|
|
182
|
+
offEvent(eventType: "biometricTokenUpdated", eventHandler: BiometricTokenUpdatedCallback): void;
|
|
204
183
|
|
|
205
184
|
/**
|
|
206
185
|
* A method used to send data to the bot. When this method is called, a
|
|
207
186
|
* service message is sent to the bot containing the data data of the length
|
|
208
|
-
* up to 4096 bytes, and the Web App is closed. See the field web_app_data
|
|
209
|
-
* 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.
|
|
210
189
|
*
|
|
211
|
-
* This method is only available for Web Apps launched via a Keyboard
|
|
190
|
+
* This method is only available for Web Apps launched via a Keyboard
|
|
191
|
+
* button.
|
|
212
192
|
*/
|
|
213
193
|
sendData(data: string): void;
|
|
214
194
|
/**
|
|
215
|
-
* A method that inserts the bot's username and the specified inline query
|
|
216
|
-
* Query may be empty, in which case only
|
|
217
|
-
*
|
|
218
|
-
*
|
|
219
|
-
*
|
|
220
|
-
*
|
|
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.
|
|
221
203
|
*/
|
|
222
204
|
switchInlineQuery(query: string, choose_chat_types?: Array<"users" | "bots" | "groups" | "channels">): void;
|
|
223
205
|
/**
|
|
224
|
-
* A method that opens a link in an external browser.
|
|
225
|
-
*
|
|
226
|
-
*
|
|
227
|
-
*
|
|
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.
|
|
228
210
|
*
|
|
229
|
-
* Note that this method can be called only in response to user interaction
|
|
230
|
-
* the Web App interface (e.g. a click inside the Web App or on the
|
|
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)
|
|
231
214
|
*/
|
|
232
215
|
openLink(url: string, options?: { try_instant_view?: boolean }): void;
|
|
233
216
|
/**
|
|
@@ -246,43 +229,54 @@ interface WebApp {
|
|
|
246
229
|
callback: (url: string, status: "paid" | "cancelled" | "failed" | "pending") => void,
|
|
247
230
|
): void;
|
|
248
231
|
/**
|
|
249
|
-
* A method that shows a native popup described by the params argument of
|
|
250
|
-
* The Web App will receive the event popupClosed when
|
|
251
|
-
*
|
|
252
|
-
*
|
|
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.
|
|
253
237
|
*/
|
|
254
238
|
showPopup(params: PopupParams, callback?: (button_id: string) => void): void;
|
|
255
239
|
/**
|
|
256
|
-
* A method that shows message in a simple alert with a 'Close' button. If
|
|
257
|
-
* parameter was passed, the callback function will be
|
|
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.
|
|
258
243
|
*/
|
|
259
244
|
showAlert(message: string, callback?: () => void): void;
|
|
260
245
|
/**
|
|
261
|
-
* A method that shows message in a simple confirmation window with 'OK' and
|
|
262
|
-
* If an optional callback parameter was passed, the
|
|
263
|
-
*
|
|
264
|
-
* pressed the 'OK'
|
|
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.
|
|
265
251
|
*/
|
|
266
252
|
showConfirm(message: string, callback?: (ok: boolean) => void): void;
|
|
267
253
|
/**
|
|
268
|
-
* A method that shows a native popup for scanning a QR code described by
|
|
269
|
-
*
|
|
270
|
-
*
|
|
271
|
-
*
|
|
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.
|
|
272
263
|
*/
|
|
273
264
|
showScanQrPopup(params: ScanQrPopupParams, callback?: (data: string) => void): void;
|
|
274
265
|
/**
|
|
275
|
-
* A method that closes the native popup for scanning a QR code opened with
|
|
276
|
-
* showScanQrPopup method. Run it if you received valid data in the
|
|
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.
|
|
277
269
|
*/
|
|
278
270
|
closeScanQrPopup(): void;
|
|
279
271
|
/**
|
|
280
|
-
* A method that requests text from the clipboard. The Web App will receive
|
|
281
|
-
* If an optional callback parameter was
|
|
282
|
-
*
|
|
272
|
+
* A method that requests text from the clipboard. The Web App will receive
|
|
273
|
+
* the event clipboardTextReceived. If an optional callback parameter was
|
|
274
|
+
* passed, the callback function will be called and the text from the
|
|
275
|
+
* clipboard will be passed as the first argument.
|
|
283
276
|
*
|
|
284
|
-
* Note: this method can be called only for Web Apps launched from the
|
|
285
|
-
* in response to a user interaction with the Web
|
|
277
|
+
* Note: this method can be called only for Web Apps launched from the
|
|
278
|
+
* attachment menu and only in response to a user interaction with the Web
|
|
279
|
+
* App interface (e.g. a click inside the Web App or on the main button).
|
|
286
280
|
*/
|
|
287
281
|
readTextFromClipboard(callback?: (data: string | null) => void): void;
|
|
288
282
|
/**
|
|
@@ -301,9 +295,9 @@ interface WebApp {
|
|
|
301
295
|
*
|
|
302
296
|
* @param callback If an optional callback parameter was passed, the
|
|
303
297
|
* callback function will be called when the popup is closed and the first
|
|
304
|
-
* argument will be a boolean indicating whether the user shared its
|
|
305
|
-
*
|
|
306
|
-
*
|
|
298
|
+
* argument will be a boolean indicating whether the user shared its phone
|
|
299
|
+
* number. The second argument, contingent upon success, will be an object
|
|
300
|
+
* detailing the shared contact information or a cancellation response.
|
|
307
301
|
*/
|
|
308
302
|
requestContact(
|
|
309
303
|
callback?: (success: boolean, response: RequestContactResponse) => void,
|
|
@@ -312,21 +306,57 @@ interface WebApp {
|
|
|
312
306
|
* A method that informs the Telegram app that the Web App is ready to be
|
|
313
307
|
* displayed. It is recommended to call this method as early as possible, as
|
|
314
308
|
* soon as all essential interface elements are loaded. Once this method is
|
|
315
|
-
* called, the loading placeholder is hidden and the Web App is shown. If
|
|
316
|
-
* method is not called, the placeholder will be hidden only when the
|
|
317
|
-
* fully loaded.
|
|
309
|
+
* called, the loading placeholder is hidden and the Web App is shown. If
|
|
310
|
+
* the method is not called, the placeholder will be hidden only when the
|
|
311
|
+
* page is fully loaded.
|
|
318
312
|
*/
|
|
319
313
|
ready(): void;
|
|
320
314
|
/**
|
|
321
|
-
* A method that expands the Web App to the maximum available height. To
|
|
322
|
-
* out if the Web App is expanded to the maximum height, refer to the
|
|
323
|
-
* the Telegram.WebApp.isExpanded parameter
|
|
315
|
+
* A method that expands the Web App to the maximum available height. To
|
|
316
|
+
* find out if the Web App is expanded to the maximum height, refer to the
|
|
317
|
+
* value of the Telegram.WebApp.isExpanded parameter
|
|
324
318
|
*/
|
|
325
319
|
expand(): void;
|
|
326
320
|
/** A method that closes the Web App. */
|
|
327
321
|
close(): void;
|
|
322
|
+
/**
|
|
323
|
+
* `True`, if vertical swipes to close or minimize the Mini App are enabled.
|
|
324
|
+
* `False`, if vertical swipes to close or minimize the Mini App are
|
|
325
|
+
* disabled. In any case, the user will still be able to minimize and close
|
|
326
|
+
* the Mini App by swiping the Mini App's header.
|
|
327
|
+
*/
|
|
328
|
+
isVerticalSwipesEnabled: boolean;
|
|
329
|
+
/**
|
|
330
|
+
* **Bot API 7.7+** A method that enables vertical swipes to close or
|
|
331
|
+
* minimize the Mini App. For user convenience, it is recommended to always
|
|
332
|
+
* enable swipes unless they conflict with the Mini App's own gestures.
|
|
333
|
+
*/
|
|
334
|
+
enableVerticalSwipes(): void;
|
|
335
|
+
/**
|
|
336
|
+
* **Bot API 7.7+** A method that disables vertical swipes to close or
|
|
337
|
+
* minimize the Mini App. This method is useful if your Mini App uses swipe
|
|
338
|
+
* gestures that may conflict with the gestures for minimizing and closing
|
|
339
|
+
* the app.
|
|
340
|
+
*/
|
|
341
|
+
disableVerticalSwipes(): void;
|
|
328
342
|
}
|
|
329
343
|
|
|
344
|
+
type ThemeChangedCallback = () => void;
|
|
345
|
+
type ViewportChangedCallback = (eventData: { isStateStable: boolean }) => void;
|
|
346
|
+
type MainButtonClickedCallback = () => void;
|
|
347
|
+
type BackButtonClickedCallback = () => void;
|
|
348
|
+
type SettingsButtonClickedCallback = () => void;
|
|
349
|
+
type InvoiceClosedCallback = (eventData: { url: string; status: "paid" | "cancelled" | "failed" | "pending" }) => void;
|
|
350
|
+
type PopupClosedCallback = (eventData: { button_id: string | null }) => void;
|
|
351
|
+
type QrTextReceivedCallback = (eventData: { data: string }) => void;
|
|
352
|
+
type ScanQrPopupClosedCallback = () => void;
|
|
353
|
+
type ClipboardTextReceivedCallback = (eventData: { data: string | null }) => void;
|
|
354
|
+
type WriteAccessRequestedCallback = (eventData: { status: "allowed" | "cancelled" }) => void;
|
|
355
|
+
type ContactRequestedCallback = (eventData: RequestContactResponse) => void;
|
|
356
|
+
type BiometricManagerUpdatedCallback = () => void;
|
|
357
|
+
type BiometricAuthRequestedCallback = (eventData: { isAuthenticated: boolean; biometricToken?: string }) => void;
|
|
358
|
+
type BiometricTokenUpdatedCallback = (eventData: { isUpdated: boolean }) => void;
|
|
359
|
+
|
|
330
360
|
/**
|
|
331
361
|
* Web Apps can adjust the appearance of the interface to match the Telegram
|
|
332
362
|
* user's app in real time. This object contains the user's current theme
|
|
@@ -334,69 +364,77 @@ interface WebApp {
|
|
|
334
364
|
*/
|
|
335
365
|
interface ThemeParams {
|
|
336
366
|
/**
|
|
337
|
-
* Background color in the `#RRGGBB` format.
|
|
338
|
-
*
|
|
367
|
+
* Background color in the `#RRGGBB` format. Also available as the CSS
|
|
368
|
+
* variable `var(--tg-theme-bg-color)`.
|
|
339
369
|
*/
|
|
340
370
|
bg_color?: string;
|
|
341
371
|
/**
|
|
342
|
-
* Main text color in the `#RRGGBB` format.
|
|
343
|
-
*
|
|
372
|
+
* Main text color in the `#RRGGBB` format. Also available as the CSS
|
|
373
|
+
* variable `var(--tg-theme-text-color)`.
|
|
344
374
|
*/
|
|
345
375
|
text_color?: string;
|
|
346
376
|
/**
|
|
347
|
-
* Hint text color in the `#RRGGBB` format.
|
|
348
|
-
*
|
|
377
|
+
* Hint text color in the `#RRGGBB` format. Also available as the CSS
|
|
378
|
+
* variable `var(--tg-theme-hint-color)`.
|
|
349
379
|
*/
|
|
350
380
|
hint_color?: string;
|
|
351
381
|
/**
|
|
352
|
-
* Link color in the `#RRGGBB` format.
|
|
353
|
-
*
|
|
382
|
+
* Link color in the `#RRGGBB` format. Also available as the CSS variable
|
|
383
|
+
* `var(--tg-theme-link-color)`.
|
|
354
384
|
*/
|
|
355
385
|
link_color?: string;
|
|
356
386
|
/**
|
|
357
|
-
* Button color in the `#RRGGBB` format.
|
|
358
|
-
*
|
|
387
|
+
* Button color in the `#RRGGBB` format. Also available as the CSS variable
|
|
388
|
+
* `var(--tg-theme-button-color)`.
|
|
359
389
|
*/
|
|
360
390
|
button_color?: string;
|
|
361
391
|
/**
|
|
362
|
-
* Button text color in the `#RRGGBB` format.
|
|
363
|
-
*
|
|
392
|
+
* Button text color in the `#RRGGBB` format. Also available as the CSS
|
|
393
|
+
* variable `var(--tg-theme-button-text-color)`.
|
|
364
394
|
*/
|
|
365
395
|
button_text_color?: string;
|
|
366
396
|
/**
|
|
367
|
-
* **Bot API 6.1+** Secondary background color in the `#RRGGBB` format.
|
|
368
|
-
*
|
|
397
|
+
* **Bot API 6.1+** Secondary background color in the `#RRGGBB` format. Also
|
|
398
|
+
* available as the CSS variable `var(--tg-theme-secondary-bg-color)`.
|
|
369
399
|
*/
|
|
370
400
|
secondary_bg_color?: string;
|
|
371
401
|
/**
|
|
372
|
-
* **Bot API 7.0+** Header background color in the `#RRGGBB` format.
|
|
373
|
-
*
|
|
402
|
+
* **Bot API 7.0+** Header background color in the `#RRGGBB` format. Also
|
|
403
|
+
* available as the CSS variable `var(--tg-theme-header-bg-color)`.
|
|
374
404
|
*/
|
|
375
405
|
header_bg_color?: string;
|
|
376
406
|
/**
|
|
377
|
-
* **Bot API 7.0+** Accent text color in the `#RRGGBB` format.
|
|
378
|
-
*
|
|
407
|
+
* **Bot API 7.0+** Accent text color in the `#RRGGBB` format. Also
|
|
408
|
+
* available as the CSS variable `var(--tg-theme-accent-text-color)`.
|
|
379
409
|
*/
|
|
380
410
|
accent_text_color?: string;
|
|
381
411
|
/**
|
|
382
|
-
* **Bot API 7.0+** Background color for the section in the `#RRGGBB`
|
|
383
|
-
* recommended to use this in conjunction with
|
|
384
|
-
* Also available as the CSS variable
|
|
412
|
+
* **Bot API 7.0+** Background color for the section in the `#RRGGBB`
|
|
413
|
+
* format. It is recommended to use this in conjunction with
|
|
414
|
+
* *secondary_bg_color*. Also available as the CSS variable
|
|
415
|
+
* `var(--tg-theme-section-bg-color)`.
|
|
385
416
|
*/
|
|
386
417
|
section_bg_color?: string;
|
|
387
418
|
/**
|
|
388
|
-
* **Bot API 7.0+** Header text color for the section in the `#RRGGBB`
|
|
389
|
-
* Also available as the CSS variable
|
|
419
|
+
* **Bot API 7.0+** Header text color for the section in the `#RRGGBB`
|
|
420
|
+
* format. Also available as the CSS variable
|
|
421
|
+
* `var(--tg-theme-section-header-text-color)`.
|
|
390
422
|
*/
|
|
391
423
|
section_header_text_color?: `#${string}`;
|
|
392
424
|
/**
|
|
393
|
-
* **Bot API 7.
|
|
394
|
-
*
|
|
425
|
+
* **Bot API 7.6+** Section separator color in the `#RRGGBB` format. Also
|
|
426
|
+
* available as the CSS variable `var(--tg-theme-section-separator-color)`.
|
|
427
|
+
*/
|
|
428
|
+
section_separator_color?: string;
|
|
429
|
+
/**
|
|
430
|
+
* **Bot API 7.0+** Subtitle text color in the `#RRGGBB` format. Also
|
|
431
|
+
* available as the CSS variable `var(--tg-theme-subtitle-text-color)`.
|
|
395
432
|
*/
|
|
396
433
|
subtitle_text_color?: string;
|
|
397
434
|
/**
|
|
398
|
-
* **Bot API 7.0+** Text color for destructive actions in the `#RRGGBB`
|
|
399
|
-
* Also available as the CSS variable
|
|
435
|
+
* **Bot API 7.0+** Text color for destructive actions in the `#RRGGBB`
|
|
436
|
+
* format. Also available as the CSS variable
|
|
437
|
+
* `var(--tg-theme-destructive-text-color)`.
|
|
400
438
|
*/
|
|
401
439
|
destructive_text_color?: string;
|
|
402
440
|
}
|
|
@@ -414,7 +452,8 @@ interface PopupParams {
|
|
|
414
452
|
*/
|
|
415
453
|
message: string;
|
|
416
454
|
/**
|
|
417
|
-
* List of buttons to be displayed in the popup, 1-3 buttons. Set to
|
|
455
|
+
* List of buttons to be displayed in the popup, 1-3 buttons. Set to
|
|
456
|
+
* [{“type”:“close”}] by default.
|
|
418
457
|
*/
|
|
419
458
|
buttons?: PopupButton[];
|
|
420
459
|
}
|
|
@@ -425,23 +464,25 @@ interface PopupParams {
|
|
|
425
464
|
type PopupButton =
|
|
426
465
|
& {
|
|
427
466
|
/**
|
|
428
|
-
* Identifier of the button, 0-64 characters. Set to empty string by
|
|
429
|
-
* If the button is pressed, its id is returned in the callback
|
|
467
|
+
* Identifier of the button, 0-64 characters. Set to empty string by
|
|
468
|
+
* default. If the button is pressed, its id is returned in the callback
|
|
469
|
+
* and the popupClosed event.
|
|
430
470
|
*/
|
|
431
471
|
id?: string;
|
|
432
472
|
/**
|
|
433
|
-
* Type of the button. Set to default by default.
|
|
434
|
-
*
|
|
473
|
+
* Type of the button. Set to default by default. Can be one of these
|
|
474
|
+
* values:
|
|
435
475
|
* - `default`, a button with the default style,
|
|
436
476
|
* - `ok`, a button with the localized text “OK”,
|
|
437
477
|
* - `close`, a button with the localized text “Close”,
|
|
438
478
|
* - `cancel`, a button with the localized text “Cancel”,
|
|
439
|
-
* - `destructive`, a button with a style that indicates a destructive
|
|
479
|
+
* - `destructive`, a button with a style that indicates a destructive
|
|
480
|
+
* action (e.g. “Remove”, “Delete”, etc.).
|
|
440
481
|
*/
|
|
441
482
|
type?: "default" | "ok" | "close" | "cancel" | "destructive";
|
|
442
483
|
/**
|
|
443
|
-
* The text to be displayed on the button, 0-64 characters.
|
|
444
|
-
*
|
|
484
|
+
* The text to be displayed on the button, 0-64 characters. Required if
|
|
485
|
+
* type is default or destructive. Irrelevant for other types.
|
|
445
486
|
*/
|
|
446
487
|
text?: string;
|
|
447
488
|
}
|
|
@@ -495,7 +536,8 @@ interface MainButton {
|
|
|
495
536
|
/** Current button color. Set to themeParams.button_color by default. */
|
|
496
537
|
color: string;
|
|
497
538
|
/**
|
|
498
|
-
* Current button text color. Set to themeParams.button_text_color by
|
|
539
|
+
* Current button text color. Set to themeParams.button_text_color by
|
|
540
|
+
* default.
|
|
499
541
|
*/
|
|
500
542
|
textColor: string;
|
|
501
543
|
/** Shows whether the button is visible. Set to false by default. */
|
|
@@ -514,9 +556,9 @@ interface MainButton {
|
|
|
514
556
|
/** A method that deletes a previously set handler */
|
|
515
557
|
offClick(callback: () => void): MainButton;
|
|
516
558
|
/**
|
|
517
|
-
* A method to make the button visible. Note that opening the Web App from
|
|
518
|
-
* attachment menu hides the main button until the user interacts with
|
|
519
|
-
* Web App interface.
|
|
559
|
+
* A method to make the button visible. Note that opening the Web App from
|
|
560
|
+
* the attachment menu hides the main button until the user interacts with
|
|
561
|
+
* the Web App interface.
|
|
520
562
|
*/
|
|
521
563
|
show(): MainButton;
|
|
522
564
|
/** A method to hide the button. */
|
|
@@ -560,8 +602,8 @@ interface MainButtonParams {
|
|
|
560
602
|
}
|
|
561
603
|
|
|
562
604
|
/**
|
|
563
|
-
* This object controls the Settings item in the context menu of the Mini App in
|
|
564
|
-
* Telegram interface.
|
|
605
|
+
* This object controls the Settings item in the context menu of the Mini App in
|
|
606
|
+
* the Telegram interface.
|
|
565
607
|
*/
|
|
566
608
|
interface SettingsButton {
|
|
567
609
|
/**
|
|
@@ -569,19 +611,20 @@ interface SettingsButton {
|
|
|
569
611
|
*/
|
|
570
612
|
isVisible: boolean;
|
|
571
613
|
/**
|
|
572
|
-
* **Bot API 7.0+** A method that sets the press event handler for the
|
|
573
|
-
* the context menu. An alias for
|
|
614
|
+
* **Bot API 7.0+** A method that sets the press event handler for the
|
|
615
|
+
* Settings item in the context menu. An alias for
|
|
574
616
|
* `Telegram.WebApp.onEvent('settingsButtonClicked', callback)`
|
|
575
617
|
*/
|
|
576
618
|
onClick(callback: () => void): SettingsButton;
|
|
577
619
|
/**
|
|
578
|
-
* **Bot API 7.0+** A method that removes the press event handler from the
|
|
579
|
-
* in the context menu. An alias for
|
|
620
|
+
* **Bot API 7.0+** A method that removes the press event handler from the
|
|
621
|
+
* Settings item in the context menu. An alias for
|
|
580
622
|
* `Telegram.WebApp.offEvent('settingsButtonClicked', callback)`
|
|
581
623
|
*/
|
|
582
624
|
offClick(callback: () => void): SettingsButton;
|
|
583
625
|
/**
|
|
584
|
-
* **Bot API 7.0+** A method to make the Settings item in the context menu
|
|
626
|
+
* **Bot API 7.0+** A method to make the Settings item in the context menu
|
|
627
|
+
* visible.
|
|
585
628
|
*/
|
|
586
629
|
show(): SettingsButton;
|
|
587
630
|
/**
|
|
@@ -627,32 +670,32 @@ interface HapticFeedback {
|
|
|
627
670
|
|
|
628
671
|
interface CloudStorage {
|
|
629
672
|
/**
|
|
630
|
-
* A method that stores a value in the cloud storage using the
|
|
631
|
-
*
|
|
673
|
+
* A method that stores a value in the cloud storage using the specified
|
|
674
|
+
* key.
|
|
632
675
|
*
|
|
633
|
-
* @param key The key should contain 1-128 characters, only A-Z, a-z, 0-9,
|
|
634
|
-
*
|
|
635
|
-
* @param value The value should contain 0-4096 characters. You can store
|
|
636
|
-
*
|
|
676
|
+
* @param key The key should contain 1-128 characters, only A-Z, a-z, 0-9, _
|
|
677
|
+
* and - are allowed.
|
|
678
|
+
* @param value The value should contain 0-4096 characters. You can store up
|
|
679
|
+
* to 1024 keys in the cloud storage.
|
|
637
680
|
* @param callback If an optional callback parameter was passed, the
|
|
638
681
|
* callback function will be called. In case of an error, the first argument
|
|
639
682
|
* will contain the error. In case of success, the first argument will be
|
|
640
683
|
* null and the second argument will be a boolean indicating whether the
|
|
641
684
|
* value was stored.
|
|
642
685
|
*/
|
|
643
|
-
setItem(key: string, value: string, callback?:
|
|
686
|
+
setItem(key: string, value: string, callback?: CloudStorageSetItemCallback): CloudStorage;
|
|
644
687
|
/**
|
|
645
|
-
* A method that receives a value from the cloud storage using
|
|
646
|
-
*
|
|
688
|
+
* A method that receives a value from the cloud storage using the specified
|
|
689
|
+
* key.
|
|
647
690
|
*
|
|
648
|
-
* @param key The key should contain 1-128 characters, only A-Z, a-z, 0-9,
|
|
649
|
-
*
|
|
650
|
-
* @param callback In case of an error, the callback function will
|
|
651
|
-
*
|
|
652
|
-
*
|
|
653
|
-
*
|
|
691
|
+
* @param key The key should contain 1-128 characters, only A-Z, a-z, 0-9, _
|
|
692
|
+
* and - are allowed.
|
|
693
|
+
* @param callback In case of an error, the callback function will be called
|
|
694
|
+
* and the first argument will contain the error. In case of success, the
|
|
695
|
+
* first argument will be null and the value will be passed as the second
|
|
696
|
+
* argument.
|
|
654
697
|
*/
|
|
655
|
-
getItem(key: string, callback?:
|
|
698
|
+
getItem(key: string, callback?: CloudStorageGetItemCallback): CloudStorage;
|
|
656
699
|
/**
|
|
657
700
|
* A method that receives values from the cloud storage using the specified
|
|
658
701
|
* keys.
|
|
@@ -660,27 +703,24 @@ interface CloudStorage {
|
|
|
660
703
|
* @param key The keys should contain 1-128 characters, only A-Z, a-z, 0-9,
|
|
661
704
|
* _ and - are allowed.
|
|
662
705
|
* @param callback In case of an error, the callback? function will be
|
|
663
|
-
* called and the first argument will contain the error. In case of
|
|
664
|
-
*
|
|
665
|
-
*
|
|
706
|
+
* called and the first argument will contain the error. In case of success,
|
|
707
|
+
* the first argument will be null and the values will be passed as the
|
|
708
|
+
* second argument.
|
|
666
709
|
*/
|
|
667
|
-
getItems(
|
|
668
|
-
keys: string[],
|
|
669
|
-
callback?: (error: string | null, values: null | Record<string, string>) => void,
|
|
670
|
-
): CloudStorage;
|
|
710
|
+
getItems(keys: string[], callback?: CloudStorageGetItemsCallback): CloudStorage;
|
|
671
711
|
/**
|
|
672
712
|
* A method that removes a value from the cloud storage using the specified
|
|
673
713
|
* key.
|
|
674
714
|
*
|
|
675
|
-
* @param key The key should contain 1-128 characters, only A-Z, a-z, 0-9,
|
|
676
|
-
*
|
|
715
|
+
* @param key The key should contain 1-128 characters, only A-Z, a-z, 0-9, _
|
|
716
|
+
* and - are allowed.
|
|
677
717
|
* @param callback If an optional callback parameter was passed, the
|
|
678
|
-
* callback function will be called. In case of an error, the first
|
|
679
|
-
*
|
|
680
|
-
*
|
|
681
|
-
*
|
|
718
|
+
* callback function will be called. In case of an error, the first argument
|
|
719
|
+
* will contain the error. In case of success, the first argument will be
|
|
720
|
+
* null and the second argument will be a boolean indicating whether the
|
|
721
|
+
* value was removed.
|
|
682
722
|
*/
|
|
683
|
-
removeItem(key: string, callback?:
|
|
723
|
+
removeItem(key: string, callback?: CloudStorageRemoveItemCallback): CloudStorage;
|
|
684
724
|
/**
|
|
685
725
|
* A method that removes values from the cloud storage using the specified
|
|
686
726
|
* keys.
|
|
@@ -688,12 +728,12 @@ interface CloudStorage {
|
|
|
688
728
|
* @param key The keys should contain 1-128 characters, only A-Z, a-z, 0-9,
|
|
689
729
|
* _ and - are allowed.
|
|
690
730
|
* @param callback If an optional callback parameter was passed, the
|
|
691
|
-
* callback function will be called. In case of an error, the first
|
|
692
|
-
*
|
|
693
|
-
*
|
|
694
|
-
*
|
|
731
|
+
* callback function will be called. In case of an error, the first argument
|
|
732
|
+
* will contain the error. In case of success, the first argument will be
|
|
733
|
+
* null and the second argument will be a boolean indicating whether the
|
|
734
|
+
* values were removed.
|
|
695
735
|
*/
|
|
696
|
-
removeItems(keys: string[], callback?:
|
|
736
|
+
removeItems(keys: string[], callback?: CloudStorageRemoveItemsCallback): CloudStorage;
|
|
697
737
|
/**
|
|
698
738
|
* A method that receives the list of all keys stored in the cloud storage.
|
|
699
739
|
*
|
|
@@ -702,12 +742,19 @@ interface CloudStorage {
|
|
|
702
742
|
* first argument will be null and the list of keys will be passed as the
|
|
703
743
|
* second argument.
|
|
704
744
|
*/
|
|
705
|
-
getKeys(callback?:
|
|
745
|
+
getKeys(callback?: CloudStorageGetKeysCallback): CloudStorage;
|
|
706
746
|
}
|
|
707
747
|
|
|
748
|
+
type CloudStorageSetItemCallback = (error: string | null, success: null | true) => void;
|
|
749
|
+
type CloudStorageGetItemCallback = (error: string | null, value: null | string) => void;
|
|
750
|
+
type CloudStorageGetItemsCallback = (error: string | null, values: null | Record<string, string>) => void;
|
|
751
|
+
type CloudStorageRemoveItemCallback = (error: string | null, success: null | true) => void;
|
|
752
|
+
type CloudStorageRemoveItemsCallback = (error: string | null, success: null | true) => void;
|
|
753
|
+
type CloudStorageGetKeysCallback = (error: string | null, keys: null | string[]) => void;
|
|
754
|
+
|
|
708
755
|
/**
|
|
709
|
-
* This object controls biometrics on the device. Before the first use
|
|
710
|
-
*
|
|
756
|
+
* This object controls biometrics on the device. Before the first use of this
|
|
757
|
+
* object, it needs to be initialized using the init method.
|
|
711
758
|
*/
|
|
712
759
|
interface BiometricManager {
|
|
713
760
|
/**
|
|
@@ -719,7 +766,8 @@ interface BiometricManager {
|
|
|
719
766
|
*/
|
|
720
767
|
isBiometricAvailable: boolean;
|
|
721
768
|
/**
|
|
722
|
-
* The type of biometrics currently available on the device. Can be one of
|
|
769
|
+
* The type of biometrics currently available on the device. Can be one of
|
|
770
|
+
* these values:
|
|
723
771
|
* - finger, fingerprint-based biometrics,
|
|
724
772
|
* - face, face-based biometrics,
|
|
725
773
|
* - unknown, biometrics of an unknown type.
|
|
@@ -738,73 +786,89 @@ interface BiometricManager {
|
|
|
738
786
|
*/
|
|
739
787
|
isBiometricTokenSaved: boolean;
|
|
740
788
|
/**
|
|
741
|
-
* A unique device identifier that can be used to match the token to the
|
|
789
|
+
* A unique device identifier that can be used to match the token to the
|
|
790
|
+
* device.
|
|
742
791
|
*/
|
|
743
792
|
deviceId: string;
|
|
744
793
|
/**
|
|
745
|
-
* A method that initializes the BiometricManager object. It should be
|
|
746
|
-
* the object's first use. If an optional callback parameter
|
|
747
|
-
* function will be called when the object is
|
|
794
|
+
* A method that initializes the BiometricManager object. It should be
|
|
795
|
+
* called before the object's first use. If an optional callback parameter
|
|
796
|
+
* was passed, the callback function will be called when the object is
|
|
797
|
+
* initialized.
|
|
748
798
|
*/
|
|
749
799
|
init: (callback?: () => void) => BiometricManager;
|
|
750
800
|
/**
|
|
751
|
-
* A method that requests permission to use biometrics according to the
|
|
752
|
-
* argument of type BiometricRequestAccessParams. If an optional
|
|
753
|
-
* parameter was passed, the callback function will be called and
|
|
754
|
-
* will be a boolean indicating whether the user granted
|
|
801
|
+
* A method that requests permission to use biometrics according to the
|
|
802
|
+
* params argument of type BiometricRequestAccessParams. If an optional
|
|
803
|
+
* callback parameter was passed, the callback function will be called and
|
|
804
|
+
* the first argument will be a boolean indicating whether the user granted
|
|
805
|
+
* access.
|
|
755
806
|
*/
|
|
756
807
|
requestAccess: (
|
|
757
808
|
params: BiometricRequestAccessParams,
|
|
758
|
-
callback?:
|
|
809
|
+
callback?: BiometricRequestAccessCallback,
|
|
759
810
|
) => BiometricManager;
|
|
760
811
|
/**
|
|
761
|
-
* A method that authenticates the user using biometrics according to the
|
|
762
|
-
* argument of type BiometricAuthenticateParams. If an optional
|
|
763
|
-
* was passed, the callback function will be called and
|
|
764
|
-
* a boolean indicating whether the user
|
|
812
|
+
* A method that authenticates the user using biometrics according to the
|
|
813
|
+
* params argument of type BiometricAuthenticateParams. If an optional
|
|
814
|
+
* callback parameter was passed, the callback function will be called and
|
|
815
|
+
* the first argument will be a boolean indicating whether the user
|
|
816
|
+
* authenticated successfully.
|
|
765
817
|
*
|
|
766
818
|
* If so, the second argument will be a biometric token.
|
|
767
819
|
*/
|
|
768
820
|
authenticate: (
|
|
769
821
|
params: BiometricAuthenticateParams,
|
|
770
|
-
callback?:
|
|
822
|
+
callback?: BiometricAuthenticateCallback,
|
|
771
823
|
) => BiometricManager;
|
|
772
824
|
/**
|
|
773
|
-
* A method that updates the biometric token in secure storage on the
|
|
774
|
-
* To remove the token, pass an empty string. If an optional
|
|
775
|
-
* was passed, the callback function will be called and
|
|
776
|
-
* a boolean indicating whether the token was
|
|
825
|
+
* A method that updates the biometric token in secure storage on the
|
|
826
|
+
* device. To remove the token, pass an empty string. If an optional
|
|
827
|
+
* callback parameter was passed, the callback function will be called and
|
|
828
|
+
* the first argument will be a boolean indicating whether the token was
|
|
829
|
+
* updated.
|
|
777
830
|
*/
|
|
778
|
-
updateBiometricToken: (
|
|
831
|
+
updateBiometricToken: (
|
|
832
|
+
token: string,
|
|
833
|
+
callback?: BiometricUpdateBiometricTokenCallback,
|
|
834
|
+
) => BiometricManager;
|
|
779
835
|
/**
|
|
780
|
-
* A method that opens the biometric access settings for bots. Useful when
|
|
781
|
-
* need to request biometrics access to users who haven't granted it
|
|
836
|
+
* A method that opens the biometric access settings for bots. Useful when
|
|
837
|
+
* you need to request biometrics access to users who haven't granted it
|
|
838
|
+
* yet.
|
|
782
839
|
*
|
|
783
|
-
* Note that this method can be called only in response to user interaction
|
|
784
|
-
* the Mini App interface (e.g. a click inside the Mini App or on the
|
|
840
|
+
* Note that this method can be called only in response to user interaction
|
|
841
|
+
* with the Mini App interface (e.g. a click inside the Mini App or on the
|
|
842
|
+
* main button)
|
|
785
843
|
*/
|
|
786
844
|
openSettings: () => BiometricManager;
|
|
787
845
|
}
|
|
788
846
|
|
|
847
|
+
type BiometricRequestAccessCallback = (isAccessGranted: boolean) => void;
|
|
848
|
+
type BiometricAuthenticateCallback = (isAuthenticated: boolean, biometricToken?: string) => void;
|
|
849
|
+
type BiometricUpdateBiometricTokenCallback = (applied: boolean) => void;
|
|
850
|
+
|
|
789
851
|
/**
|
|
790
|
-
* This object describes the native popup for requesting permission to use
|
|
852
|
+
* This object describes the native popup for requesting permission to use
|
|
853
|
+
* biometrics.
|
|
791
854
|
*/
|
|
792
855
|
interface BiometricRequestAccessParams {
|
|
793
856
|
/**
|
|
794
|
-
* The text to be displayed to a user in the popup describing why the bot
|
|
795
|
-
* access to biometrics, 0-128 characters.
|
|
857
|
+
* The text to be displayed to a user in the popup describing why the bot
|
|
858
|
+
* needs access to biometrics, 0-128 characters.
|
|
796
859
|
*/
|
|
797
860
|
reason?: string;
|
|
798
861
|
}
|
|
799
862
|
|
|
800
863
|
/**
|
|
801
|
-
* This object describes the native popup for authenticating the user using
|
|
864
|
+
* This object describes the native popup for authenticating the user using
|
|
865
|
+
* biometrics.
|
|
802
866
|
*/
|
|
803
867
|
interface BiometricAuthenticateParams {
|
|
804
868
|
/**
|
|
805
|
-
* The text to be displayed to a user in the popup describing why you are
|
|
806
|
-
* to authenticate and what action you will be taking based on
|
|
807
|
-
* 0-128 characters.
|
|
869
|
+
* The text to be displayed to a user in the popup describing why you are
|
|
870
|
+
* asking them to authenticate and what action you will be taking based on
|
|
871
|
+
* that authentication, 0-128 characters.
|
|
808
872
|
*/
|
|
809
873
|
reason?: string;
|
|
810
874
|
}
|
|
@@ -815,16 +879,16 @@ interface BiometricAuthenticateParams {
|
|
|
815
879
|
*/
|
|
816
880
|
interface WebAppInitData {
|
|
817
881
|
/**
|
|
818
|
-
* A unique identifier for the Web App session, required for sending
|
|
819
|
-
* via the answerWebAppQuery method.
|
|
882
|
+
* A unique identifier for the Web App session, required for sending
|
|
883
|
+
* messages via the answerWebAppQuery method.
|
|
820
884
|
*/
|
|
821
885
|
query_id?: string;
|
|
822
886
|
/** An object containing data about the current user. */
|
|
823
887
|
user?: WebAppUser;
|
|
824
888
|
/**
|
|
825
|
-
* An object containing data about the chat partner of the current user in
|
|
826
|
-
* chat where the bot was launched via the attachment menu. Returned
|
|
827
|
-
* Web Apps launched via the attachment menu.
|
|
889
|
+
* An object containing data about the chat partner of the current user in
|
|
890
|
+
* the chat where the bot was launched via the attachment menu. Returned
|
|
891
|
+
* only for Web Apps launched via the attachment menu.
|
|
828
892
|
*/
|
|
829
893
|
receiver?: WebAppUser;
|
|
830
894
|
/**
|
|
@@ -834,21 +898,21 @@ interface WebAppInitData {
|
|
|
834
898
|
*/
|
|
835
899
|
chat?: WebAppChat;
|
|
836
900
|
/**
|
|
837
|
-
* Type of the chat from which the Web App was opened.
|
|
838
|
-
*
|
|
839
|
-
* “
|
|
840
|
-
*
|
|
901
|
+
* Type of the chat from which the Web App was opened. Can be either
|
|
902
|
+
* “sender” for a private chat with the user opening the link, “private”,
|
|
903
|
+
* “group”, “supergroup”, or “channel”. Returned only for Web Apps launched
|
|
904
|
+
* from direct links.
|
|
841
905
|
*/
|
|
842
906
|
chat_type?: "sender" | "private" | "group" | "supergroup" | "channel";
|
|
843
907
|
/**
|
|
844
|
-
* Global identifier, uniquely corresponding to the chat from which the Web
|
|
845
|
-
* Returned only for Web Apps launched from a direct link.
|
|
908
|
+
* Global identifier, uniquely corresponding to the chat from which the Web
|
|
909
|
+
* App was opened. Returned only for Web Apps launched from a direct link.
|
|
846
910
|
*/
|
|
847
911
|
chat_instance?: string;
|
|
848
912
|
/**
|
|
849
|
-
* The value of the startattach parameter, passed via link. Only returned
|
|
850
|
-
* Web Apps when launched from the attachment menu via link. The value
|
|
851
|
-
* start_param parameter will also be passed in the GET-parameter
|
|
913
|
+
* The value of the startattach parameter, passed via link. Only returned
|
|
914
|
+
* for Web Apps when launched from the attachment menu via link. The value
|
|
915
|
+
* of the start_param parameter will also be passed in the GET-parameter
|
|
852
916
|
* tgWebAppStartParam, so the Web App can load the correct interface right
|
|
853
917
|
* away.
|
|
854
918
|
*/
|
|
@@ -870,11 +934,11 @@ interface WebAppInitData {
|
|
|
870
934
|
/** This object contains the data of the Web App user. */
|
|
871
935
|
interface WebAppUser {
|
|
872
936
|
/**
|
|
873
|
-
* A unique identifier for the user or bot. This number may have more than
|
|
874
|
-
* significant bits and some programming languages may have
|
|
875
|
-
* defects in interpreting it. It has at most 52
|
|
876
|
-
* integer or a double-precision float type is
|
|
877
|
-
* identifier.
|
|
937
|
+
* A unique identifier for the user or bot. This number may have more than
|
|
938
|
+
* 32 significant bits and some programming languages may have
|
|
939
|
+
* difficulty/silent defects in interpreting it. It has at most 52
|
|
940
|
+
* significant bits, so a 64-bit integer or a double-precision float type is
|
|
941
|
+
* safe for storing this identifier.
|
|
878
942
|
*/
|
|
879
943
|
id: number;
|
|
880
944
|
/** True, if this user is a bot. Returns in the receiver field only. */
|
|
@@ -894,8 +958,8 @@ interface WebAppUser {
|
|
|
894
958
|
/** True, if this user allowed the bot to message them. */
|
|
895
959
|
allows_write_to_pm?: true;
|
|
896
960
|
/**
|
|
897
|
-
* URL of the user’s profile photo. The photo can be in .jpeg or .svg
|
|
898
|
-
* Only returned for Web Apps launched from the attachment menu.
|
|
961
|
+
* URL of the user’s profile photo. The photo can be in .jpeg or .svg
|
|
962
|
+
* formats. Only returned for Web Apps launched from the attachment menu.
|
|
899
963
|
*/
|
|
900
964
|
photo_url?: string;
|
|
901
965
|
}
|
|
@@ -942,16 +1006,17 @@ interface ScanQrPopupParams {
|
|
|
942
1006
|
}
|
|
943
1007
|
|
|
944
1008
|
/**
|
|
945
|
-
* This object describes contact information shared when requestContact was
|
|
1009
|
+
* This object describes contact information shared when requestContact was
|
|
1010
|
+
* approved by the user.
|
|
946
1011
|
*/
|
|
947
1012
|
interface RequestContactResponseSent {
|
|
948
1013
|
/** Status 'sent' indicates that contact information has been shared. */
|
|
949
1014
|
status: "sent";
|
|
950
1015
|
/** A status message or result as a string. */
|
|
951
1016
|
response: string;
|
|
952
|
-
/** Contains sensitive information shared upon user consent. WARNING: Data
|
|
953
|
-
* this field should not be trusted. You should only use data from
|
|
954
|
-
* the bot's server and only after it has been validated. */
|
|
1017
|
+
/** Contains sensitive information shared upon user consent. WARNING: Data
|
|
1018
|
+
* from this field should not be trusted. You should only use data from
|
|
1019
|
+
* `response` on the bot's server and only after it has been validated. */
|
|
955
1020
|
responseUnsafe: {
|
|
956
1021
|
/** Authorization date for sharing contact information. */
|
|
957
1022
|
auth_date: string;
|
|
@@ -975,7 +1040,8 @@ interface RequestContactResponseSent {
|
|
|
975
1040
|
* This object only contains a status to indicate the cancellation.
|
|
976
1041
|
*/
|
|
977
1042
|
interface RequestContactResponseCancelled {
|
|
978
|
-
/** Status 'cancelled', indicates that user cancelled the contact share
|
|
1043
|
+
/** Status 'cancelled', indicates that user cancelled the contact share
|
|
1044
|
+
* request. */
|
|
979
1045
|
status: "cancelled";
|
|
980
1046
|
}
|
|
981
1047
|
|
telegram-web-app/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@types/telegram-web-app",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.3.1",
|
|
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": "
|
|
34
|
-
"typeScriptVersion": "4.
|
|
33
|
+
"typesPublisherContentHash": "9fcc5a91b3a09ca84a2f4cad0107ca63464a781a4cc3dfbf0a3eb9aa5d908916",
|
|
34
|
+
"typeScriptVersion": "4.8"
|
|
35
35
|
}
|