@tma.js/sdk 2.6.1 → 3.0.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.
Files changed (310) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +9 -9
  3. package/dist/dts/composables/AsyncMountable.d.ts +44 -0
  4. package/dist/dts/composables/Button.d.ts +140 -0
  5. package/dist/dts/composables/Mountable.d.ts +43 -0
  6. package/dist/dts/composables/Stateful.d.ts +35 -0
  7. package/dist/dts/errors.d.ts +41 -0
  8. package/dist/dts/features/BackButton/BackButton.d.ts +96 -0
  9. package/dist/dts/features/BackButton/exports.d.ts +2 -0
  10. package/dist/dts/features/BackButton/instance.d.ts +2 -0
  11. package/dist/dts/features/Biometry/Biometry.d.ts +122 -0
  12. package/dist/dts/features/Biometry/exports.d.ts +3 -0
  13. package/dist/dts/features/Biometry/instance.d.ts +2 -0
  14. package/dist/dts/features/Biometry/types.d.ts +84 -0
  15. package/dist/dts/features/ClosingBehavior/ClosingBehavior.d.ts +51 -0
  16. package/dist/dts/features/ClosingBehavior/exports.d.ts +2 -0
  17. package/dist/dts/features/ClosingBehavior/instance.d.ts +2 -0
  18. package/dist/dts/features/CloudStorage/CloudStorage.d.ts +90 -0
  19. package/dist/dts/features/CloudStorage/exports.d.ts +2 -0
  20. package/dist/dts/features/CloudStorage/instance.d.ts +2 -0
  21. package/dist/dts/features/HapticFeedback/HapticFeedback.d.ts +57 -0
  22. package/dist/dts/features/HapticFeedback/exports.d.ts +2 -0
  23. package/dist/dts/features/HapticFeedback/instance.d.ts +2 -0
  24. package/dist/dts/features/InitData/InitData.d.ts +84 -0
  25. package/dist/dts/features/InitData/exports.d.ts +2 -0
  26. package/dist/dts/features/InitData/instance.d.ts +2 -0
  27. package/dist/dts/features/Invoice/Invoice.d.ts +54 -0
  28. package/dist/dts/features/Invoice/exports.d.ts +2 -0
  29. package/dist/dts/features/Invoice/instance.d.ts +2 -0
  30. package/dist/dts/features/LocationManager/LocationManager.d.ts +74 -0
  31. package/dist/dts/features/LocationManager/exports.d.ts +3 -0
  32. package/dist/dts/features/LocationManager/instance.d.ts +2 -0
  33. package/dist/dts/features/LocationManager/types.d.ts +65 -0
  34. package/dist/dts/features/MainButton/MainButton.d.ts +214 -0
  35. package/dist/dts/features/MainButton/exports.d.ts +2 -0
  36. package/dist/dts/features/MainButton/instance.d.ts +2 -0
  37. package/dist/dts/features/MiniApp/MiniApp.d.ts +192 -0
  38. package/dist/dts/features/MiniApp/exports.d.ts +2 -0
  39. package/dist/dts/features/MiniApp/instance.d.ts +2 -0
  40. package/dist/dts/features/Popup/Popup.d.ts +56 -0
  41. package/dist/dts/features/Popup/exports.d.ts +3 -0
  42. package/dist/dts/features/Popup/instance.d.ts +2 -0
  43. package/dist/dts/features/Popup/prepareParams.d.ts +9 -0
  44. package/dist/dts/{components → features}/Popup/types.d.ts +5 -12
  45. package/dist/dts/features/QrScanner/QrScanner.d.ts +132 -0
  46. package/dist/dts/features/QrScanner/exports.d.ts +2 -0
  47. package/dist/dts/features/QrScanner/instance.d.ts +2 -0
  48. package/dist/dts/features/SecondaryButton/SecondaryButton.d.ts +253 -0
  49. package/dist/dts/features/SecondaryButton/exports.d.ts +2 -0
  50. package/dist/dts/features/SecondaryButton/instance.d.ts +2 -0
  51. package/dist/dts/features/SettingsButton/SettingsButton.d.ts +96 -0
  52. package/dist/dts/features/SettingsButton/exports.d.ts +2 -0
  53. package/dist/dts/features/SettingsButton/instance.d.ts +2 -0
  54. package/dist/dts/features/SwipeBehavior/SwipeBehavior.d.ts +62 -0
  55. package/dist/dts/features/SwipeBehavior/exports.d.ts +2 -0
  56. package/dist/dts/features/SwipeBehavior/instance.d.ts +2 -0
  57. package/dist/dts/features/ThemeParams/ThemeParams.d.ts +127 -0
  58. package/dist/dts/features/ThemeParams/exports.d.ts +2 -0
  59. package/dist/dts/features/ThemeParams/instance.d.ts +2 -0
  60. package/dist/dts/features/Viewport/Viewport.d.ts +220 -0
  61. package/dist/dts/features/Viewport/exports.d.ts +2 -0
  62. package/dist/dts/features/Viewport/instance.d.ts +2 -0
  63. package/dist/dts/features/emoji-status/exports.d.ts +2 -0
  64. package/dist/dts/features/emoji-status/requestEmojiStatusAccess.d.ts +16 -0
  65. package/dist/dts/features/emoji-status/setEmojiStatus.d.ts +28 -0
  66. package/dist/dts/features/home-screen/addToHomeScreen.d.ts +11 -0
  67. package/dist/dts/features/home-screen/checkHomeScreenStatus.d.ts +14 -0
  68. package/dist/dts/features/home-screen/exports.d.ts +2 -0
  69. package/dist/dts/features/links/exports.d.ts +3 -0
  70. package/dist/dts/features/links/openLink.d.ts +31 -0
  71. package/dist/dts/features/links/openTelegramLink.d.ts +18 -0
  72. package/dist/dts/features/links/shareURL.d.ts +18 -0
  73. package/dist/dts/features/privacy/exports.d.ts +3 -0
  74. package/dist/dts/features/privacy/requestContact.d.ts +59 -0
  75. package/dist/dts/features/privacy/requestPhoneAccess.d.ts +19 -0
  76. package/dist/dts/features/privacy/requestWriteAccess.d.ts +14 -0
  77. package/dist/dts/features/uncategorized/copyTextToClipboard.d.ts +5 -0
  78. package/dist/dts/features/uncategorized/downloadFile.d.ts +21 -0
  79. package/dist/dts/features/uncategorized/exports.d.ts +11 -0
  80. package/dist/dts/features/uncategorized/getCurrentTime.d.ts +15 -0
  81. package/dist/dts/features/uncategorized/hideKeyboard.d.ts +13 -0
  82. package/dist/dts/features/uncategorized/readTextFromClipboard.d.ts +13 -0
  83. package/dist/dts/features/uncategorized/retrieveAndroidDeviceData.d.ts +6 -0
  84. package/dist/dts/features/uncategorized/retrieveAndroidDeviceDataFrom.d.ts +14 -0
  85. package/dist/dts/features/uncategorized/sendData.d.ts +20 -0
  86. package/dist/dts/features/uncategorized/shareMessage.d.ts +14 -0
  87. package/dist/dts/features/uncategorized/shareStory.d.ts +50 -0
  88. package/dist/dts/features/uncategorized/switchInlineQuery.d.ts +28 -0
  89. package/dist/dts/fn-options/bottomButtonOptions.d.ts +11 -0
  90. package/dist/dts/fn-options/buttonOptions.d.ts +10 -0
  91. package/dist/dts/fn-options/createFnOption.d.ts +2 -0
  92. package/dist/dts/fn-options/sharedFeatureOptions.d.ts +8 -0
  93. package/dist/dts/fn-options/withInvokeCustomMethod.d.ts +11 -0
  94. package/dist/dts/fn-options/withPostEvent.d.ts +8 -0
  95. package/dist/dts/fn-options/withRequest.d.ts +8 -0
  96. package/dist/dts/fn-options/withStateRestore.d.ts +13 -0
  97. package/dist/dts/fn-options/withVersion.d.ts +9 -0
  98. package/dist/dts/globals/createRequestId.d.ts +4 -0
  99. package/dist/dts/globals/inline-mode.d.ts +4 -0
  100. package/dist/dts/globals/invokeCustomMethod.d.ts +16 -0
  101. package/dist/dts/globals/post-event.d.ts +4 -0
  102. package/dist/dts/globals/request.d.ts +3 -0
  103. package/dist/dts/globals/resetGlobals.d.ts +4 -0
  104. package/dist/dts/globals/signals-registry.d.ts +39 -0
  105. package/dist/dts/globals/themeParams.d.ts +4 -0
  106. package/dist/dts/globals/version.d.ts +4 -0
  107. package/dist/dts/helpers/access.d.ts +2 -0
  108. package/dist/dts/helpers/component-storage.d.ts +9 -0
  109. package/dist/dts/helpers/createIsSupportedSignal.d.ts +5 -0
  110. package/dist/dts/helpers/css-vars.d.ts +11 -0
  111. package/dist/dts/helpers/isColorDark.d.ts +11 -0
  112. package/dist/dts/{navigation/isPageReload.d.ts → helpers/navigation.d.ts} +1 -1
  113. package/dist/dts/helpers/removeUndefined.d.ts +10 -0
  114. package/dist/dts/helpers/shallowEqual.d.ts +1 -0
  115. package/dist/dts/index.d.ts +33 -168
  116. package/dist/dts/init.d.ts +42 -0
  117. package/dist/dts/types.d.ts +6 -0
  118. package/dist/dts/with-checks/throwifyWithChecksFp.d.ts +3 -0
  119. package/dist/dts/with-checks/withChecksFp.d.ts +172 -0
  120. package/dist/index.cjs +1 -1
  121. package/dist/index.cjs.map +1 -1
  122. package/dist/index.iife.js +3 -1
  123. package/dist/index.iife.js.map +1 -1
  124. package/dist/index.js +3824 -2925
  125. package/dist/index.js.map +1 -1
  126. package/package.json +19 -9
  127. package/dist/dts/bridge/events/event-emitter/createMiniAppsEventEmitter.d.ts +0 -15
  128. package/dist/dts/bridge/events/event-emitter/singleton.d.ts +0 -8
  129. package/dist/dts/bridge/events/event-handlers/cleanupEventHandlers.d.ts +0 -4
  130. package/dist/dts/bridge/events/event-handlers/defineEventHandlers.d.ts +0 -6
  131. package/dist/dts/bridge/events/event-handlers/emitMiniAppsEvent.d.ts +0 -9
  132. package/dist/dts/bridge/events/listening/off.d.ts +0 -8
  133. package/dist/dts/bridge/events/listening/on.d.ts +0 -12
  134. package/dist/dts/bridge/events/listening/subscribe.d.ts +0 -9
  135. package/dist/dts/bridge/events/listening/unsubscribe.d.ts +0 -7
  136. package/dist/dts/bridge/events/types.d.ts +0 -302
  137. package/dist/dts/bridge/methods/createPostEvent.d.ts +0 -13
  138. package/dist/dts/bridge/methods/postEvent.d.ts +0 -38
  139. package/dist/dts/bridge/methods/types/custom-methods.d.ts +0 -57
  140. package/dist/dts/bridge/methods/types/haptic.d.ts +0 -40
  141. package/dist/dts/bridge/methods/types/index.d.ts +0 -4
  142. package/dist/dts/bridge/methods/types/methods.d.ts +0 -392
  143. package/dist/dts/bridge/methods/types/popup.d.ts +0 -49
  144. package/dist/dts/bridge/parseMessage.d.ts +0 -18
  145. package/dist/dts/bridge/target-origin.d.ts +0 -13
  146. package/dist/dts/bridge/utils/captureSameReq.d.ts +0 -10
  147. package/dist/dts/bridge/utils/invokeCustomMethod.d.ts +0 -23
  148. package/dist/dts/bridge/utils/request.d.ts +0 -47
  149. package/dist/dts/classes/State/State.d.ts +0 -46
  150. package/dist/dts/classes/State/types.d.ts +0 -29
  151. package/dist/dts/classes/WithStateUtils.d.ts +0 -18
  152. package/dist/dts/classes/WithSupports.d.ts +0 -19
  153. package/dist/dts/classes/WithSupportsAndStateUtils.d.ts +0 -24
  154. package/dist/dts/classes/WithSupportsAndTrackableState.d.ts +0 -16
  155. package/dist/dts/classes/WithTrackableState.d.ts +0 -16
  156. package/dist/dts/classnames/classNames.d.ts +0 -12
  157. package/dist/dts/classnames/mergeClassNames.d.ts +0 -14
  158. package/dist/dts/colors/isColorDark.d.ts +0 -6
  159. package/dist/dts/colors/isRGB.d.ts +0 -7
  160. package/dist/dts/colors/isRGBShort.d.ts +0 -7
  161. package/dist/dts/colors/toRGB.d.ts +0 -12
  162. package/dist/dts/colors/types.d.ts +0 -8
  163. package/dist/dts/components/BackButton/BackButton.d.ts +0 -41
  164. package/dist/dts/components/BackButton/initBackButton.d.ts +0 -7
  165. package/dist/dts/components/BackButton/types.d.ts +0 -25
  166. package/dist/dts/components/BiometryManager/BiometryManager.d.ts +0 -61
  167. package/dist/dts/components/BiometryManager/formatEvent.d.ts +0 -34
  168. package/dist/dts/components/BiometryManager/initBiometryManager.d.ts +0 -7
  169. package/dist/dts/components/BiometryManager/requestBiometryInfo.d.ts +0 -8
  170. package/dist/dts/components/BiometryManager/types.d.ts +0 -40
  171. package/dist/dts/components/ClosingBehavior/ClosingBehavior.d.ts +0 -26
  172. package/dist/dts/components/ClosingBehavior/initClosingBehavior.d.ts +0 -7
  173. package/dist/dts/components/ClosingBehavior/types.d.ts +0 -20
  174. package/dist/dts/components/CloudStorage/CloudStorage.d.ts +0 -47
  175. package/dist/dts/components/CloudStorage/initCloudStorage.d.ts +0 -7
  176. package/dist/dts/components/HapticFeedback/HapticFeedback.d.ts +0 -34
  177. package/dist/dts/components/HapticFeedback/initHapticFeedback.d.ts +0 -7
  178. package/dist/dts/components/InitData/InitData.d.ts +0 -55
  179. package/dist/dts/components/InitData/initInitData.d.ts +0 -7
  180. package/dist/dts/components/InitData/parseInitData.d.ts +0 -7
  181. package/dist/dts/components/InitData/parsers/chat.d.ts +0 -3
  182. package/dist/dts/components/InitData/parsers/initData.d.ts +0 -7
  183. package/dist/dts/components/InitData/parsers/user.d.ts +0 -3
  184. package/dist/dts/components/InitData/types.d.ts +0 -132
  185. package/dist/dts/components/Invoice/Invoice.d.ts +0 -31
  186. package/dist/dts/components/Invoice/initInvoice.d.ts +0 -7
  187. package/dist/dts/components/Invoice/types.d.ts +0 -20
  188. package/dist/dts/components/MainButton/MainButton.d.ts +0 -106
  189. package/dist/dts/components/MainButton/initMainButton.d.ts +0 -7
  190. package/dist/dts/components/MainButton/types.d.ts +0 -40
  191. package/dist/dts/components/MiniApp/MiniApp.d.ts +0 -120
  192. package/dist/dts/components/MiniApp/initMiniApp.d.ts +0 -7
  193. package/dist/dts/components/MiniApp/parsing/contact.d.ts +0 -7
  194. package/dist/dts/components/MiniApp/types.d.ts +0 -53
  195. package/dist/dts/components/Popup/Popup.d.ts +0 -30
  196. package/dist/dts/components/Popup/initPopup.d.ts +0 -7
  197. package/dist/dts/components/Popup/preparePopupParams.d.ts +0 -8
  198. package/dist/dts/components/QRScanner/QRScanner.d.ts +0 -33
  199. package/dist/dts/components/QRScanner/initQRScanner.d.ts +0 -7
  200. package/dist/dts/components/QRScanner/types.d.ts +0 -31
  201. package/dist/dts/components/SettingsButton/SettingsButton.d.ts +0 -37
  202. package/dist/dts/components/SettingsButton/initSettingsButton.d.ts +0 -7
  203. package/dist/dts/components/SettingsButton/types.d.ts +0 -25
  204. package/dist/dts/components/ThemeParams/ThemeParams.d.ts +0 -57
  205. package/dist/dts/components/ThemeParams/initThemeParams.d.ts +0 -7
  206. package/dist/dts/components/ThemeParams/keys.d.ts +0 -11
  207. package/dist/dts/components/ThemeParams/parsing/parseThemeParams.d.ts +0 -7
  208. package/dist/dts/components/ThemeParams/parsing/serializeThemeParams.d.ts +0 -6
  209. package/dist/dts/components/ThemeParams/parsing/themeParams.d.ts +0 -4
  210. package/dist/dts/components/ThemeParams/requestThemeParams.d.ts +0 -8
  211. package/dist/dts/components/ThemeParams/types.d.ts +0 -29
  212. package/dist/dts/components/Utils/Utils.d.ts +0 -54
  213. package/dist/dts/components/Utils/initUtils.d.ts +0 -7
  214. package/dist/dts/components/Viewport/Viewport.d.ts +0 -77
  215. package/dist/dts/components/Viewport/initViewport.d.ts +0 -7
  216. package/dist/dts/components/Viewport/requestViewport.d.ts +0 -13
  217. package/dist/dts/components/Viewport/types.d.ts +0 -35
  218. package/dist/dts/css-vars/bindMiniAppCSSVars.d.ts +0 -29
  219. package/dist/dts/css-vars/bindThemeParamsCSSVars.d.ts +0 -29
  220. package/dist/dts/css-vars/bindViewportCSSVars.d.ts +0 -32
  221. package/dist/dts/css-vars/setCSSVar.d.ts +0 -6
  222. package/dist/dts/debug/debug.d.ts +0 -14
  223. package/dist/dts/env/hasExternalNotify.d.ts +0 -10
  224. package/dist/dts/env/hasWebviewProxy.d.ts +0 -10
  225. package/dist/dts/env/initWeb.d.ts +0 -11
  226. package/dist/dts/env/isIframe.d.ts +0 -5
  227. package/dist/dts/env/isSSR.d.ts +0 -4
  228. package/dist/dts/env/isTMA.d.ts +0 -4
  229. package/dist/dts/env/mockTelegramEnv.d.ts +0 -7
  230. package/dist/dts/errors/SDKError.d.ts +0 -9
  231. package/dist/dts/errors/createError.d.ts +0 -10
  232. package/dist/dts/errors/errors.d.ts +0 -49
  233. package/dist/dts/errors/isSDKError.d.ts +0 -7
  234. package/dist/dts/errors/isSDKErrorOfType.d.ts +0 -8
  235. package/dist/dts/events/event-emitter/EventEmitter.d.ts +0 -54
  236. package/dist/dts/events/event-emitter/types.d.ts +0 -45
  237. package/dist/dts/events/onWindow.d.ts +0 -10
  238. package/dist/dts/events/types.d.ts +0 -6
  239. package/dist/dts/index.low-level.d.ts +0 -41
  240. package/dist/dts/launch-params/parseLaunchParams.d.ts +0 -7
  241. package/dist/dts/launch-params/retrieveFromLocation.d.ts +0 -7
  242. package/dist/dts/launch-params/retrieveFromPerformance.d.ts +0 -7
  243. package/dist/dts/launch-params/retrieveFromStorage.d.ts +0 -7
  244. package/dist/dts/launch-params/retrieveFromUrl.d.ts +0 -8
  245. package/dist/dts/launch-params/retrieveLaunchParams.d.ts +0 -7
  246. package/dist/dts/launch-params/saveToStorage.d.ts +0 -7
  247. package/dist/dts/launch-params/serializeLaunchParams.d.ts +0 -7
  248. package/dist/dts/launch-params/types.d.ts +0 -51
  249. package/dist/dts/logger/Logger.d.ts +0 -29
  250. package/dist/dts/misc/createCleanup.d.ts +0 -11
  251. package/dist/dts/misc/createComponentInitFn/createComponentInitFn.d.ts +0 -16
  252. package/dist/dts/misc/createComponentInitFn/types.d.ts +0 -54
  253. package/dist/dts/misc/createSingleton.d.ts +0 -15
  254. package/dist/dts/misc/isRecord.d.ts +0 -5
  255. package/dist/dts/misc/objectFromKeys.d.ts +0 -6
  256. package/dist/dts/navigation/BasicNavigator/BasicNavigator.d.ts +0 -118
  257. package/dist/dts/navigation/BasicNavigator/prepareItem.d.ts +0 -8
  258. package/dist/dts/navigation/BasicNavigator/types.d.ts +0 -37
  259. package/dist/dts/navigation/BrowserNavigator/BrowserNavigator.d.ts +0 -198
  260. package/dist/dts/navigation/BrowserNavigator/basicItemToBrowser.d.ts +0 -7
  261. package/dist/dts/navigation/BrowserNavigator/createBrowserNavigatorFromLocation.d.ts +0 -4
  262. package/dist/dts/navigation/BrowserNavigator/prepareItem.d.ts +0 -25
  263. package/dist/dts/navigation/BrowserNavigator/types.d.ts +0 -64
  264. package/dist/dts/navigation/createSafeURL.d.ts +0 -7
  265. package/dist/dts/navigation/drop.d.ts +0 -4
  266. package/dist/dts/navigation/ensurePrefix.d.ts +0 -7
  267. package/dist/dts/navigation/getFirstNavigationEntry.d.ts +0 -6
  268. package/dist/dts/navigation/getHash.d.ts +0 -15
  269. package/dist/dts/navigation/getPathname.d.ts +0 -7
  270. package/dist/dts/navigation/go.d.ts +0 -5
  271. package/dist/dts/navigation/initNavigator.d.ts +0 -9
  272. package/dist/dts/navigation/urlToPath.d.ts +0 -7
  273. package/dist/dts/parsing/ArrayParser/ArrayParser.d.ts +0 -17
  274. package/dist/dts/parsing/ArrayParser/types.d.ts +0 -12
  275. package/dist/dts/parsing/ValueParser/ValueParser.d.ts +0 -17
  276. package/dist/dts/parsing/ValueParser/types.d.ts +0 -28
  277. package/dist/dts/parsing/createTypeError.d.ts +0 -6
  278. package/dist/dts/parsing/createValueParserGenerator.d.ts +0 -10
  279. package/dist/dts/parsing/parseBySchema.d.ts +0 -9
  280. package/dist/dts/parsing/parsers/array.d.ts +0 -7
  281. package/dist/dts/parsing/parsers/boolean.d.ts +0 -6
  282. package/dist/dts/parsing/parsers/date.d.ts +0 -6
  283. package/dist/dts/parsing/parsers/json.d.ts +0 -9
  284. package/dist/dts/parsing/parsers/number.d.ts +0 -6
  285. package/dist/dts/parsing/parsers/rgb.d.ts +0 -7
  286. package/dist/dts/parsing/parsers/searchParams.d.ts +0 -9
  287. package/dist/dts/parsing/parsers/string.d.ts +0 -6
  288. package/dist/dts/parsing/toRecord.d.ts +0 -7
  289. package/dist/dts/parsing/types.d.ts +0 -30
  290. package/dist/dts/request-id/createRequestIdGenerator.d.ts +0 -6
  291. package/dist/dts/request-id/types.d.ts +0 -9
  292. package/dist/dts/storage/storage.d.ts +0 -42
  293. package/dist/dts/supports/createSupportsFn.d.ts +0 -12
  294. package/dist/dts/supports/createSupportsParamFn.d.ts +0 -16
  295. package/dist/dts/supports/supports.d.ts +0 -16
  296. package/dist/dts/supports/types.d.ts +0 -4
  297. package/dist/dts/timeout/createTimeoutError.d.ts +0 -7
  298. package/dist/dts/timeout/sleep.d.ts +0 -5
  299. package/dist/dts/timeout/withTimeout.d.ts +0 -6
  300. package/dist/dts/types/index.d.ts +0 -6
  301. package/dist/dts/types/logical.d.ts +0 -16
  302. package/dist/dts/types/methods.d.ts +0 -16
  303. package/dist/dts/types/misc.d.ts +0 -12
  304. package/dist/dts/types/platform.d.ts +0 -4
  305. package/dist/dts/types/unions.d.ts +0 -20
  306. package/dist/dts/types/utils.d.ts +0 -24
  307. package/dist/dts/version/compareVersions.d.ts +0 -10
  308. package/dist/dts/version/types.d.ts +0 -5
  309. package/dist/index.low-level.iife.js +0 -2
  310. package/dist/index.low-level.iife.js.map +0 -1
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2020 Vladislav Kibenko
3
+ Copyright (c) 2025 Vladislav Kibenko
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -4,20 +4,20 @@
4
4
 
