@vbotma/bridge 2.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +59 -0
- package/dist/dts/applyPolyfills.d.ts +5 -0
- package/dist/dts/base64-url.d.ts +24 -0
- package/dist/dts/env/hasWebviewProxy.d.ts +10 -0
- package/dist/dts/env/isIframe.d.ts +5 -0
- package/dist/dts/env/isVBMA.d.ts +31 -0
- package/dist/dts/env/mockVBotEnv.d.ts +60 -0
- package/dist/dts/errors.d.ts +27 -0
- package/dist/dts/events/createEmitter.d.ts +58 -0
- package/dist/dts/events/emitEvent.d.ts +33 -0
- package/dist/dts/events/emitter.d.ts +2 -0
- package/dist/dts/events/types/events.d.ts +780 -0
- package/dist/dts/events/types/index.d.ts +3 -0
- package/dist/dts/events/types/listening.d.ts +5 -0
- package/dist/dts/events/types/misc.d.ts +16 -0
- package/dist/dts/globals.d.ts +53 -0
- package/dist/dts/index.d.ts +26 -0
- package/dist/dts/launch-params.d.ts +31 -0
- package/dist/dts/methods/captureSameReq.d.ts +10 -0
- package/dist/dts/methods/createPostEvent.d.ts +30 -0
- package/dist/dts/methods/getReleaseVersion.d.ts +15 -0
- package/dist/dts/methods/postEvent.d.ts +35 -0
- package/dist/dts/methods/postMessage.d.ts +7 -0
- package/dist/dts/methods/supports.d.ts +15 -0
- package/dist/dts/methods/types/custom-method.d.ts +59 -0
- package/dist/dts/methods/types/haptic-feedback.d.ts +40 -0
- package/dist/dts/methods/types/index.d.ts +7 -0
- package/dist/dts/methods/types/methods.d.ts +807 -0
- package/dist/dts/methods/types/misc.d.ts +27 -0
- package/dist/dts/methods/types/notification.d.ts +20 -0
- package/dist/dts/methods/types/popup.d.ts +49 -0
- package/dist/dts/methods/types/utils.d.ts +9 -0
- package/dist/dts/obj-prop-helpers.d.ts +39 -0
- package/dist/dts/start-param.d.ts +52 -0
- package/dist/dts/utils/compareVersions.d.ts +10 -0
- package/dist/dts/utils/invokeCustomMethod.d.ts +34 -0
- package/dist/dts/utils/request.d.ts +102 -0
- package/dist/dts/utils/request2.d.ts +62 -0
- package/dist/index.cjs +4 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.iife.js +4 -0
- package/dist/index.iife.js.map +1 -0
- package/dist/index.js +758 -0
- package/dist/index.js.map +1 -0
- package/package.json +54 -0
|
@@ -0,0 +1,807 @@
|
|
|
1
|
+
import { If, IsNever } from '@vbotma/toolkit';
|
|
2
|
+
import { RGB } from '@vbotma/types';
|
|
3
|
+
import { AnyInvokeCustomMethodParams } from './custom-method.js';
|
|
4
|
+
import { AnyHapticFeedbackParams } from './haptic-feedback.js';
|
|
5
|
+
import { BackgroundColor, BottomBarColor, HeaderColorKey, OpenLinkBrowser, SecondaryButtonPosition, SwitchInlineQueryChatType } from './misc.js';
|
|
6
|
+
import { NotificationParams } from './notification.js';
|
|
7
|
+
import { PopupParams } from './popup.js';
|
|
8
|
+
import { CreateMethodParams } from './utils.js';
|
|
9
|
+
type WithReqId<T = {}> = T & {
|
|
10
|
+
/**
|
|
11
|
+
* Unique request identifier. Should be any unique string to handle the generated event
|
|
12
|
+
* appropriately.
|
|
13
|
+
*/
|
|
14
|
+
req_id: string;
|
|
15
|
+
};
|
|
16
|
+
interface ButtonParams {
|
|
17
|
+
/**
|
|
18
|
+
* Should the button shine.
|
|
19
|
+
* @since 7.10
|
|
20
|
+
*/
|
|
21
|
+
has_shine_effect?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Should the button be displayed.
|
|
24
|
+
*/
|
|
25
|
+
is_visible?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Should the button be enabled.
|
|
28
|
+
*/
|
|
29
|
+
is_active?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Should loader inside the button be displayed. Use this property in case, some
|
|
32
|
+
* operation takes time. This loader will make user notified about it.
|
|
33
|
+
*/
|
|
34
|
+
is_progress_visible?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Text inside the button.
|
|
37
|
+
*/
|
|
38
|
+
text?: string;
|
|
39
|
+
/**
|
|
40
|
+
* The button background color in `#RRGGBB` format.
|
|
41
|
+
*/
|
|
42
|
+
color?: RGB;
|
|
43
|
+
/**
|
|
44
|
+
* The Main Button text color in `#RRGGBB` format.
|
|
45
|
+
*/
|
|
46
|
+
text_color?: RGB;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Describes a list of events and their parameters that could be posted.
|
|
50
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods
|
|
51
|
+
*/
|
|
52
|
+
export interface Methods {
|
|
53
|
+
/**
|
|
54
|
+
* Notifies parent iframe about the current frame is ready. This method is only used in the Web
|
|
55
|
+
* version of Telegram. As a result, Mini App will receive `set_custom_style` event.
|
|
56
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#iframe-ready
|
|
57
|
+
*/
|
|
58
|
+
iframe_ready: CreateMethodParams<{
|
|
59
|
+
/**
|
|
60
|
+
* True, if the current Mini App supports native reloading.
|
|
61
|
+
*/
|
|
62
|
+
reload_supported?: boolean;
|
|
63
|
+
} | undefined>;
|
|
64
|
+
/**
|
|
65
|
+
* Notifies parent iframe about the current iframe is going to reload.
|
|
66
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#iframe-will-reload
|
|
67
|
+
*/
|
|
68
|
+
iframe_will_reload: CreateMethodParams;
|
|
69
|
+
/**
|
|
70
|
+
* Prompts the user to add the Mini App to the home screen. Note that if the device cannot
|
|
71
|
+
* determine the installation status, the event may not be received even if the icon has
|
|
72
|
+
* been added.
|
|
73
|
+
* @since v8.0
|
|
74
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-add-to-home-screen
|
|
75
|
+
*/
|
|
76
|
+
web_app_add_to_home_screen: CreateMethodParams;
|
|
77
|
+
/**
|
|
78
|
+
* Emitted by bot mini apps to ask the client to initialize the biometric authentication manager
|
|
79
|
+
* object for the current bot, emitting a `biometry_info_received` event on completion.
|
|
80
|
+
*
|
|
81
|
+
* This request should just initialize the client-side state, i.e. by checking if biometric
|
|
82
|
+
* authentication is even available or not, it should not ask the user anything.
|
|
83
|
+
* @since v7.2
|
|
84
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-biometry-get-info
|
|
85
|
+
*/
|
|
86
|
+
web_app_biometry_get_info: CreateMethodParams;
|
|
87
|
+
/**
|
|
88
|
+
* Opens the biometric access settings for bots. Useful when you need to request biometrics
|
|
89
|
+
* access to users who haven't granted it yet.
|
|
90
|
+
*
|
|
91
|
+
* _Note that this method can be called only in response to user interaction with the Mini
|
|
92
|
+
* App interface (e.g. a click inside the Mini App or on the main button)_.
|
|
93
|
+
* @since v7.2
|
|
94
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-biometry-open-settings
|
|
95
|
+
*/
|
|
96
|
+
web_app_biometry_open_settings: CreateMethodParams;
|
|
97
|
+
/**
|
|
98
|
+
* Emitted by bot mini apps to ask the user permission to use biometric authentication,
|
|
99
|
+
* emitting a `biometry_info_received` event on completion.
|
|
100
|
+
*
|
|
101
|
+
* This request should not actually prompt biometric authentication, it should just ask the
|
|
102
|
+
* user permission to use them, and a popup should be shown only if the user hasn't already
|
|
103
|
+
* allowed or denied the usage of biometric authentication for the bot associated with the
|
|
104
|
+
* mini app.
|
|
105
|
+
* @since v7.2
|
|
106
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-biometry-request-access
|
|
107
|
+
*/
|
|
108
|
+
web_app_biometry_request_access: CreateMethodParams<{
|
|
109
|
+
/**
|
|
110
|
+
* Reason to request biometry access. Should be at least 1 symbol length, but not
|
|
111
|
+
* more than 128 symbols.
|
|
112
|
+
*/
|
|
113
|
+
reason?: string;
|
|
114
|
+
}>;
|
|
115
|
+
/**
|
|
116
|
+
* Attempts to authenticate a user using biometrics and fetch a previously stored
|
|
117
|
+
* secure token, emitting the `biometry_auth_requested` event on completion, containing either
|
|
118
|
+
* an error, or a decrypted biometric token (or an empty string if no token was configured yet).
|
|
119
|
+
*
|
|
120
|
+
* Should only be used if the `token_saved` field of the `biometry_info_received` event object
|
|
121
|
+
* is equal to true.
|
|
122
|
+
*
|
|
123
|
+
* If a user has previously disallowed the bot from using biometric authentication, this
|
|
124
|
+
* request will immediately fail, emitting an appropriate `biometry_auth_requested` event.
|
|
125
|
+
* @since v7.2
|
|
126
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-biometry-request-auth
|
|
127
|
+
*/
|
|
128
|
+
web_app_biometry_request_auth: CreateMethodParams<{
|
|
129
|
+
/**
|
|
130
|
+
* Reason to request biometry data. Should be at least 1 symbol length, but not more than
|
|
131
|
+
* 128 symbols.
|
|
132
|
+
*/
|
|
133
|
+
reason?: string;
|
|
134
|
+
}>;
|
|
135
|
+
/**
|
|
136
|
+
* Attempts to authenticate using biometrics and store the biometric token
|
|
137
|
+
* securely on a device, emitting a `biometry_token_updated` event on completion.
|
|
138
|
+
*
|
|
139
|
+
* This token will be safely stored by the VBot client and will be associated with the bot
|
|
140
|
+
* that owns the mini app.
|
|
141
|
+
*
|
|
142
|
+
* If the user has previously disallowed the bot from using biometric authentication, this
|
|
143
|
+
* request will immediately fail, emitting an appropriate biometry_token_updated event.
|
|
144
|
+
* @since v7.2
|
|
145
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-biometry-update-token
|
|
146
|
+
*/
|
|
147
|
+
web_app_biometry_update_token: CreateMethodParams<{
|
|
148
|
+
/**
|
|
149
|
+
* Optional string field, containing the reason why the bot is asking to authenticate using
|
|
150
|
+
* biometrics (1-128 chars, used in the prompt).
|
|
151
|
+
*/
|
|
152
|
+
reason?: string;
|
|
153
|
+
/**
|
|
154
|
+
* The new token (string, 0-1024 chars), or an empty string to remove it.
|
|
155
|
+
*/
|
|
156
|
+
token: string;
|
|
157
|
+
}>;
|
|
158
|
+
/**
|
|
159
|
+
* Sends a request to the native VBot application to check if the current mini
|
|
160
|
+
* application is added to the device's home screen.
|
|
161
|
+
* @since v8.0
|
|
162
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-check-home-screen
|
|
163
|
+
*/
|
|
164
|
+
web_app_check_home_screen: CreateMethodParams;
|
|
165
|
+
/**
|
|
166
|
+
* Requests location-related functionality availability state.
|
|
167
|
+
* @since v8.0
|
|
168
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-check-location
|
|
169
|
+
*/
|
|
170
|
+
web_app_check_location: CreateMethodParams;
|
|
171
|
+
/**
|
|
172
|
+
* Closes Mini App.
|
|
173
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-close
|
|
174
|
+
*/
|
|
175
|
+
web_app_close: CreateMethodParams<{
|
|
176
|
+
/**
|
|
177
|
+
* Should the client return to the previous activity.
|
|
178
|
+
* @since v7.6
|
|
179
|
+
*/
|
|
180
|
+
return_back?: boolean;
|
|
181
|
+
} | undefined, 'return_back'>;
|
|
182
|
+
/**
|
|
183
|
+
* Closes a QR scanner. The VBot application creates `scan_qr_popup_closed` event.
|
|
184
|
+
* @since v6.4
|
|
185
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-close-scan-qr-popup
|
|
186
|
+
*/
|
|
187
|
+
web_app_close_scan_qr_popup: CreateMethodParams;
|
|
188
|
+
/**
|
|
189
|
+
* Sends data to the bot. When this method is called, a service message is sent to the bot
|
|
190
|
+
* containing the data of the length up to 4096 bytes. Then, Mini App will be closed.
|
|
191
|
+
*
|
|
192
|
+
* To get more information, take a look at `web_app_data` field in the
|
|
193
|
+
* class [Message](https://core.telegram.org/bots/api#message).
|
|
194
|
+
*
|
|
195
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-data-send
|
|
196
|
+
*/
|
|
197
|
+
web_app_data_send: CreateMethodParams<{
|
|
198
|
+
/**
|
|
199
|
+
* Data to send to a bot. Should not have size of more than 4096 bytes.
|
|
200
|
+
*/
|
|
201
|
+
data: string;
|
|
202
|
+
}>;
|
|
203
|
+
/**
|
|
204
|
+
* Clears all keys previously stored by the bot in the device's local storage.
|
|
205
|
+
* @since 9.0
|
|
206
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-device-storage-clear
|
|
207
|
+
*/
|
|
208
|
+
web_app_device_storage_clear: CreateMethodParams<WithReqId>;
|
|
209
|
+
/**
|
|
210
|
+
* Receives a value from the device's local storage using the specified key.
|
|
211
|
+
* @since 9.0
|
|
212
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-device-storage-get-key
|
|
213
|
+
*/
|
|
214
|
+
web_app_device_storage_get_key: CreateMethodParams<WithReqId<{
|
|
215
|
+
/**
|
|
216
|
+
* A key name to retrieve.
|
|
217
|
+
*/
|
|
218
|
+
key: string;
|
|
219
|
+
}>>;
|
|
220
|
+
/**
|
|
221
|
+
* Stores a value in the device's local storage using the specified key.
|
|
222
|
+
* @since 9.0
|
|
223
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-device-storage-save-key
|
|
224
|
+
*/
|
|
225
|
+
web_app_device_storage_save_key: CreateMethodParams<WithReqId<{
|
|
226
|
+
/**
|
|
227
|
+
* A key to use to store the value.
|
|
228
|
+
*/
|
|
229
|
+
key: string;
|
|
230
|
+
/**
|
|
231
|
+
* A value to store for the specified key. Passing `null` will lead to the key removal.
|
|
232
|
+
*/
|
|
233
|
+
value: string | null;
|
|
234
|
+
}>>;
|
|
235
|
+
/**
|
|
236
|
+
* Exits the fullscreen mode previously requested using the web_app_request_fullscreen method.
|
|
237
|
+
* @since v8.0
|
|
238
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-exit-fullscreen
|
|
239
|
+
*/
|
|
240
|
+
web_app_exit_fullscreen: CreateMethodParams;
|
|
241
|
+
/**
|
|
242
|
+
* Notifies native app that the refresh operation has completed.
|
|
243
|
+
* @since v9.2
|
|
244
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-finish-refresh
|
|
245
|
+
*/
|
|
246
|
+
web_app_finish_refresh: CreateMethodParams;
|
|
247
|
+
/**
|
|
248
|
+
* Expands the Mini App.
|
|
249
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-expand
|
|
250
|
+
*/
|
|
251
|
+
web_app_expand: CreateMethodParams;
|
|
252
|
+
/**
|
|
253
|
+
* Hides the on-screen keyboard, if it is currently visible. Does nothing if the keyboard is
|
|
254
|
+
* not active.
|
|
255
|
+
* @since v9.1
|
|
256
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-hide-keyboard
|
|
257
|
+
*/
|
|
258
|
+
web_app_hide_keyboard: CreateMethodParams;
|
|
259
|
+
/**
|
|
260
|
+
* Invokes custom method.
|
|
261
|
+
* @since v6.9
|
|
262
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-invoke-custom-method
|
|
263
|
+
*/
|
|
264
|
+
web_app_invoke_custom_method: CreateMethodParams<AnyInvokeCustomMethodParams>;
|
|
265
|
+
/**
|
|
266
|
+
* Opens an invoice by its specified slug. More information about invoices in
|
|
267
|
+
* this [documentation](https://core.telegram.org/bots/payments).
|
|
268
|
+
* @since v6.1
|
|
269
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-open-invoice
|
|
270
|
+
*/
|
|
271
|
+
web_app_open_invoice: CreateMethodParams<{
|
|
272
|
+
/**
|
|
273
|
+
* Invoice unique identifier.
|
|
274
|
+
*/
|
|
275
|
+
slug: string;
|
|
276
|
+
}>;
|
|
277
|
+
/**
|
|
278
|
+
* Opens a link in a default browser. The Mini App will not be closed.
|
|
279
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-open-link
|
|
280
|
+
*/
|
|
281
|
+
web_app_open_link: CreateMethodParams<{
|
|
282
|
+
/**
|
|
283
|
+
* URL to be opened by VBot application. Should be a full path with `https` protocol.
|
|
284
|
+
*/
|
|
285
|
+
url: string;
|
|
286
|
+
/**
|
|
287
|
+
* Link will be opened in Instant View mode if possible.
|
|
288
|
+
* @since v6.4
|
|
289
|
+
* @see https://instantview.telegram.org/
|
|
290
|
+
*/
|
|
291
|
+
try_instant_view?: boolean;
|
|
292
|
+
/**
|
|
293
|
+
* A preferred browser to open the link in.
|
|
294
|
+
* @since v7.6
|
|
295
|
+
*/
|
|
296
|
+
try_browser?: OpenLinkBrowser;
|
|
297
|
+
}, 'try_instant_view' | 'try_browser'>;
|
|
298
|
+
/**
|
|
299
|
+
* Opens the location access settings for bots. Useful when you need to request location access
|
|
300
|
+
* from users who haven't granted it yet.
|
|
301
|
+
*
|
|
302
|
+
* Note that this method can be called only in response to user interaction with the Mini App
|
|
303
|
+
* interface (e.g., a click inside the Mini App or on the main button).
|
|
304
|
+
* @since v8.0
|
|
305
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-open-location-settings
|
|
306
|
+
*/
|
|
307
|
+
web_app_open_location_settings: CreateMethodParams;
|
|
308
|
+
/**
|
|
309
|
+
* Opens a new popup. When a user closes the popup, Telegram creates the `popup_closed` event.
|
|
310
|
+
* @since v6.2
|
|
311
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-open-popup
|
|
312
|
+
*/
|
|
313
|
+
web_app_open_popup: CreateMethodParams<PopupParams>;
|
|
314
|
+
/**
|
|
315
|
+
* Opens a QR scanner. When the scanner was closed, the VBot application creates
|
|
316
|
+
* the `scan_qr_popup_closed` event. When the scanner reads QR, Telegram creates the
|
|
317
|
+
* `qr_text_received` event.
|
|
318
|
+
* @since v6.4
|
|
319
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-open-scan-qr-popup
|
|
320
|
+
*/
|
|
321
|
+
web_app_open_scan_qr_popup: CreateMethodParams<{
|
|
322
|
+
/**
|
|
323
|
+
* Text to be displayed in the QR scanner.
|
|
324
|
+
*/
|
|
325
|
+
text?: string;
|
|
326
|
+
}>;
|
|
327
|
+
/**
|
|
328
|
+
* Opens the Telegram link by its pathname and query parameters. The link will be opened in the
|
|
329
|
+
* Telegram app, Mini App will be closed.
|
|
330
|
+
* @since v6.1
|
|
331
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-open-tg-link
|
|
332
|
+
*/
|
|
333
|
+
web_app_open_tg_link: CreateMethodParams<{
|
|
334
|
+
/**
|
|
335
|
+
* Should be a value taken from the link of this format: `https://t.me/{path_full}`. Can
|
|
336
|
+
* additionally contain query parameters.
|
|
337
|
+
*/
|
|
338
|
+
path_full: string;
|
|
339
|
+
}>;
|
|
340
|
+
/**
|
|
341
|
+
* Reads text from the clipboard. The method accepts a request identifier which is used to
|
|
342
|
+
* appropriately retrieve the method execution result from the `clipboard_text_received` event.
|
|
343
|
+
* @since v6.4
|
|
344
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-read-text-from-clipboard
|
|
345
|
+
*/
|
|
346
|
+
web_app_read_text_from_clipboard: CreateMethodParams<WithReqId>;
|
|
347
|
+
/**
|
|
348
|
+
* Notifies Telegram about current application is ready to be shown. This method will make
|
|
349
|
+
* Telegram to remove application loader and display Mini App.
|
|
350
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-ready
|
|
351
|
+
*/
|
|
352
|
+
web_app_ready: CreateMethodParams;
|
|
353
|
+
/**
|
|
354
|
+
* Requests content safe area of the user's phone.
|
|
355
|
+
* @since v8.0
|
|
356
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-request-content-safe-area
|
|
357
|
+
*/
|
|
358
|
+
web_app_request_content_safe_area: CreateMethodParams;
|
|
359
|
+
/**
|
|
360
|
+
* Shows a native popup requesting permission for the bot to manage user's emoji status.
|
|
361
|
+
* @since v8.0
|
|
362
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-request-emoji-status-access
|
|
363
|
+
*/
|
|
364
|
+
web_app_request_emoji_status_access: CreateMethodParams;
|
|
365
|
+
/**
|
|
366
|
+
* Displays a native popup prompting the user to download a file.
|
|
367
|
+
* @since v8.0
|
|
368
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-request-file-download
|
|
369
|
+
*/
|
|
370
|
+
web_app_request_file_download: CreateMethodParams<{
|
|
371
|
+
/**
|
|
372
|
+
* The HTTPS URL of the file to be downloaded.
|
|
373
|
+
*/
|
|
374
|
+
url: string;
|
|
375
|
+
/**
|
|
376
|
+
* The suggested name for the downloaded file.
|
|
377
|
+
*/
|
|
378
|
+
file_name: string;
|
|
379
|
+
}>;
|
|
380
|
+
/**
|
|
381
|
+
* Requests to open the mini app in fullscreen.
|
|
382
|
+
* @since v8.0
|
|
383
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-request-fullscreen
|
|
384
|
+
*/
|
|
385
|
+
web_app_request_fullscreen: CreateMethodParams;
|
|
386
|
+
/**
|
|
387
|
+
* Requests location data.
|
|
388
|
+
* @since v8.0
|
|
389
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-request-location
|
|
390
|
+
*/
|
|
391
|
+
web_app_request_location: CreateMethodParams;
|
|
392
|
+
/**
|
|
393
|
+
* Requests access to current user's phone.
|
|
394
|
+
* @since v6.9
|
|
395
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-request-phone
|
|
396
|
+
*/
|
|
397
|
+
web_app_request_phone: CreateMethodParams;
|
|
398
|
+
/**
|
|
399
|
+
* Requests safe area of the user's phone.
|
|
400
|
+
* @since v8.0
|
|
401
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-request-safe-area
|
|
402
|
+
*/
|
|
403
|
+
web_app_request_safe_area: CreateMethodParams;
|
|
404
|
+
/**
|
|
405
|
+
* Requests access to device storage to select files or folders.
|
|
406
|
+
* The native app will show a file/folder picker and emit storage_access_granted
|
|
407
|
+
* or storage_access_denied event.
|
|
408
|
+
* @since v9.3
|
|
409
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-request-storage-access
|
|
410
|
+
*/
|
|
411
|
+
web_app_request_storage_access: CreateMethodParams<{
|
|
412
|
+
/**
|
|
413
|
+
* Type of storage access to request.
|
|
414
|
+
* - 'file': Select one or multiple files
|
|
415
|
+
* - 'folder': Select a folder
|
|
416
|
+
*/
|
|
417
|
+
access_type: 'file' | 'folder';
|
|
418
|
+
/**
|
|
419
|
+
* Whether to allow multiple file selection (only applies when access_type is 'file').
|
|
420
|
+
* @default false
|
|
421
|
+
*/
|
|
422
|
+
multiple?: boolean;
|
|
423
|
+
/**
|
|
424
|
+
* MIME types to filter files (e.g., ['image/*', 'application/pdf']).
|
|
425
|
+
* Only applies when access_type is 'file'.
|
|
426
|
+
*/
|
|
427
|
+
accept?: string[];
|
|
428
|
+
/**
|
|
429
|
+
* Maximum file size in bytes.
|
|
430
|
+
* Files larger than this will be rejected.
|
|
431
|
+
* Only applies when access_type is 'file'.
|
|
432
|
+
* @default undefined (no limit)
|
|
433
|
+
*/
|
|
434
|
+
max_file_size?: number;
|
|
435
|
+
/**
|
|
436
|
+
* Whether to read file content as base64.
|
|
437
|
+
* If true, the event will include file content.
|
|
438
|
+
* @default false
|
|
439
|
+
*/
|
|
440
|
+
read_content?: boolean;
|
|
441
|
+
}>;
|
|
442
|
+
/**
|
|
443
|
+
* Requests current theme from Telegram. As a result, Telegram will create `theme_changed` event.
|
|
444
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-request-theme
|
|
445
|
+
*/
|
|
446
|
+
web_app_request_theme: CreateMethodParams;
|
|
447
|
+
/**
|
|
448
|
+
* Requests current viewport information from Telegram. As a result, Telegram will create
|
|
449
|
+
* `viewport_changed` event.
|
|
450
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-request-viewport
|
|
451
|
+
*/
|
|
452
|
+
web_app_request_viewport: CreateMethodParams;
|
|
453
|
+
/**
|
|
454
|
+
* Requests write message access to the current user.
|
|
455
|
+
* @since v6.9
|
|
456
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-rqeuest-write-access
|
|
457
|
+
*/
|
|
458
|
+
web_app_request_write_access: CreateMethodParams;
|
|
459
|
+
/**
|
|
460
|
+
* Clears all keys previously stored by the bot in the device's secure storage.
|
|
461
|
+
* @since 9.0
|
|
462
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-secure-storage-clear
|
|
463
|
+
*/
|
|
464
|
+
web_app_secure_storage_clear: CreateMethodParams<WithReqId>;
|
|
465
|
+
/**
|
|
466
|
+
* Receives a value from the device's secure storage using the specified key.
|
|
467
|
+
* @since 9.0
|
|
468
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-secure-storage-get-key
|
|
469
|
+
*/
|
|
470
|
+
web_app_secure_storage_get_key: CreateMethodParams<WithReqId<{
|
|
471
|
+
/**
|
|
472
|
+
* A key to use to store the value.
|
|
473
|
+
*/
|
|
474
|
+
key: string;
|
|
475
|
+
}>>;
|
|
476
|
+
/**
|
|
477
|
+
* Attempts to restore a key that previously existed on the current device. When called, the user
|
|
478
|
+
* will be asked for permission to restore the value.
|
|
479
|
+
* @since 9.0
|
|
480
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-secure-storage-restore-key
|
|
481
|
+
*/
|
|
482
|
+
web_app_secure_storage_restore_key: CreateMethodParams<WithReqId<{
|
|
483
|
+
/**
|
|
484
|
+
* A key to use to restore the value.
|
|
485
|
+
*/
|
|
486
|
+
key: string;
|
|
487
|
+
}>>;
|
|
488
|
+
/**
|
|
489
|
+
* Stores a value in the device's secure storage using the specified key.
|
|
490
|
+
* @since 9.0
|
|
491
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-secure-storage-save-key
|
|
492
|
+
*/
|
|
493
|
+
web_app_secure_storage_save_key: CreateMethodParams<WithReqId<{
|
|
494
|
+
/**
|
|
495
|
+
* A key to use to store the value.
|
|
496
|
+
*/
|
|
497
|
+
key: string;
|
|
498
|
+
/**
|
|
499
|
+
* A value to store for the specified key. Passing `null` will lead to the key removal.
|
|
500
|
+
*/
|
|
501
|
+
value: string | null;
|
|
502
|
+
}>>;
|
|
503
|
+
/**
|
|
504
|
+
* Sends a notification to the native app.
|
|
505
|
+
* @since v9.2
|
|
506
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-send-notification
|
|
507
|
+
*/
|
|
508
|
+
web_app_send_notification: CreateMethodParams<NotificationParams>;
|
|
509
|
+
/**
|
|
510
|
+
* Opens a dialog allowing the user to share a message provided by the bot.
|
|
511
|
+
* @since v8.0
|
|
512
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-send-prepared-message
|
|
513
|
+
*/
|
|
514
|
+
web_app_send_prepared_message: CreateMethodParams<{
|
|
515
|
+
/**
|
|
516
|
+
* Identifier of the message
|
|
517
|
+
* ([PreparedInlineMessage](https://core.telegram.org/bots/api#preparedinlinemessage))
|
|
518
|
+
* previously obtained via the Bot API method
|
|
519
|
+
* [savePreparedInlineMessage](https://core.telegram.org/bots/api#savepreparedinlinemessage).
|
|
520
|
+
*/
|
|
521
|
+
id: string;
|
|
522
|
+
}>;
|
|
523
|
+
/**
|
|
524
|
+
* Updates the Mini App background color.
|
|
525
|
+
* @since v6.1
|
|
526
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-set-background-color
|
|
527
|
+
*/
|
|
528
|
+
web_app_set_background_color: CreateMethodParams<{
|
|
529
|
+
/**
|
|
530
|
+
* Color to set.
|
|
531
|
+
*/
|
|
532
|
+
color: BackgroundColor;
|
|
533
|
+
}>;
|
|
534
|
+
/**
|
|
535
|
+
* Updates the mini app bottom bar background color.
|
|
536
|
+
* @since v7.10
|
|
537
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-set-bottom-bar-color
|
|
538
|
+
*/
|
|
539
|
+
web_app_set_bottom_bar_color: CreateMethodParams<{
|
|
540
|
+
/**
|
|
541
|
+
* Color to set.
|
|
542
|
+
*/
|
|
543
|
+
color: BottomBarColor;
|
|
544
|
+
}>;
|
|
545
|
+
/**
|
|
546
|
+
* Opens a dialog allowing the user to set the specified custom emoji as their status.
|
|
547
|
+
* @since v8.0
|
|
548
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-set-emoji-status
|
|
549
|
+
*/
|
|
550
|
+
web_app_set_emoji_status: CreateMethodParams<{
|
|
551
|
+
/**
|
|
552
|
+
* Custom emoji identifier to set.
|
|
553
|
+
*/
|
|
554
|
+
custom_emoji_id: string;
|
|
555
|
+
/**
|
|
556
|
+
* The status expiration time in seconds.
|
|
557
|
+
*/
|
|
558
|
+
duration?: number;
|
|
559
|
+
}>;
|
|
560
|
+
/**
|
|
561
|
+
* Updates the Mini App header color.
|
|
562
|
+
* @since v6.1
|
|
563
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-set-header-color
|
|
564
|
+
*/
|
|
565
|
+
web_app_set_header_color: CreateMethodParams<{
|
|
566
|
+
/**
|
|
567
|
+
* The Mini App header color key.
|
|
568
|
+
*/
|
|
569
|
+
color_key: HeaderColorKey;
|
|
570
|
+
} | {
|
|
571
|
+
/**
|
|
572
|
+
* Color in RGB format.
|
|
573
|
+
* @since v6.9
|
|
574
|
+
*/
|
|
575
|
+
color: RGB;
|
|
576
|
+
}, 'color'>;
|
|
577
|
+
/**
|
|
578
|
+
* Updates the Back Button settings.
|
|
579
|
+
* @since v6.1
|
|
580
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-setup-back-button
|
|
581
|
+
*/
|
|
582
|
+
web_app_setup_back_button: CreateMethodParams<{
|
|
583
|
+
/**
|
|
584
|
+
* Should the Back Button be visible.
|
|
585
|
+
*/
|
|
586
|
+
is_visible: boolean;
|
|
587
|
+
}>;
|
|
588
|
+
/**
|
|
589
|
+
* Updates current closing behavior.
|
|
590
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-setup-closing-behavior
|
|
591
|
+
*/
|
|
592
|
+
web_app_setup_closing_behavior: CreateMethodParams<{
|
|
593
|
+
/**
|
|
594
|
+
* Will user be prompted in case, an application is going to be closed.
|
|
595
|
+
*/
|
|
596
|
+
need_confirmation: boolean;
|
|
597
|
+
}>;
|
|
598
|
+
/**
|
|
599
|
+
* Updates the Main Button settings.
|
|
600
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-setup-main-button
|
|
601
|
+
*/
|
|
602
|
+
web_app_setup_main_button: CreateMethodParams<ButtonParams, 'has_shine_effect'>;
|
|
603
|
+
/**
|
|
604
|
+
* Updates the secondary button settings.
|
|
605
|
+
* @since v7.10
|
|
606
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-setup-secondary-button
|
|
607
|
+
*/
|
|
608
|
+
web_app_setup_secondary_button: CreateMethodParams<ButtonParams & {
|
|
609
|
+
/**
|
|
610
|
+
* Position of the secondary button. It applies only if both the main and secondary buttons
|
|
611
|
+
* are visible.
|
|
612
|
+
*
|
|
613
|
+
* Supported values:
|
|
614
|
+
* - `left`, displayed to the left of the main button.
|
|
615
|
+
* - `right`, displayed to the right of the main button.
|
|
616
|
+
* - `top`, displayed above the main button.
|
|
617
|
+
* - `bottom`, displayed below the main button.
|
|
618
|
+
*/
|
|
619
|
+
position?: SecondaryButtonPosition;
|
|
620
|
+
}>;
|
|
621
|
+
/**
|
|
622
|
+
* Updates the current state of the Settings Button.
|
|
623
|
+
* @since v6.10
|
|
624
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-setup-settings-button
|
|
625
|
+
*/
|
|
626
|
+
web_app_setup_settings_button: CreateMethodParams<{
|
|
627
|
+
/**
|
|
628
|
+
* Should the Settings Button be displayed.
|
|
629
|
+
*/
|
|
630
|
+
is_visible: boolean;
|
|
631
|
+
}>;
|
|
632
|
+
/**
|
|
633
|
+
* Changes swipe behavior.
|
|
634
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-setup-swipe-behavior
|
|
635
|
+
* @since v7.7
|
|
636
|
+
*/
|
|
637
|
+
web_app_setup_swipe_behavior: CreateMethodParams<{
|
|
638
|
+
allow_vertical_swipe: boolean;
|
|
639
|
+
}>;
|
|
640
|
+
/**
|
|
641
|
+
* A method that opens the native story editor.
|
|
642
|
+
* @since v7.8
|
|
643
|
+
*/
|
|
644
|
+
web_app_share_to_story: CreateMethodParams<{
|
|
645
|
+
/**
|
|
646
|
+
* A media URL which will be used as a background for a created story.
|
|
647
|
+
*/
|
|
648
|
+
media_url: string;
|
|
649
|
+
/**
|
|
650
|
+
* The caption to be added to the media.
|
|
651
|
+
* 0-200 characters for regular users and 0-2048 characters for premium subscribers.
|
|
652
|
+
* @see https://telegram.org/faq_premium#telegram-premium
|
|
653
|
+
*/
|
|
654
|
+
text?: string;
|
|
655
|
+
/**
|
|
656
|
+
* An object that describes a widget link to be included in the story.
|
|
657
|
+
* Note that only premium subscribers can post stories with links.
|
|
658
|
+
* @see https://telegram.org/faq_premium#telegram-premium
|
|
659
|
+
*/
|
|
660
|
+
widget_link?: {
|
|
661
|
+
/**
|
|
662
|
+
* The URL to be included in the story.
|
|
663
|
+
*/
|
|
664
|
+
url: string;
|
|
665
|
+
/**
|
|
666
|
+
* The name to be displayed for the widget link, 0-48 characters.
|
|
667
|
+
*/
|
|
668
|
+
name?: string;
|
|
669
|
+
};
|
|
670
|
+
}>;
|
|
671
|
+
/**
|
|
672
|
+
* Starts tracking accelerometer data.
|
|
673
|
+
* @since v8.0
|
|
674
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-start-accelerometer
|
|
675
|
+
*/
|
|
676
|
+
web_app_start_accelerometer: CreateMethodParams<{
|
|
677
|
+
/**
|
|
678
|
+
* The refresh rate in milliseconds, with acceptable values ranging from 20 to 1000.
|
|
679
|
+
* Note that refresh_rate may not be supported on all platforms, so the actual tracking
|
|
680
|
+
* frequency may differ from the specified value.
|
|
681
|
+
*/
|
|
682
|
+
refresh_rate: number;
|
|
683
|
+
}>;
|
|
684
|
+
/**
|
|
685
|
+
* Starts tracking device orientation data.
|
|
686
|
+
* @since v8.0
|
|
687
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-start-device-orientation
|
|
688
|
+
*/
|
|
689
|
+
web_app_start_device_orientation: CreateMethodParams<{
|
|
690
|
+
/**
|
|
691
|
+
* The refresh rate in milliseconds, with acceptable values ranging from 20 to 1000.
|
|
692
|
+
* Note that refresh_rate may not be supported on all platforms, so the actual tracking
|
|
693
|
+
* frequency may differ from the specified value.
|
|
694
|
+
*/
|
|
695
|
+
refresh_rate: number;
|
|
696
|
+
/**
|
|
697
|
+
* Pass true to receive absolute orientation data, allowing you to determine the device's
|
|
698
|
+
* attitude relative to magnetic north. Use this option if implementing features like a
|
|
699
|
+
* compass in your app. If relative data is sufficient, pass false.
|
|
700
|
+
*
|
|
701
|
+
* Keep in mind that some devices may not support absolute orientation data. In such cases,
|
|
702
|
+
* you will receive relative data even if need_absolute=true is passed.
|
|
703
|
+
*/
|
|
704
|
+
need_absolute?: boolean;
|
|
705
|
+
}>;
|
|
706
|
+
/**
|
|
707
|
+
* Starts tracking gyroscope data.
|
|
708
|
+
* @since v8.0
|
|
709
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-start-gyroscope
|
|
710
|
+
*/
|
|
711
|
+
web_app_start_gyroscope: CreateMethodParams<{
|
|
712
|
+
/**
|
|
713
|
+
* The refresh rate in milliseconds, with acceptable values ranging from 20 to 1000.
|
|
714
|
+
* Note that refresh_rate may not be supported on all platforms, so the actual tracking
|
|
715
|
+
* frequency may differ from the specified value.
|
|
716
|
+
*/
|
|
717
|
+
refresh_rate: number;
|
|
718
|
+
}>;
|
|
719
|
+
/**
|
|
720
|
+
* Stops tracking accelerometer data.
|
|
721
|
+
* @since v8.0
|
|
722
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-stop-accelerometer
|
|
723
|
+
*/
|
|
724
|
+
web_app_stop_accelerometer: CreateMethodParams;
|
|
725
|
+
/**
|
|
726
|
+
* Stops tracking device orientation data.
|
|
727
|
+
* @since v8.0
|
|
728
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-stop-device-orientation
|
|
729
|
+
*/
|
|
730
|
+
web_app_stop_device_orientation: CreateMethodParams;
|
|
731
|
+
/**
|
|
732
|
+
* Stops tracking gyroscope data.
|
|
733
|
+
* @since v8.0
|
|
734
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-stop-gyroscope
|
|
735
|
+
*/
|
|
736
|
+
web_app_stop_gyroscope: CreateMethodParams;
|
|
737
|
+
/**
|
|
738
|
+
* Inserts the bot's username and the specified inline query in the current chat's input field.
|
|
739
|
+
* Query may be empty, in which case only the bot's username will be inserted. The client prompts
|
|
740
|
+
* the user to choose a specific chat, then opens that chat and inserts the bot's username and
|
|
741
|
+
* the specified inline query in the input field.
|
|
742
|
+
* @since v6.7
|
|
743
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-switch-inline-query
|
|
744
|
+
*/
|
|
745
|
+
web_app_switch_inline_query: CreateMethodParams<{
|
|
746
|
+
/**
|
|
747
|
+
* Text which should be inserted in the input after the current bot name. Max length is
|
|
748
|
+
* 256 symbols.
|
|
749
|
+
*/
|
|
750
|
+
query: string;
|
|
751
|
+
/**
|
|
752
|
+
* List of chat types which could be chosen to send the message. Could be empty list.
|
|
753
|
+
*/
|
|
754
|
+
chat_types: SwitchInlineQueryChatType[];
|
|
755
|
+
}>;
|
|
756
|
+
/**
|
|
757
|
+
* Locks the Mini App’s orientation to its current mode (either portrait or landscape). Once
|
|
758
|
+
* locked, the orientation remains fixed, regardless of device rotation. This is useful if a
|
|
759
|
+
* stable orientation is needed during specific interactions.
|
|
760
|
+
* @since v8.0
|
|
761
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-toggle-orientation-lock
|
|
762
|
+
*/
|
|
763
|
+
web_app_toggle_orientation_lock: CreateMethodParams<{
|
|
764
|
+
locked: boolean;
|
|
765
|
+
}>;
|
|
766
|
+
/**
|
|
767
|
+
* Generates haptic feedback event.
|
|
768
|
+
* @since v6.1
|
|
769
|
+
* @see https://docs.vbot-mini-apps.com/platform/methods#web-app-trigger-haptic-feedback
|
|
770
|
+
*/
|
|
771
|
+
web_app_trigger_haptic_feedback: CreateMethodParams<AnyHapticFeedbackParams>;
|
|
772
|
+
}
|
|
773
|
+
/**
|
|
774
|
+
* Mini Apps method name.
|
|
775
|
+
*/
|
|
776
|
+
export type MethodName = keyof Methods;
|
|
777
|
+
/**
|
|
778
|
+
* Parameters of the specified Mini Apps method.
|
|
779
|
+
*/
|
|
780
|
+
export type MethodParams<M extends MethodName> = Methods[M]['params'];
|
|
781
|
+
/**
|
|
782
|
+
* Methods with optional parameters.
|
|
783
|
+
*/
|
|
784
|
+
export type MethodNameWithOptionalParams = {
|
|
785
|
+
[M in MethodName]: undefined extends MethodParams<M> ? M : never;
|
|
786
|
+
}[MethodName];
|
|
787
|
+
/**
|
|
788
|
+
* Methods without parameters.
|
|
789
|
+
*/
|
|
790
|
+
export type MethodNameWithoutParams = {
|
|
791
|
+
[M in MethodName]: If<IsNever<MethodParams<M>>, M, never>;
|
|
792
|
+
}[MethodName];
|
|
793
|
+
/**
|
|
794
|
+
* Methods with parameters.
|
|
795
|
+
*/
|
|
796
|
+
export type MethodNameWithRequiredParams = Exclude<MethodName, MethodNameWithoutParams | MethodNameWithOptionalParams>;
|
|
797
|
+
/**
|
|
798
|
+
* Method names which have versioned params.
|
|
799
|
+
*/
|
|
800
|
+
export type MethodNameWithVersionedParams = {
|
|
801
|
+
[M in MethodName]: If<IsNever<Methods[M]['versionedParams']>, never, M>;
|
|
802
|
+
}[MethodName];
|
|
803
|
+
/**
|
|
804
|
+
* Method parameters which appear only in the specific VBot Mini Apps version.
|
|
805
|
+
*/
|
|
806
|
+
export type MethodVersionedParams<M extends MethodNameWithVersionedParams> = Methods[M]['versionedParams'];
|
|
807
|
+
export {};
|