@tma.js/sdk 2.7.0 → 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.
- package/LICENSE +1 -1
- package/README.md +9 -9
- package/dist/dts/composables/AsyncMountable.d.ts +44 -0
- package/dist/dts/composables/Button.d.ts +140 -0
- package/dist/dts/composables/Mountable.d.ts +43 -0
- package/dist/dts/composables/Stateful.d.ts +35 -0
- package/dist/dts/errors.d.ts +41 -0
- package/dist/dts/features/BackButton/BackButton.d.ts +96 -0
- package/dist/dts/features/BackButton/exports.d.ts +2 -0
- package/dist/dts/features/BackButton/instance.d.ts +2 -0
- package/dist/dts/features/Biometry/Biometry.d.ts +122 -0
- package/dist/dts/features/Biometry/exports.d.ts +3 -0
- package/dist/dts/features/Biometry/instance.d.ts +2 -0
- package/dist/dts/features/Biometry/types.d.ts +84 -0
- package/dist/dts/features/ClosingBehavior/ClosingBehavior.d.ts +51 -0
- package/dist/dts/features/ClosingBehavior/exports.d.ts +2 -0
- package/dist/dts/features/ClosingBehavior/instance.d.ts +2 -0
- package/dist/dts/features/CloudStorage/CloudStorage.d.ts +90 -0
- package/dist/dts/features/CloudStorage/exports.d.ts +2 -0
- package/dist/dts/features/CloudStorage/instance.d.ts +2 -0
- package/dist/dts/features/HapticFeedback/HapticFeedback.d.ts +57 -0
- package/dist/dts/features/HapticFeedback/exports.d.ts +2 -0
- package/dist/dts/features/HapticFeedback/instance.d.ts +2 -0
- package/dist/dts/features/InitData/InitData.d.ts +84 -0
- package/dist/dts/features/InitData/exports.d.ts +2 -0
- package/dist/dts/features/InitData/instance.d.ts +2 -0
- package/dist/dts/features/Invoice/Invoice.d.ts +54 -0
- package/dist/dts/features/Invoice/exports.d.ts +2 -0
- package/dist/dts/features/Invoice/instance.d.ts +2 -0
- package/dist/dts/features/LocationManager/LocationManager.d.ts +74 -0
- package/dist/dts/features/LocationManager/exports.d.ts +3 -0
- package/dist/dts/features/LocationManager/instance.d.ts +2 -0
- package/dist/dts/features/LocationManager/types.d.ts +65 -0
- package/dist/dts/features/MainButton/MainButton.d.ts +214 -0
- package/dist/dts/features/MainButton/exports.d.ts +2 -0
- package/dist/dts/features/MainButton/instance.d.ts +2 -0
- package/dist/dts/features/MiniApp/MiniApp.d.ts +192 -0
- package/dist/dts/features/MiniApp/exports.d.ts +2 -0
- package/dist/dts/features/MiniApp/instance.d.ts +2 -0
- package/dist/dts/features/Popup/Popup.d.ts +56 -0
- package/dist/dts/features/Popup/exports.d.ts +3 -0
- package/dist/dts/features/Popup/instance.d.ts +2 -0
- package/dist/dts/features/Popup/prepareParams.d.ts +9 -0
- package/dist/dts/{components → features}/Popup/types.d.ts +5 -12
- package/dist/dts/features/QrScanner/QrScanner.d.ts +132 -0
- package/dist/dts/features/QrScanner/exports.d.ts +2 -0
- package/dist/dts/features/QrScanner/instance.d.ts +2 -0
- package/dist/dts/features/SecondaryButton/SecondaryButton.d.ts +253 -0
- package/dist/dts/features/SecondaryButton/exports.d.ts +2 -0
- package/dist/dts/features/SecondaryButton/instance.d.ts +2 -0
- package/dist/dts/features/SettingsButton/SettingsButton.d.ts +96 -0
- package/dist/dts/features/SettingsButton/exports.d.ts +2 -0
- package/dist/dts/features/SettingsButton/instance.d.ts +2 -0
- package/dist/dts/features/SwipeBehavior/SwipeBehavior.d.ts +62 -0
- package/dist/dts/features/SwipeBehavior/exports.d.ts +2 -0
- package/dist/dts/features/SwipeBehavior/instance.d.ts +2 -0
- package/dist/dts/features/ThemeParams/ThemeParams.d.ts +127 -0
- package/dist/dts/features/ThemeParams/exports.d.ts +2 -0
- package/dist/dts/features/ThemeParams/instance.d.ts +2 -0
- package/dist/dts/features/Viewport/Viewport.d.ts +220 -0
- package/dist/dts/features/Viewport/exports.d.ts +2 -0
- package/dist/dts/features/Viewport/instance.d.ts +2 -0
- package/dist/dts/features/emoji-status/exports.d.ts +2 -0
- package/dist/dts/features/emoji-status/requestEmojiStatusAccess.d.ts +16 -0
- package/dist/dts/features/emoji-status/setEmojiStatus.d.ts +28 -0
- package/dist/dts/features/home-screen/addToHomeScreen.d.ts +11 -0
- package/dist/dts/features/home-screen/checkHomeScreenStatus.d.ts +14 -0
- package/dist/dts/features/home-screen/exports.d.ts +2 -0
- package/dist/dts/features/links/exports.d.ts +3 -0
- package/dist/dts/features/links/openLink.d.ts +31 -0
- package/dist/dts/features/links/openTelegramLink.d.ts +18 -0
- package/dist/dts/features/links/shareURL.d.ts +18 -0
- package/dist/dts/features/privacy/exports.d.ts +3 -0
- package/dist/dts/features/privacy/requestContact.d.ts +59 -0
- package/dist/dts/features/privacy/requestPhoneAccess.d.ts +19 -0
- package/dist/dts/features/privacy/requestWriteAccess.d.ts +14 -0
- package/dist/dts/features/uncategorized/copyTextToClipboard.d.ts +5 -0
- package/dist/dts/features/uncategorized/downloadFile.d.ts +21 -0
- package/dist/dts/features/uncategorized/exports.d.ts +11 -0
- package/dist/dts/features/uncategorized/getCurrentTime.d.ts +15 -0
- package/dist/dts/features/uncategorized/hideKeyboard.d.ts +13 -0
- package/dist/dts/features/uncategorized/readTextFromClipboard.d.ts +13 -0
- package/dist/dts/features/uncategorized/retrieveAndroidDeviceData.d.ts +6 -0
- package/dist/dts/features/uncategorized/retrieveAndroidDeviceDataFrom.d.ts +14 -0
- package/dist/dts/features/uncategorized/sendData.d.ts +20 -0
- package/dist/dts/features/uncategorized/shareMessage.d.ts +14 -0
- package/dist/dts/features/uncategorized/shareStory.d.ts +50 -0
- package/dist/dts/features/uncategorized/switchInlineQuery.d.ts +28 -0
- package/dist/dts/fn-options/bottomButtonOptions.d.ts +11 -0
- package/dist/dts/fn-options/buttonOptions.d.ts +10 -0
- package/dist/dts/fn-options/createFnOption.d.ts +2 -0
- package/dist/dts/fn-options/sharedFeatureOptions.d.ts +8 -0
- package/dist/dts/fn-options/withInvokeCustomMethod.d.ts +11 -0
- package/dist/dts/fn-options/withPostEvent.d.ts +8 -0
- package/dist/dts/fn-options/withRequest.d.ts +8 -0
- package/dist/dts/fn-options/withStateRestore.d.ts +13 -0
- package/dist/dts/fn-options/withVersion.d.ts +9 -0
- package/dist/dts/globals/createRequestId.d.ts +4 -0
- package/dist/dts/globals/inline-mode.d.ts +4 -0
- package/dist/dts/globals/invokeCustomMethod.d.ts +16 -0
- package/dist/dts/globals/post-event.d.ts +4 -0
- package/dist/dts/globals/request.d.ts +3 -0
- package/dist/dts/globals/resetGlobals.d.ts +4 -0
- package/dist/dts/globals/signals-registry.d.ts +39 -0
- package/dist/dts/globals/themeParams.d.ts +4 -0
- package/dist/dts/globals/version.d.ts +4 -0
- package/dist/dts/helpers/access.d.ts +2 -0
- package/dist/dts/helpers/component-storage.d.ts +9 -0
- package/dist/dts/helpers/createIsSupportedSignal.d.ts +5 -0
- package/dist/dts/helpers/css-vars.d.ts +11 -0
- package/dist/dts/helpers/isColorDark.d.ts +11 -0
- package/dist/dts/{navigation/isPageReload.d.ts → helpers/navigation.d.ts} +1 -1
- package/dist/dts/helpers/removeUndefined.d.ts +10 -0
- package/dist/dts/helpers/shallowEqual.d.ts +1 -0
- package/dist/dts/index.d.ts +33 -168
- package/dist/dts/init.d.ts +42 -0
- package/dist/dts/types.d.ts +6 -0
- package/dist/dts/with-checks/throwifyWithChecksFp.d.ts +3 -0
- package/dist/dts/with-checks/withChecksFp.d.ts +172 -0
- package/dist/index.cjs +1 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.iife.js +3 -3
- package/dist/index.iife.js.map +1 -1
- package/dist/index.js +3811 -2897
- package/dist/index.js.map +1 -1
- package/package.json +19 -9
- package/dist/dts/bridge/captureSameReq.d.ts +0 -10
- package/dist/dts/bridge/events/event-emitter/createMiniAppsEventEmitter.d.ts +0 -15
- package/dist/dts/bridge/events/event-emitter/singleton.d.ts +0 -8
- package/dist/dts/bridge/events/event-handlers/cleanupEventHandlers.d.ts +0 -4
- package/dist/dts/bridge/events/event-handlers/defineEventHandlers.d.ts +0 -6
- package/dist/dts/bridge/events/event-handlers/emitMiniAppsEvent.d.ts +0 -9
- package/dist/dts/bridge/events/listening/off.d.ts +0 -8
- package/dist/dts/bridge/events/listening/on.d.ts +0 -12
- package/dist/dts/bridge/events/listening/subscribe.d.ts +0 -9
- package/dist/dts/bridge/events/listening/unsubscribe.d.ts +0 -7
- package/dist/dts/bridge/events/types.d.ts +0 -302
- package/dist/dts/bridge/invokeCustomMethod.d.ts +0 -23
- package/dist/dts/bridge/methods/createPostEvent.d.ts +0 -14
- package/dist/dts/bridge/methods/postEvent.d.ts +0 -40
- package/dist/dts/bridge/methods/types/custom-methods.d.ts +0 -57
- package/dist/dts/bridge/methods/types/haptic.d.ts +0 -40
- package/dist/dts/bridge/methods/types/index.d.ts +0 -4
- package/dist/dts/bridge/methods/types/methods.d.ts +0 -392
- package/dist/dts/bridge/methods/types/popup.d.ts +0 -49
- package/dist/dts/bridge/parseMessage.d.ts +0 -18
- package/dist/dts/bridge/request.d.ts +0 -53
- package/dist/dts/bridge/target-origin.d.ts +0 -18
- package/dist/dts/classes/State/State.d.ts +0 -46
- package/dist/dts/classes/State/types.d.ts +0 -29
- package/dist/dts/classes/WithStateUtils.d.ts +0 -18
- package/dist/dts/classes/WithSupports.d.ts +0 -19
- package/dist/dts/classes/WithSupportsAndStateUtils.d.ts +0 -24
- package/dist/dts/classes/WithSupportsAndTrackableState.d.ts +0 -16
- package/dist/dts/classes/WithTrackableState.d.ts +0 -16
- package/dist/dts/classnames/classNames.d.ts +0 -12
- package/dist/dts/classnames/mergeClassNames.d.ts +0 -14
- package/dist/dts/colors/isColorDark.d.ts +0 -6
- package/dist/dts/colors/isRGB.d.ts +0 -7
- package/dist/dts/colors/isRGBShort.d.ts +0 -7
- package/dist/dts/colors/toRGB.d.ts +0 -12
- package/dist/dts/colors/types.d.ts +0 -8
- package/dist/dts/components/BackButton/BackButton.d.ts +0 -41
- package/dist/dts/components/BackButton/initBackButton.d.ts +0 -7
- package/dist/dts/components/BackButton/types.d.ts +0 -25
- package/dist/dts/components/BiometryManager/BiometryManager.d.ts +0 -61
- package/dist/dts/components/BiometryManager/formatEvent.d.ts +0 -34
- package/dist/dts/components/BiometryManager/initBiometryManager.d.ts +0 -7
- package/dist/dts/components/BiometryManager/requestBiometryInfo.d.ts +0 -8
- package/dist/dts/components/BiometryManager/types.d.ts +0 -40
- package/dist/dts/components/ClosingBehavior/ClosingBehavior.d.ts +0 -26
- package/dist/dts/components/ClosingBehavior/initClosingBehavior.d.ts +0 -7
- package/dist/dts/components/ClosingBehavior/types.d.ts +0 -20
- package/dist/dts/components/CloudStorage/CloudStorage.d.ts +0 -47
- package/dist/dts/components/CloudStorage/initCloudStorage.d.ts +0 -7
- package/dist/dts/components/HapticFeedback/HapticFeedback.d.ts +0 -34
- package/dist/dts/components/HapticFeedback/initHapticFeedback.d.ts +0 -7
- package/dist/dts/components/InitData/InitData.d.ts +0 -55
- package/dist/dts/components/InitData/initInitData.d.ts +0 -7
- package/dist/dts/components/InitData/parseInitData.d.ts +0 -7
- package/dist/dts/components/InitData/parsers/chat.d.ts +0 -3
- package/dist/dts/components/InitData/parsers/initData.d.ts +0 -7
- package/dist/dts/components/InitData/parsers/user.d.ts +0 -3
- package/dist/dts/components/InitData/types.d.ts +0 -132
- package/dist/dts/components/Invoice/Invoice.d.ts +0 -31
- package/dist/dts/components/Invoice/initInvoice.d.ts +0 -7
- package/dist/dts/components/Invoice/types.d.ts +0 -20
- package/dist/dts/components/MainButton/MainButton.d.ts +0 -106
- package/dist/dts/components/MainButton/initMainButton.d.ts +0 -7
- package/dist/dts/components/MainButton/types.d.ts +0 -40
- package/dist/dts/components/MiniApp/MiniApp.d.ts +0 -121
- package/dist/dts/components/MiniApp/initMiniApp.d.ts +0 -7
- package/dist/dts/components/MiniApp/parsing/contact.d.ts +0 -7
- package/dist/dts/components/MiniApp/types.d.ts +0 -53
- package/dist/dts/components/Popup/Popup.d.ts +0 -30
- package/dist/dts/components/Popup/initPopup.d.ts +0 -7
- package/dist/dts/components/Popup/preparePopupParams.d.ts +0 -8
- package/dist/dts/components/QRScanner/QRScanner.d.ts +0 -33
- package/dist/dts/components/QRScanner/initQRScanner.d.ts +0 -7
- package/dist/dts/components/QRScanner/types.d.ts +0 -31
- package/dist/dts/components/SettingsButton/SettingsButton.d.ts +0 -37
- package/dist/dts/components/SettingsButton/initSettingsButton.d.ts +0 -7
- package/dist/dts/components/SettingsButton/types.d.ts +0 -25
- package/dist/dts/components/ThemeParams/ThemeParams.d.ts +0 -57
- package/dist/dts/components/ThemeParams/initThemeParams.d.ts +0 -7
- package/dist/dts/components/ThemeParams/keys.d.ts +0 -11
- package/dist/dts/components/ThemeParams/parsing/parseThemeParams.d.ts +0 -7
- package/dist/dts/components/ThemeParams/parsing/serializeThemeParams.d.ts +0 -6
- package/dist/dts/components/ThemeParams/parsing/themeParams.d.ts +0 -4
- package/dist/dts/components/ThemeParams/requestThemeParams.d.ts +0 -8
- package/dist/dts/components/ThemeParams/types.d.ts +0 -29
- package/dist/dts/components/Utils/Utils.d.ts +0 -77
- package/dist/dts/components/Utils/initUtils.d.ts +0 -7
- package/dist/dts/components/Viewport/Viewport.d.ts +0 -77
- package/dist/dts/components/Viewport/initViewport.d.ts +0 -7
- package/dist/dts/components/Viewport/requestViewport.d.ts +0 -13
- package/dist/dts/components/Viewport/types.d.ts +0 -35
- package/dist/dts/css-vars/bindMiniAppCSSVars.d.ts +0 -29
- package/dist/dts/css-vars/bindThemeParamsCSSVars.d.ts +0 -29
- package/dist/dts/css-vars/bindViewportCSSVars.d.ts +0 -32
- package/dist/dts/css-vars/setCSSVar.d.ts +0 -6
- package/dist/dts/debug/debug.d.ts +0 -14
- package/dist/dts/env/hasExternalNotify.d.ts +0 -10
- package/dist/dts/env/hasWebviewProxy.d.ts +0 -10
- package/dist/dts/env/initWeb.d.ts +0 -11
- package/dist/dts/env/isIframe.d.ts +0 -5
- package/dist/dts/env/isSSR.d.ts +0 -4
- package/dist/dts/env/isTMA.d.ts +0 -4
- package/dist/dts/env/mockTelegramEnv.d.ts +0 -7
- package/dist/dts/errors/SDKError.d.ts +0 -9
- package/dist/dts/errors/createError.d.ts +0 -10
- package/dist/dts/errors/errors.d.ts +0 -49
- package/dist/dts/errors/isSDKError.d.ts +0 -7
- package/dist/dts/errors/isSDKErrorOfType.d.ts +0 -8
- package/dist/dts/events/event-emitter/EventEmitter.d.ts +0 -54
- package/dist/dts/events/event-emitter/types.d.ts +0 -45
- package/dist/dts/events/onWindow.d.ts +0 -10
- package/dist/dts/events/types.d.ts +0 -6
- package/dist/dts/index.low-level.d.ts +0 -41
- package/dist/dts/launch-params/parseLaunchParams.d.ts +0 -7
- package/dist/dts/launch-params/retrieveFromLocation.d.ts +0 -7
- package/dist/dts/launch-params/retrieveFromPerformance.d.ts +0 -7
- package/dist/dts/launch-params/retrieveFromStorage.d.ts +0 -7
- package/dist/dts/launch-params/retrieveFromUrl.d.ts +0 -8
- package/dist/dts/launch-params/retrieveLaunchParams.d.ts +0 -7
- package/dist/dts/launch-params/saveToStorage.d.ts +0 -7
- package/dist/dts/launch-params/serializeLaunchParams.d.ts +0 -7
- package/dist/dts/launch-params/types.d.ts +0 -51
- package/dist/dts/logger/Logger.d.ts +0 -29
- package/dist/dts/misc/createCleanup.d.ts +0 -11
- package/dist/dts/misc/createComponentInitFn/createComponentInitFn.d.ts +0 -16
- package/dist/dts/misc/createComponentInitFn/types.d.ts +0 -54
- package/dist/dts/misc/createSingleton.d.ts +0 -15
- package/dist/dts/misc/isRecord.d.ts +0 -5
- package/dist/dts/misc/objectFromKeys.d.ts +0 -6
- package/dist/dts/navigation/BasicNavigator/BasicNavigator.d.ts +0 -118
- package/dist/dts/navigation/BasicNavigator/prepareItem.d.ts +0 -8
- package/dist/dts/navigation/BasicNavigator/types.d.ts +0 -37
- package/dist/dts/navigation/BrowserNavigator/BrowserNavigator.d.ts +0 -198
- package/dist/dts/navigation/BrowserNavigator/basicItemToBrowser.d.ts +0 -7
- package/dist/dts/navigation/BrowserNavigator/createBrowserNavigatorFromLocation.d.ts +0 -4
- package/dist/dts/navigation/BrowserNavigator/prepareItem.d.ts +0 -25
- package/dist/dts/navigation/BrowserNavigator/types.d.ts +0 -64
- package/dist/dts/navigation/createSafeURL.d.ts +0 -7
- package/dist/dts/navigation/drop.d.ts +0 -4
- package/dist/dts/navigation/ensurePrefix.d.ts +0 -7
- package/dist/dts/navigation/getFirstNavigationEntry.d.ts +0 -6
- package/dist/dts/navigation/getHash.d.ts +0 -15
- package/dist/dts/navigation/getPathname.d.ts +0 -7
- package/dist/dts/navigation/go.d.ts +0 -5
- package/dist/dts/navigation/initNavigator.d.ts +0 -9
- package/dist/dts/navigation/urlToPath.d.ts +0 -7
- package/dist/dts/parsing/ArrayParser/ArrayParser.d.ts +0 -17
- package/dist/dts/parsing/ArrayParser/types.d.ts +0 -12
- package/dist/dts/parsing/ValueParser/ValueParser.d.ts +0 -17
- package/dist/dts/parsing/ValueParser/types.d.ts +0 -28
- package/dist/dts/parsing/createTypeError.d.ts +0 -6
- package/dist/dts/parsing/createValueParserGenerator.d.ts +0 -10
- package/dist/dts/parsing/parseBySchema.d.ts +0 -9
- package/dist/dts/parsing/parsers/array.d.ts +0 -7
- package/dist/dts/parsing/parsers/boolean.d.ts +0 -6
- package/dist/dts/parsing/parsers/date.d.ts +0 -6
- package/dist/dts/parsing/parsers/json.d.ts +0 -9
- package/dist/dts/parsing/parsers/number.d.ts +0 -6
- package/dist/dts/parsing/parsers/rgb.d.ts +0 -7
- package/dist/dts/parsing/parsers/searchParams.d.ts +0 -9
- package/dist/dts/parsing/parsers/string.d.ts +0 -6
- package/dist/dts/parsing/toRecord.d.ts +0 -7
- package/dist/dts/parsing/types.d.ts +0 -30
- package/dist/dts/request-id/createRequestIdGenerator.d.ts +0 -6
- package/dist/dts/request-id/types.d.ts +0 -9
- package/dist/dts/storage/storage.d.ts +0 -42
- package/dist/dts/supports/createSupportsFn.d.ts +0 -12
- package/dist/dts/supports/createSupportsParamFn.d.ts +0 -16
- package/dist/dts/supports/supports.d.ts +0 -16
- package/dist/dts/supports/types.d.ts +0 -4
- package/dist/dts/timeout/createTimeoutError.d.ts +0 -7
- package/dist/dts/timeout/sleep.d.ts +0 -5
- package/dist/dts/timeout/withTimeout.d.ts +0 -6
- package/dist/dts/types/index.d.ts +0 -6
- package/dist/dts/types/logical.d.ts +0 -16
- package/dist/dts/types/methods.d.ts +0 -16
- package/dist/dts/types/misc.d.ts +0 -12
- package/dist/dts/types/platform.d.ts +0 -4
- package/dist/dts/types/unions.d.ts +0 -20
- package/dist/dts/types/utils.d.ts +0 -24
- package/dist/dts/version/compareVersions.d.ts +0 -10
- package/dist/dts/version/types.d.ts +0 -5
- package/dist/index.low-level.iife.js +0 -4
- package/dist/index.low-level.iife.js.map +0 -1
package/LICENSE
CHANGED
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
|
-
[
|
|
7
|
+
[link]: https://github.com/Telegram-Mini-Apps/telegram-apps/tree/master/tma.js/sdk
|
|
8
8
|
|
|
9
|
-
[
|
|
9
|
+
[docs-link]: https://docs.telegram-mini-apps.com/packages/tma-js-sdk
|
|
10
10
|
|
|
11
|
-
[
|
|
11
|
+
[npm-link]: https://npmjs.com/package/@tma.js/sdk
|
|
12
12
|
|
|
13
|
-
[
|
|
13
|
+
[npm-badge]: https://img.shields.io/npm/v/@tma.js/sdk?logo=npm
|
|
14
14
|
|
|
15
|
-
[
|
|
15
|
+
[size-badge]: https://img.shields.io/bundlephobia/minzip/@tma.js/sdk
|
|
16
16
|
|
|
17
|
-
[![NPM][
|
|
18
|
-
![Size][
|
|
19
|
-
[![docs-badge]][
|
|
20
|
-
[![code-badge]][
|
|
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,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,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
|
+
}
|