5
5
  [docs-badge]: https://img.shields.io/badge/documentation-blue?logo=gitbook&logoColor=white
6
6
 
7
- [sdk-code-link]: https://github.com/Telegram-Mini-Apps/tma.js/tree/master/packages/sdk
7
+ [link]: https://github.com/Telegram-Mini-Apps/telegram-apps/tree/master/tma.js/sdk
8
8
 
9
- [sdk-docs-link]: https://docs.telegram-mini-apps.com/packages/tma-js-sdk
9
+ [docs-link]: https://docs.telegram-mini-apps.com/packages/tma-js-sdk
10
10
 
11
- [sdk-npm-link]: https://npmjs.com/package/@tma.js/sdk
11
+ [npm-link]: https://npmjs.com/package/@tma.js/sdk
12
12
 
13
- [sdk-npm-badge]: https://img.shields.io/npm/v/@tma.js/sdk?logo=npm
13
+ [npm-badge]: https://img.shields.io/npm/v/@tma.js/sdk?logo=npm
14
14
 
15
- [sdk-size-badge]: https://img.shields.io/bundlephobia/minzip/@tma.js/sdk
15
+ [size-badge]: https://img.shields.io/bundlephobia/minzip/@tma.js/sdk
16
16
 
17
- [![NPM][sdk-npm-badge]][sdk-npm-link]
18
- ![Size][sdk-size-badge]
19
- [![docs-badge]][sdk-docs-link]
20
- [![code-badge]][sdk-code-link]
17
+ [![NPM][npm-badge]][npm-link]
18
+ ![Size][size-badge]
19
+ [![docs-badge]][docs-link]
20
+ [![code-badge]][link]
21
21
 
