dop-sdk
Version:
Mini App SDK for JavaScript by VTB
122 lines (121 loc) • 5.81 kB
TypeScript
import { CloseAlertInfo } from '../types/close-alert';
import { HostThemeColor } from '../types/host-color-scheme';
import { MAAnalyticsInfo } from '../types/analytics/analytics';
import { MiniAppError } from '../types/error-types';
/**
* Mini App Utility methods
*/
export interface MiniAppUtilsProvider {
/**
* Mini App can choose whether to display Close confirmation alert dialog when mini app is closed
* @param alertInfo - CloseAlertInfo object
*/
setCloseAlert(alertInfo: CloseAlertInfo): Promise<string>;
/**
* Mini App can be closed using this method, provided Host app is supporting this interface to close the miniapp.
* @param withConfirmation boolean value which will be used by the host app to show/hide close confirmation alert
* which should be set using `setCloseAlert` method in prior before calling this interface
*/
closeMiniApp(withConfirmation: boolean): Promise<string>;
/**
* Miniapp can notify the host app that it has finished loading using this call.
* Host app can implement this interface to perform any other actions after the miniapp has loaded.
*/
miniAppFinishedLoading(): Promise<string>;
/**
* Interface that is used to get the Color theme used in the Host application
*/
getHostAppThemeColors(): Promise<HostThemeColor | MiniAppError>;
/**
* Interface to check if the Device/Application is using Dark mode
*/
isDarkMode(): Promise<boolean | MiniAppError>;
/**
* Interface to send analytics to Host app
* @param analyticsInfo Analytics info
*/
sendAnalytics(analytics: MAAnalyticsInfo): Promise<string>;
/**
* Interface to get list of features supported by the SDK and Host
*/
getFeatureList(): Promise<string[] | MiniAppError>;
/**
* Interface to check if the device has the deeplink available.
*/
canOpenAppDeeplink(deeplinkURL: string): Promise<boolean>;
/**
* Interface to check if the application has whitelisted the deeplink
*/
isAppDeeplinkSupported(deeplinkURL: string): Promise<boolean>;
/**
* This interface will be used to launch the URL in external browser
* @param url Remote URL
*/
launchExternalBrowser(url: string): Promise<boolean | MiniAppError>;
/**
* This interface will be used to launch the URL in Internal browser
* @param url Remote URL
*/
launchInternalBrowser(url: string): Promise<boolean | MiniAppError>;
}
/** @internal */
export declare class MiniAppUtils implements MiniAppUtilsProvider {
/**
* Associating closeMiniApp function to MiniAppBridge object.
* @param {withConfirmation} boolean value which will be used by the host app to show/hide close confirmation alert
* which should be set using `setCloseAlert` method in prior before calling this interface
* @see {closeMiniApp}
*/
closeMiniApp(withConfirmation: boolean): Promise<string>;
/**
* Associating miniAppFinishedLoading function to MiniAppBridge object.
* @returns Promise resolve with string
* Host app can implement an interface miniAppFinishedLoading to perform any operations after the miniapp is loaded.
*/
miniAppFinishedLoading(): Promise<string>;
setCloseAlert(alertInfo: CloseAlertInfo): Promise<string>;
getHostAppThemeColors(): Promise<HostThemeColor | MiniAppError>;
isDarkMode(): Promise<boolean | MiniAppError>;
sendAnalytics(analytics: MAAnalyticsInfo): Promise<string>;
/**
* This interface will get you the list of all features that is supported by the SDK and Host application
* @returns List of features for eg., ["GET_UNIQUE_ID", "GET_USERNAME", "GET_PROFILE_PHOTO", "IS_DARK_MODE"]
*/
getFeatureList(): Promise<string[] | MiniAppError>;
/**
* This interface checks if the device contains/has the deeplink to launch
* @param deeplinkURL Deeplink URL that you wanted to check if the device can launch
* @returns true if device can find the deeplink available to launch
*/
canOpenAppDeeplink(deeplinkURL: string): Promise<boolean>;
/**
* This interface checks if the application supports launching the Deeplink URL,
* sometimes application has whitelist URL, so this interface helps to check it.
* @param deeplinkURL Deeplink URL that you wanted to check if the device can launch
* @returns true if device can find the deeplink available to launch
*/
isAppDeeplinkSupported(deeplinkURL: string): Promise<boolean>;
/**
* Launches the specified URL in an external browser.
* @param {string} url - The URL to be opened in the external browser.
* @returns {Promise<boolean>} - A promise that resolves to true if the URL was successfully opened, otherwise rejects with an error.
* @see {launchExternalBrowser}
*/
launchExternalBrowser(url: string): Promise<boolean | MiniAppError>;
/**
* Launches the specified URL in an internal browser.
* @param {string} url - The URL to be opened in the internal browser.
* @returns {Promise<boolean>} - A promise that resolves to true if the URL was successfully opened, otherwise rejects with an error.
* @see {launchInternalBrowser}
*/
launchInternalBrowser(url: string): Promise<boolean | MiniAppError>;
/**
* Converts a list of Blob objects to a list of number arrays.
* Each Blob is converted to an ArrayBuffer, which is then converted to a Uint8Array.
* The Uint8Array is converted to a regular array of numbers.
*
* @param imageBlob - An optional of Blob object to be converted.
* @returns A promise that resolves to an array of number arrays.
*/
static convertBlobToNumberArray(imageBlob?: Blob): Promise<number[]>;
}