@types/telegram-web-app 7.0.0 → 7.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- telegram-web-app/README.md +1 -1
- telegram-web-app/index.d.ts +177 -6
- 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: Mon, 01 Apr 2024 17:35:38 GMT
|
|
12
12
|
* Dependencies: none
|
|
13
13
|
|
|
14
14
|
# Credits
|
telegram-web-app/index.d.ts
CHANGED
|
@@ -113,6 +113,10 @@ interface WebApp {
|
|
|
113
113
|
* An object for controlling cloud storage.
|
|
114
114
|
*/
|
|
115
115
|
CloudStorage: CloudStorage;
|
|
116
|
+
/**
|
|
117
|
+
* An object for controlling biometrics on the device.
|
|
118
|
+
*/
|
|
119
|
+
BiometricManager: BiometricManager;
|
|
116
120
|
/**
|
|
117
121
|
* Returns true if the user's app supports a version of the Bot API that is
|
|
118
122
|
* equal to or higher than the version passed as the parameter.
|
|
@@ -142,7 +146,12 @@ interface WebApp {
|
|
|
142
146
|
* events.
|
|
143
147
|
*/
|
|
144
148
|
onEvent(
|
|
145
|
-
eventType:
|
|
149
|
+
eventType:
|
|
150
|
+
| "themeChanged"
|
|
151
|
+
| "mainButtonClicked"
|
|
152
|
+
| "backButtonClicked"
|
|
153
|
+
| "settingsButtonClicked"
|
|
154
|
+
| "biometricManagerUpdated",
|
|
146
155
|
eventHandler: () => void,
|
|
147
156
|
): void;
|
|
148
157
|
onEvent(eventType: "popupClosed", eventHandler: (eventData: { button_id: string | null }) => void): void;
|
|
@@ -157,11 +166,21 @@ interface WebApp {
|
|
|
157
166
|
eventType: "writeAccessRequested",
|
|
158
167
|
eventHandler: (eventData: { status: "allowed" | "cancelled" }) => void,
|
|
159
168
|
): void;
|
|
160
|
-
onEvent(eventType: "contactRequested", eventHandler: (eventData:
|
|
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;
|
|
161
175
|
|
|
162
176
|
/** A method that deletes a previously set event handler. */
|
|
163
177
|
offEvent(
|
|
164
|
-
eventType:
|
|
178
|
+
eventType:
|
|
179
|
+
| "themeChanged"
|
|
180
|
+
| "mainButtonClicked"
|
|
181
|
+
| "backButtonClicked"
|
|
182
|
+
| "settingsButtonClicked"
|
|
183
|
+
| "biometricManagerUpdated",
|
|
165
184
|
eventHandler: () => void,
|
|
166
185
|
): void;
|
|
167
186
|
offEvent(eventType: "popupClosed", eventHandler: (eventData: { button_id: string | null }) => void): void;
|
|
@@ -176,7 +195,12 @@ interface WebApp {
|
|
|
176
195
|
eventType: "writeAccessRequested",
|
|
177
196
|
eventHandler: (eventData: { status: "allowed" | "cancelled" }) => void,
|
|
178
197
|
): void;
|
|
179
|
-
offEvent(eventType: "contactRequested", eventHandler: (eventData:
|
|
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;
|
|
180
204
|
|
|
181
205
|
/**
|
|
182
206
|
* A method used to send data to the bot. When this method is called, a
|
|
@@ -278,9 +302,12 @@ interface WebApp {
|
|
|
278
302
|
* @param callback If an optional callback parameter was passed, the
|
|
279
303
|
* callback function will be called when the popup is closed and the first
|
|
280
304
|
* argument will be a boolean indicating whether the user shared its
|
|
281
|
-
* phone number.
|
|
305
|
+
* phone number. The second argument, contingent upon success, will be
|
|
306
|
+
* an object detailing the shared contact information or a cancellation response.
|
|
282
307
|
*/
|
|
283
|
-
requestContact(
|
|
308
|
+
requestContact(
|
|
309
|
+
callback?: (success: boolean, response: RequestContactResponse) => void,
|
|
310
|
+
): void;
|
|
284
311
|
/**
|
|
285
312
|
* A method that informs the Telegram app that the Web App is ready to be
|
|
286
313
|
* displayed. It is recommended to call this method as early as possible, as
|
|
@@ -678,6 +705,110 @@ interface CloudStorage {
|
|
|
678
705
|
getKeys(callback?: (error: string | null, keys: null | string[]) => void): CloudStorage;
|
|
679
706
|
}
|
|
680
707
|
|
|
708
|
+
/**
|
|
709
|
+
* This object controls biometrics on the device. Before the first use
|
|
710
|
+
* of this object, it needs to be initialized using the init method.
|
|
711
|
+
*/
|
|
712
|
+
interface BiometricManager {
|
|
713
|
+
/**
|
|
714
|
+
* Shows whether biometrics object is initialized.
|
|
715
|
+
*/
|
|
716
|
+
isInited: boolean;
|
|
717
|
+
/**
|
|
718
|
+
* Shows whether biometrics is available on the current device.
|
|
719
|
+
*/
|
|
720
|
+
isBiometricAvailable: boolean;
|
|
721
|
+
/**
|
|
722
|
+
* The type of biometrics currently available on the device. Can be one of these values:
|
|
723
|
+
* - finger, fingerprint-based biometrics,
|
|
724
|
+
* - face, face-based biometrics,
|
|
725
|
+
* - unknown, biometrics of an unknown type.
|
|
726
|
+
*/
|
|
727
|
+
biometricType: "finger" | "face" | "unkown";
|
|
728
|
+
/**
|
|
729
|
+
* Shows whether permission to use biometrics has been requested.
|
|
730
|
+
*/
|
|
731
|
+
isAccessRequested: boolean;
|
|
732
|
+
/**
|
|
733
|
+
* Shows whether permission to use biometrics has been granted.
|
|
734
|
+
*/
|
|
735
|
+
isAccessGranted: boolean;
|
|
736
|
+
/**
|
|
737
|
+
* Shows whether the token is saved in secure storage on the device.
|
|
738
|
+
*/
|
|
739
|
+
isBiometricTokenSaved: boolean;
|
|
740
|
+
/**
|
|
741
|
+
* A unique device identifier that can be used to match the token to the device.
|
|
742
|
+
*/
|
|
743
|
+
deviceId: string;
|
|
744
|
+
/**
|
|
745
|
+
* A method that initializes the BiometricManager object. It should be called before
|
|
746
|
+
* the object's first use. If an optional callback parameter was passed, the callback
|
|
747
|
+
* function will be called when the object is initialized.
|
|
748
|
+
*/
|
|
749
|
+
init: (callback?: (isAccessGranted: boolean) => void) => BiometricManager;
|
|
750
|
+
/**
|
|
751
|
+
* A method that requests permission to use biometrics according to the params
|
|
752
|
+
* argument of type BiometricRequestAccessParams. If an optional callback
|
|
753
|
+
* parameter was passed, the callback function will be called and the first argument
|
|
754
|
+
* will be a boolean indicating whether the user granted access.
|
|
755
|
+
*/
|
|
756
|
+
requestAccess: (
|
|
757
|
+
params: BiometricRequestAccessParams,
|
|
758
|
+
callback?: (isAccessGranted: boolean) => void,
|
|
759
|
+
) => BiometricManager;
|
|
760
|
+
/**
|
|
761
|
+
* A method that authenticates the user using biometrics according to the params
|
|
762
|
+
* argument of type BiometricAuthenticateParams. If an optional callback parameter
|
|
763
|
+
* was passed, the callback function will be called and the first argument will be
|
|
764
|
+
* a boolean indicating whether the user authenticated successfully.
|
|
765
|
+
*
|
|
766
|
+
* If so, the second argument will be a biometric token.
|
|
767
|
+
*/
|
|
768
|
+
authenticate: (
|
|
769
|
+
params: BiometricAuthenticateParams,
|
|
770
|
+
callback?: (isAuthenticated: boolean, biometricToken?: string) => void,
|
|
771
|
+
) => BiometricManager;
|
|
772
|
+
/**
|
|
773
|
+
* A method that updates the biometric token in secure storage on the device.
|
|
774
|
+
* To remove the token, pass an empty string. If an optional callback parameter
|
|
775
|
+
* was passed, the callback function will be called and the first argument will be
|
|
776
|
+
* a boolean indicating whether the token was updated.
|
|
777
|
+
*/
|
|
778
|
+
updateBiometricToken: (token: string, callback?: (applied: boolean) => void) => BiometricManager;
|
|
779
|
+
/**
|
|
780
|
+
* A method that opens the biometric access settings for bots. Useful when you
|
|
781
|
+
* need to request biometrics access to users who haven't granted it yet.
|
|
782
|
+
*
|
|
783
|
+
* Note that this method can be called only in response to user interaction with
|
|
784
|
+
* the Mini App interface (e.g. a click inside the Mini App or on the main button)
|
|
785
|
+
*/
|
|
786
|
+
openSettings: () => BiometricManager;
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
/**
|
|
790
|
+
* This object describes the native popup for requesting permission to use biometrics.
|
|
791
|
+
*/
|
|
792
|
+
interface BiometricRequestAccessParams {
|
|
793
|
+
/**
|
|
794
|
+
* The text to be displayed to a user in the popup describing why the bot needs
|
|
795
|
+
* access to biometrics, 0-128 characters.
|
|
796
|
+
*/
|
|
797
|
+
reason?: string;
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
/**
|
|
801
|
+
* This object describes the native popup for authenticating the user using biometrics.
|
|
802
|
+
*/
|
|
803
|
+
interface BiometricAuthenticateParams {
|
|
804
|
+
/**
|
|
805
|
+
* The text to be displayed to a user in the popup describing why you are asking them
|
|
806
|
+
* to authenticate and what action you will be taking based on that authentication,
|
|
807
|
+
* 0-128 characters.
|
|
808
|
+
*/
|
|
809
|
+
reason?: string;
|
|
810
|
+
}
|
|
811
|
+
|
|
681
812
|
/**
|
|
682
813
|
* This object contains data that is transferred to the Web App when it is
|
|
683
814
|
* opened. It is empty if the Web App was launched from a keyboard button.
|
|
@@ -809,3 +940,43 @@ interface ScanQrPopupParams {
|
|
|
809
940
|
*/
|
|
810
941
|
text?: string;
|
|
811
942
|
}
|
|
943
|
+
|
|
944
|
+
/**
|
|
945
|
+
* This object describes contact information shared when requestContact was approved by the user.
|
|
946
|
+
*/
|
|
947
|
+
interface RequestContactResponseSent {
|
|
948
|
+
/** Status 'sent' indicates that contact information has been shared. */
|
|
949
|
+
status: "sent";
|
|
950
|
+
/** A status message or result as a string. */
|
|
951
|
+
response: string;
|
|
952
|
+
/** Contains sensitive information shared upon user consent. WARNING: Data from
|
|
953
|
+
* this field should not be trusted. You should only use data from `response` on
|
|
954
|
+
* the bot's server and only after it has been validated. */
|
|
955
|
+
responseUnsafe: {
|
|
956
|
+
/** Authorization date for sharing contact information. */
|
|
957
|
+
auth_date: string;
|
|
958
|
+
/** Object holding user's contact details. */
|
|
959
|
+
contact: {
|
|
960
|
+
/** User's first name. */
|
|
961
|
+
first_name: string;
|
|
962
|
+
/** Optional. User's last name. */
|
|
963
|
+
last_name?: string;
|
|
964
|
+
/** User's phone number. */
|
|
965
|
+
phone_number: string;
|
|
966
|
+
/** Unique identifier of the user. */
|
|
967
|
+
user_id: number;
|
|
968
|
+
};
|
|
969
|
+
/** Hash to verify data authenticity. */
|
|
970
|
+
hash: string;
|
|
971
|
+
};
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
/**
|
|
975
|
+
* This object only contains a status to indicate the cancellation.
|
|
976
|
+
*/
|
|
977
|
+
interface RequestContactResponseCancelled {
|
|
978
|
+
/** Status 'cancelled', indicates that user cancelled the contact share request. */
|
|
979
|
+
status: "cancelled";
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
type RequestContactResponse = RequestContactResponseSent | RequestContactResponseCancelled;
|
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.2.0",
|
|
4
4
|
"description": "TypeScript definitions for telegram-web-app",
|
|
5
5
|
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/telegram-web-app",
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,6 +30,6 @@
|
|
|
30
30
|
},
|
|
31
31
|
"scripts": {},
|
|
32
32
|
"dependencies": {},
|
|
33
|
-
"typesPublisherContentHash": "
|
|
34
|
-
"typeScriptVersion": "4.
|
|
33
|
+
"typesPublisherContentHash": "9b6c2ed98451f412f06d422b59f9c79f95aeedab280ed7756fb647e3b90c76fc",
|
|
34
|
+
"typeScriptVersion": "4.7"
|
|
35
35
|
}
|