22
22
  Made from scratch TypeScript library for seamless communication with Telegram Mini Apps
23
23
  functionality.
@@ -0,0 +1,44 @@
1
+ import { AsyncOptions, MaybeAccessor } from '../types.js';
2
+ import * as TE from 'fp-ts/TaskEither';
3
+ export interface AsyncMountableOptions<S, E> {
4
+ /**
5
+ * A function to retrieve the initial state.
6
+ * @param options - additional options.
7
+ */
8
+ initialState: (options?: AsyncOptions) => TE.TaskEither<E, S>;
9
+ /**
10
+ * @returns True if the current page was reloaded.
11
+ */
12
+ isPageReload: MaybeAccessor<boolean>;
13
+ /**
14
+ * A function to call whenever the component was mounted.
15
+ * @param state - restored state.
16
+ */
17
+ onMounted?: (state: S) => void;
18
+ /**
19
+ * A function to call whenever the component was unmounted.
20
+ */
21
+ onUnmounted?: VoidFunction;
22
+ /**
23
+ * Attempts to restore previously saved component state. This function
24
+ * will only be called if the current page was reloaded.
25
+ */
26
+ restoreState: () => (S | undefined);
27
+ }
28
+ export declare class AsyncMountable<S extends object, E> {
29
+ constructor({ initialState, onMounted, restoreState, onUnmounted, isPageReload, }: AsyncMountableOptions<S, E>);
30
+ private readonly _isMounted;
31
+ /**
32
+ * Signal indicating if the component is mounted.
33
+ */
34
+ readonly isMounted: import('@tma.js/signals').Computed<boolean>;
35
+ /**
36
+ * Mounts the component restoring its state and calling required side effects.
37
+ * @param options - additional execution options.
38
+ */
39
+ readonly mount: (options?: AsyncOptions) => TE.TaskEither<E, void>;
40
+ /**
41
+ * Unmounts the component.
42
+ */
43
+ readonly unmount: () => void;
44
+ }
@@ -0,0 +1,140 @@
1
+ import { Computed } from '@tma.js/signals';
2
+ import { PostEventError, MethodName, MethodParams } from '@tma.js/bridge';
3
+ import { WithChecksFp, WithChecks } from '../with-checks/withChecksFp.js';
4
+ import { SharedFeatureOptions } from '../fn-options/sharedFeatureOptions.js';
5
+ import { WithStateRestore } from '../fn-options/withStateRestore.js';
6
+ import { WithPostEvent } from '../fn-options/withPostEvent.js';
7
+ import { WithVersion } from '../fn-options/withVersion.js';
8
+ import * as E from 'fp-ts/Either';
9
+ type ButtonEither = E.Either<PostEventError, void>;
10
+ type BoolFields<S> = {
11
+ [K in keyof S]-?: S[K] extends boolean ? K : never;
12
+ }[keyof S];
13
+ export interface ButtonOptions<S, M extends MethodName> extends SharedFeatureOptions, WithStateRestore<S>, WithPostEvent, WithVersion {
14
+ /**
15
+ * The initial button state.
16
+ */
17
+ initialState: S;
18
+ /**
19
+ * Removes a component click listener.
20
+ * @param listener - a listener to remove.
21
+ * @param once - should the listener be called only once.
22
+ */
23
+ offClick: (listener: VoidFunction, once?: boolean) => void;
24
+ /**
25
+ * Adds a component click listener.
26
+ * @returns A function to remove listener.
27
+ * @param listener - a listener to add.
28
+ * @param once - should the listener be called only once.
29
+ */
30
+ onClick: (listener: VoidFunction, once?: boolean) => VoidFunction;
31
+ /**
32
+ * A Mini Apps method to commit changes.
33
+ */
34
+ method: M;
35
+ /**
36
+ * A function to create method payload.
37
+ * @param state
38
+ */
39
+ payload: (state: S) => MethodParams<M>;
40
+ }
41
+ export declare class Button<S extends object, M extends MethodName> {
42
+ constructor({ isTma, storage, onClick, offClick, initialState, isPageReload, postEvent, payload, method, version, }: ButtonOptions<S, M>);
43
+ /**
44
+ * Signal indicating if the component is currently mounted.
45
+ */
46
+ readonly isMounted: Computed<boolean>;
47
+ /**
48
+ * Signal indicating if the component is supported.
49
+ */
50
+ readonly isSupported: Computed<boolean>;
51
+ /**
52
+ * Complete button state.
53
+ */
54
+ readonly state: Computed<S>;
55
+ /**
56
+ * @returns A computed based on the specified state and its related key.
57
+ * @param key - a key to use.
58
+ */
59
+ stateGetter<K extends keyof S>(key: K): Computed<S[K]>;
60
+ /**
61
+ * @returns A setter with checks for the specified key.
62
+ * @param key
63
+ */
64
+ readonly stateSetters: <K extends keyof S>(key: K) => [
65
+ throwing: WithChecks<(value: S[K]) => void, true>,
66
+ fp: WithChecksFp<(value: S[K]) => ButtonEither, true>
67
+ ];
68
+ /**
69
+ * @returns Setters with checks to set a specified boolean key.
70
+ * @param key
71
+ */
72
+ readonly stateBoolSetters: <K extends BoolFields<S>>(key: K) => [
73
+ setFalse: [
74
+ throwing: WithChecks<() => void, true>,
75
+ fp: WithChecksFp<() => ButtonEither, true>
76
+ ],
77
+ setTrue: [
78
+ throwing: WithChecks<() => void, true>,
79
+ fp: WithChecksFp<() => ButtonEither, true>
80
+ ]
81
+ ];
82
+ /**
83
+ * Updates the button state.
84
+ */
85
+ readonly setStateFp: WithChecksFp<(state: Partial<S>) => ButtonEither, true>;
86
+ /**
87
+ * @see setStateFp
88
+ */
89
+ readonly setState: WithChecks<(state: Partial<S>) => void, true>;
90
+ /**
91
+ * Adds a new button listener.
92
+ * @param listener - event listener.
93
+ * @param once - should the listener be called only once.
94
+ * @returns A function to remove bound listener.
95
+ * @example
96
+ * const off = button.onClick(() => {
97
+ * console.log('User clicked the button');
98
+ * off();
99
+ * });
100
+ */
101
+ readonly onClickFp: WithChecksFp<(listener: VoidFunction, once?: boolean) => VoidFunction, true>;
102
+ /**
103
+ * @see onClickFp
104
+ */
105
+ readonly onClick: WithChecks<(listener: VoidFunction, once?: boolean) => VoidFunction, true>;
106
+ /**
107
+ * Removes the button click listener.
108
+ * @param listener - event listener.
109
+ * @param once - should the listener be called only once.
110
+ * @example
111
+ * function listener() {
112
+ * console.log('User clicked the button');
113
+ * button.offClick(listener);
114
+ * }
115
+ * button.onClick(listener);
116
+ */
117
+ readonly offClickFp: WithChecksFp<(listener: VoidFunction, once?: boolean) => void, true>;
118
+ /**
119
+ * @see offClickFp
120
+ */
121
+ readonly offClick: WithChecks<(listener: VoidFunction, once?: boolean) => void, true>;
122
+ /**
123
+ * Mounts the component restoring its state.
124
+ * @since Mini Apps v6.1
125
+ */
126
+ readonly mountFp: WithChecksFp<() => void, true>;
127
+ /**
128
+ * @see mountFp
129
+ */
130
+ readonly mount: WithChecks<() => void, true>;
131
+ /**
132
+ * Unmounts the component.
133
+ *
134
+ * Note that this function does not remove listeners added via the `onClick`
135
+ * function, so you have to remove them on your own.
136
+ * @see onClick
137
+ */
138
+ readonly unmount: () => void;
139
+ }
140
+ export {};
@@ -0,0 +1,43 @@
1
+ import { MaybeAccessor } from '../types.js';
2
+ import * as E from 'fp-ts/Either';
3
+ export interface MountableOptions<S, Err> {
4
+ /**
5
+ * A state to use if the `restoreState` function returned falsy value or
6
+ * `isPageReload` returned false.
7
+ */
8
+ initialState: S | (() => E.Either<Err, S>);
9
+ /**
10
+ * @returns True if the current page was reloaded.
11
+ */
12
+ isPageReload: MaybeAccessor<boolean>;
13
+ /**
14
+ * A function to call whenever the component was mounted.
15
+ * @param state - restored state.
16
+ */
17
+ onMounted?: (state: S) => void;
18
+ /**
19
+ * A function to call whenever the component was unmounted.
20
+ */
21
+ onUnmounted?: VoidFunction;
22
+ /**
23
+ * Attempts to restore previously saved component state. This function
24
+ * will only be called if the current page was reloaded.
25
+ */
26
+ restoreState: () => (S | undefined);
27
+ }
28
+ export declare class Mountable<S extends object, Err = never> {
29
+ constructor({ onMounted, restoreState, initialState, onUnmounted, isPageReload, }: MountableOptions<S, Err>);
30
+ private readonly _isMounted;
31
+ /**
32
+ * Signal indicating if the component is mounted.
33
+ */
34
+ readonly isMounted: import('@tma.js/signals').Computed<boolean>;
35
+ /**
36
+ * Mounts the component restoring its state and calling required side effects.
37
+ */
38
+ readonly mount: () => E.Either<Err, void>;
39
+ /**
40
+ * Unmounts the component.
41
+ */
42
+ readonly unmount: () => void;
43
+ }
@@ -0,0 +1,35 @@
1
+ import { Computed, Signal } from '@tma.js/signals';
2
+ export interface StatefulOptions<S> {
3
+ /**
4
+ * The initial state.
5
+ */
6
+ initialState: S;
7
+ /**
8
+ * A function to call whenever the state changes.
9
+ * @param state - updated state.
10
+ */
11
+ onChange: (state: S) => void;
12
+ }
13
+ export declare class Stateful<S extends object> {
14
+ constructor({ initialState, onChange }: StatefulOptions<S>);
15
+ protected readonly _state: Signal<S>;
16
+ /**
17
+ * The current state.
18
+ */
19
+ readonly state: Computed<S>;
20
+ /**
21
+ * Creates a computed signal based on the state.
22
+ * @param key - a state key to use as a source.
23
+ */
24
+ getter<K extends keyof S>(key: K): Computed<S[K]>;
25
+ /**
26
+ * Updates the state.
27
+ * @param state - updates to apply.
28
+ */
29
+ readonly setState: (state: Partial<S>) => void;
30
+ /**
31
+ * @returns True if specified payload will update the state.
32
+ * @param state
33
+ */
34
+ hasDiff(state: Partial<S>): boolean;
35
+ }
@@ -0,0 +1,41 @@
1
+ import { BaseIssue } from 'valibot';
2
+ declare const ValidationError_base: import('error-kid').ErrorClassWithData<[input: unknown, issues: BaseIssue<any>[]], {
3
+ input: unknown;
4
+ issues: BaseIssue<any>[];
5
+ }>;
6
+ export declare class ValidationError extends ValidationError_base {
7
+ }
8
+ declare const CSSVarsBoundError_base: import('error-kid').ErrorClass<[]>;
9
+ export declare class CSSVarsBoundError extends CSSVarsBoundError_base {
10
+ }
11
+ declare const NotAvailableError_base: import('error-kid').ErrorClass<[message: string]>;
12
+ export declare class NotAvailableError extends NotAvailableError_base {
13
+ }
14
+ declare const InvalidEnvError_base: import('error-kid').ErrorClass<[message?: string | undefined]>;
15
+ export declare class InvalidEnvError extends InvalidEnvError_base {
16
+ }
17
+ declare const FunctionUnavailableError_base: import('error-kid').ErrorClass<[message?: string | undefined]>;
18
+ export declare class FunctionUnavailableError extends FunctionUnavailableError_base {
19
+ }
20
+ declare const InvalidArgumentsError_base: import('error-kid').ErrorClass<[message: string, cause?: unknown]>;
21
+ export declare class InvalidArgumentsError extends InvalidArgumentsError_base {
22
+ }
23
+ declare const ConcurrentCallError_base: import('error-kid').ErrorClass<[message: string]>;
24
+ export declare class ConcurrentCallError extends ConcurrentCallError_base {
25
+ }
26
+ declare const SetEmojiStatusError_base: import('error-kid').ErrorClass<[error: string]>;
27
+ export declare class SetEmojiStatusError extends SetEmojiStatusError_base {
28
+ }
29
+ declare const AccessDeniedError_base: import('error-kid').ErrorClass<[message: string]>;
30
+ export declare class AccessDeniedError extends AccessDeniedError_base {
31
+ }
32
+ declare const FullscreenFailedError_base: import('error-kid').ErrorClass<[message: string]>;
33
+ export declare class FullscreenFailedError extends FullscreenFailedError_base {
34
+ }
35
+ declare const ShareMessageError_base: import('error-kid').ErrorClass<[error: string]>;
36
+ export declare class ShareMessageError extends ShareMessageError_base {
37
+ }
38
+ declare const UnknownThemeParamsKeyError_base: import('error-kid').ErrorClass<[key: string]>;
39
+ export declare class UnknownThemeParamsKeyError extends UnknownThemeParamsKeyError_base {
40
+ }
41
+ export {};
@@ -0,0 +1,96 @@
1
+ import { Computed } from '@tma.js/signals';
2
+ import { PostEventError } from '@tma.js/bridge';
3
+ import { ButtonOptions } from '../../composables/Button.js';
4
+ import { WithChecksFp, WithChecks } from '../../with-checks/withChecksFp.js';
5
+ import * as E from 'fp-ts/Either';
6
+ export interface BackButtonState {
7
+ isVisible: boolean;
8
+ }
9
+ export type BackButtonOptions = Omit<ButtonOptions<BackButtonState, 'web_app_setup_back_button'>, 'method' | 'payload' | 'initialState'>;
10
+ /**
11
+ * @since Mini Apps v6.1
12
+ */
13
+ export declare class BackButton {
14
+ constructor(options: BackButtonOptions);
15
+ /**
16
+ * Signal indicating if the component is currently visible.
17
+ */
18
+ readonly isVisible: Computed<boolean>;
19
+ /**
20
+ * Signal indicating if the component is currently mounted.
21
+ */
22
+ readonly isMounted: Computed<boolean>;
23
+ /**
24
+ * Signal indicating if the component is supported.
25
+ */
26
+ readonly isSupported: Computed<boolean>;
27
+ /**
28
+ * Hides the button.
29
+ * @since Mini Apps v6.1
30
+ */
31
+ readonly hideFp: WithChecksFp<() => E.Either<PostEventError, void>, true>;
32
+ /**
33
+ * @see hideFp
34
+ */
35
+ readonly hide: WithChecks<() => void, true>;
36
+ /**
37
+ * Shows the button.
38
+ * @since Mini Apps v6.1
39
+ */
40
+ readonly showFp: WithChecksFp<() => E.Either<PostEventError, void>, true>;
41
+ /**
42
+ * @see showFp
43
+ */
44
+ readonly show: WithChecks<() => void, true>;
45
+ /**
46
+ * Adds a new button listener.
47
+ * @param listener - event listener.
48
+ * @param once - should the listener be called only once.
49
+ * @returns A function to remove bound listener.
50
+ * @since Mini Apps v6.1
51
+ * @example
52
+ * const off = button.onClick(() => {
53
+ * console.log('User clicked the button');
54
+ * off();
55
+ * });
56
+ */
57
+ readonly onClickFp: WithChecksFp<(listener: VoidFunction, once?: boolean) => VoidFunction, true>;
58
+ /**
59
+ * @see onClickFp
60
+ */
61
+ readonly onClick: WithChecks<(listener: VoidFunction, once?: boolean) => VoidFunction, true>;
62
+ /**
63
+ * Removes the button click listener.
64
+ * @param listener - event listener.
65
+ * @param once - should the listener be called only once.
66
+ * @since Mini Apps v6.1
67
+ * @example
68
+ * function listener() {
69
+ * console.log('User clicked the button');
70
+ * button.offClick(listener);
71
+ * }
72
+ * button.onClick(listener);
73
+ */
74
+ readonly offClickFp: WithChecksFp<(listener: VoidFunction, once?: boolean) => void, true>;
75
+ /**
76
+ * @see offClickFp
77
+ */
78
+ readonly offClick: WithChecks<(listener: VoidFunction, once?: boolean) => void, true>;
79
+ /**
80
+ * Mounts the component restoring its state.
81
+ * @since Mini Apps v6.1
82
+ */
83
+ readonly mountFp: WithChecksFp<() => void, true>;
84
+ /**
85
+ * @see mountFp
86
+ */
87
+ readonly mount: WithChecks<() => void, true>;
88
+ /**
89
+ * Unmounts the component.
90
+ *
91
+ * Note that this function does not remove listeners added via the `onClick`
92
+ * function, so you have to remove them on your own.
93
+ * @see onClick
94
+ */
95
+ readonly unmount: () => void;
96
+ }
@@ -0,0 +1,2 @@
1
+ export { BackButton, type BackButtonState, type BackButtonOptions } from './BackButton.js';
2
+ export { backButton } from './instance.js';
@@ -0,0 +1,2 @@
1
+ import { BackButton } from './BackButton.js';
2
+ export declare const backButton: BackButton;
@@ -0,0 +1,122 @@
1
+ import { Computed } from '@tma.js/signals';
2
+ import { RequestError, PostEventError, BiometryAuthRequestStatus, BiometryTokenUpdateStatus } from '@tma.js/bridge';
3
+ import { BetterPromise } from 'better-promises';
4
+ import { WithChecks, WithChecksFp } from '../../with-checks/withChecksFp.js';
5
+ import { BiometryAuthenticateOptions, BiometryOptions, BiometryRequestAccessOptions, BiometryState, BiometryUpdateTokenOptions } from './types.js';
6
+ import { AsyncOptions } from '../../types.js';
7
+ import * as E from 'fp-ts/Either';
8
+ import * as TE from 'fp-ts/TaskEither';
9
+ type BiometryTask<T> = TE.TaskEither<RequestError, T>;
10
+ interface AuthenticateResult {
11
+ /**
12
+ * Authentication status.
13
+ */
14
+ status: BiometryAuthRequestStatus;
15
+ /**
16
+ * Token from the local secure storage saved previously.
17
+ */
18
+ token?: string;
19
+ }
20
+ /**
21
+ * @since Mini Apps v7.2
22
+ */
23
+ export declare class Biometry {
24
+ constructor({ version, request, postEvent, storage, onInfoReceived, offInfoReceived, isTma, isPageReload, }: BiometryOptions);
25
+ /**
26
+ * Signal indicating if biometry is available.
27
+ */
28
+ readonly isAvailable: Computed<boolean>;
29
+ /**
30
+ * Signal indicating if the component is supported.
31
+ */
32
+ readonly isSupported: Computed<boolean>;
33
+ /**
34
+ * Signal indicating if the component is mounted.
35
+ */
36
+ readonly isMounted: Computed<boolean>;
37
+ /**
38
+ * Complete component state.
39
+ */
40
+ readonly state: Computed<BiometryState>;
41
+ /**
42
+ * Attempts to authenticate a user using biometrics and fetch a previously stored secure token.
43
+ * @param options - method options.
44
+ * @since Mini Apps v7.2
45
+ * @returns Token from the local secure storage saved previously or undefined.
46
+ * @example
47
+ * const { status, token } = await biometry.authenticate({
48
+ * reason: 'Authenticate to open wallet',
49
+ * });
50
+ */
51
+ readonly authenticateFp: WithChecksFp<(options?: BiometryAuthenticateOptions) => BiometryTask<{
52
+ /**
53
+ * Authentication status.
54
+ */
55
+ status: BiometryAuthRequestStatus;
56
+ /**
57
+ * Token from the local secure storage saved previously.
58
+ */
59
+ token?: string;
60
+ }>, true>;
61
+ /**
62
+ * @see authenticateFp
63
+ */
64
+ readonly authenticate: WithChecks<(options?: BiometryAuthenticateOptions) => BetterPromise<AuthenticateResult>, true>;
65
+ /**
66
+ * Opens the biometric access settings for bots. Useful when you need to request biometrics
67
+ * access to users who haven't granted it yet.
68
+ *
69
+ * _Note that this method can be called only in response to user interaction with the Mini App
70
+ * interface (e.g. a click inside the Mini App or on the main button)_.
71
+ * @since Mini Apps v7.2
72
+ */
73
+ readonly openSettingsFp: WithChecksFp<() => E.Either<PostEventError, void>, true>;
74
+ /**
75
+ * @see openSettingsFp
76
+ */
77
+ readonly openSettings: WithChecks<() => void, true>;
78
+ /**
79
+ * Requests permission to use biometrics.
80
+ * @since Mini Apps v7.2
81
+ * @returns Promise with true, if access was granted.
82
+ * @example
83
+ * const accessGranted = await biometry.requestAccess({
84
+ * reason: 'Authenticate to open wallet',
85
+ * });
86
+ */
87
+ readonly requestAccessFp: WithChecksFp<(options?: BiometryRequestAccessOptions) => BiometryTask<boolean>, true>;
88
+ /**
89
+ * @see requestAccessFp
90
+ */
91
+ readonly requestAccess: WithChecks<(options?: BiometryRequestAccessOptions) => BetterPromise<boolean>, true>;
92
+ /**
93
+ * Updates the biometric token in a secure storage on the device.
94
+ * @since Mini Apps v7.2
95
+ * @returns Promise with `true`, if token was updated.
96
+ * @example Setting a new token
97
+ * biometry.updateToken({
98
+ * token: 'abcdef',
99
+ * })
100
+ * @example Deleting the token
101
+ * biometry.updateToken();
102
+ */
103
+ readonly updateTokenFp: WithChecksFp<(options?: BiometryUpdateTokenOptions) => BiometryTask<BiometryTokenUpdateStatus>, true>;
104
+ /**
105
+ * @see updateTokenFp
106
+ */
107
+ readonly updateToken: WithChecks<(options?: BiometryUpdateTokenOptions) => BetterPromise<BiometryTokenUpdateStatus>, true>;
108
+ /**
109
+ * Mounts the component restoring its state.
110
+ * @since Mini Apps v7.2
111
+ */
112
+ readonly mountFp: WithChecksFp<(options?: AsyncOptions) => BiometryTask<void>, true>;
113
+ /**
114
+ * @see mountFp
115
+ */
116
+ readonly mount: WithChecks<(options?: AsyncOptions) => BetterPromise<void>, true>;
117
+ /**
118
+ * Unmounts the component.
119
+ */
120
+ readonly unmount: () => void;
121
+ }
122
+ export {};
@@ -0,0 +1,3 @@
1
+ export { Biometry } from './Biometry.js';
2
+ export { biometry } from './instance.js';
3
+ export type { BiometryState, BiometryUpdateTokenOptions, BiometryAuthenticateOptions, BiometryRequestAccessOptions, } from './types.js';
@@ -0,0 +1,2 @@
1
+ import { Biometry } from './Biometry.js';
2
+ export declare const biometry: Biometry;
@@ -0,0 +1,84 @@
1
+ import { BiometryType, EventListener } from '@tma.js/bridge';
2
+ import { Maybe } from '@tma.js/toolkit';
3
+ import { AsyncOptions } from '../../types.js';
4
+ import { WithVersion } from '../../fn-options/withVersion.js';
5
+ import { WithStateRestore } from '../../fn-options/withStateRestore.js';
6
+ import { WithRequest } from '../../fn-options/withRequest.js';
7
+ import { WithPostEvent } from '../../fn-options/withPostEvent.js';
8
+ import { SharedFeatureOptions } from '../../fn-options/sharedFeatureOptions.js';
9
+ export interface BiometryState {
10
+ /**
11
+ * If true, indicates that biometric authentication is available on the current device.
12
+ */
13
+ available: boolean;
14
+ /**
15
+ * Indicates whether the app has previously requested permission to use biometrics.
16
+ */
17
+ accessRequested: boolean;
18
+ /**
19
+ * Indicates whether the user has granted the app permission to use biometrics.
20
+ *
21
+ * If false and access_requested is true may indicate that:
22
+ *
23
+ * - The user has simply canceled the permission popup, in which case
24
+ * a `web_app_biometry_request_access` event can be emitted to re-open the popup.
25
+ *
26
+ * - The user has denied the app permission to use biometrics, in which case the app should
27
+ * open a prompt notifying the user that the biometric settings must be changed to use
28
+ * biometrics.
29
+ */
30
+ accessGranted: boolean;
31
+ /**
32
+ * A unique device identifier that can be used to match the token to the device.
33
+ */
34
+ deviceId: string;
35
+ /**
36
+ * Show whether a token was safely stored on-device.
37
+ */
38
+ tokenSaved: boolean;
39
+ /**
40
+ * The type of biometrics currently available on the device.
41
+ */
42
+ type: BiometryType;
43
+ /**
44
+ * Last retrieved token.
45
+ */
46
+ token?: string;
47
+ }
48
+ export interface BiometryAuthenticateOptions extends AsyncOptions {
49
+ /**
50
+ * Reason to request biometry data. Should be at least 1 symbol length, but not more than
51
+ * 128 symbols.
52
+ */
53
+ reason?: Maybe<string>;
54
+ }
55
+ export interface BiometryUpdateTokenOptions extends AsyncOptions {
56
+ /**
57
+ * Optional string field, containing the reason why the bot is asking to authenticate using biometrics (1-128 chars, used in the prompt).
58
+ */
59
+ reason?: string;
60
+ /**
61
+ * Token to save in the local device secure storage. Passing `null`, `undefined` or empty string
62
+ * removes it from the storage.
63
+ */
64
+ token?: Maybe<string>;
65
+ }
66
+ export interface BiometryRequestAccessOptions extends AsyncOptions {
67
+ /**
68
+ * The text to be displayed to a user in the popup describing why the bot needs access to
69
+ * biometrics, 0-128 characters.
70
+ */
71
+ reason?: Maybe<string>;
72
+ }
73
+ export interface BiometryOptions extends WithVersion, WithStateRestore<BiometryState>, WithRequest, WithPostEvent, SharedFeatureOptions {
74
+ /**
75
+ * Adds a biometry info received event listener.
76
+ * @param listener - a listener to add.
77
+ */
78
+ onInfoReceived: (listener: EventListener<'biometry_info_received'>) => void;
79
+ /**
80
+ * Removes a biometry info received event listener.
81
+ * @param listener - a listener to add.
82
+ */
83
+ offInfoReceived: (listener: EventListener<'biometry_info_received'>) => void;
84
+ }