@types/telegram-web-app 7.1.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.
@@ -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: Wed, 06 Mar 2024 06:35:45 GMT
11
+ * Last updated: Mon, 01 Apr 2024 17:35:38 GMT
12
12
  * Dependencies: none
13
13
 
14
14
  # Credits
@@ -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: "themeChanged" | "mainButtonClicked" | "backButtonClicked" | "settingsButtonClicked",
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;
@@ -158,10 +167,20 @@ interface WebApp {
158
167
  eventHandler: (eventData: { status: "allowed" | "cancelled" }) => void,
159
168
  ): void;
160
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: "themeChanged" | "mainButtonClicked" | "backButtonClicked" | "settingsButtonClicked",
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;
@@ -177,6 +196,11 @@ interface WebApp {
177
196
  eventHandler: (eventData: { status: "allowed" | "cancelled" }) => void,
178
197
  ): void;
179
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
@@ -681,6 +705,110 @@ interface CloudStorage {
681
705
  getKeys(callback?: (error: string | null, keys: null | string[]) => void): CloudStorage;
682
706
  }
683
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
+
684
812
  /**
685
813
  * This object contains data that is transferred to the Web App when it is
686
814
  * opened. It is empty if the Web App was launched from a keyboard button.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/telegram-web-app",
3
- "version": "7.1.0",
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": "e60f7c8652216a4904f9dec0fa735f121014abd943bd6a19bb9c430198c076b6",
34
- "typeScriptVersion": "4.6"
33
+ "typesPublisherContentHash": "9b6c2ed98451f412f06d422b59f9c79f95aeedab280ed7756fb647e3b90c76fc",
34
+ "typeScriptVersion": "4.7"
35
35
  }