@btsd/aitu-bridge 0.3.55 → 0.3.56

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.umd.js","sources":["../src/utils.ts","../src/webBridge.ts","../src/index.ts","../src/version.ts"],"sourcesContent":["function createCounter(prefix = 'm:') {\n return {\n current: 0,\n next() {\n return prefix + ++this.current;\n },\n };\n}\n\nfunction createRequestResolver(prefix: string) {\n type PromiseController = {\n resolve: (value: any) => any;\n reject: (reason: any) => any;\n };\n\n const counter = createCounter(prefix);\n const promiseControllers: Record<string, PromiseController | null> = {};\n\n return {\n add(controller: PromiseController, customId = ''): number | string {\n const id = customId + counter.next()\n promiseControllers[id] = controller;\n return id;\n },\n\n resolve<T>(reqId: number | string, data: T, isSuccess: (data: T) => boolean, error: any) {\n const requestPromise = promiseControllers[reqId];\n\n if (requestPromise) {\n if (isSuccess(error)) {\n requestPromise.resolve(data);\n } else {\n requestPromise.reject(error);\n }\n\n promiseControllers[reqId] = null;\n }\n },\n };\n}\n\nfunction handleSubscribe(subscribe: (handler: (event: any) => void) => void, requestResolver: ReturnType<typeof createRequestResolver>) {\n subscribe(event => {\n if (!event.detail) {\n return;\n }\n\n if ('reqId' in event.detail) {\n const { reqId, data, error } = event.detail;\n\n if (reqId) {\n requestResolver.resolve(reqId, data, (error) => !(error), error);\n }\n }\n })\n}\n\nexport function promisifyStorage(storage, subscribe: (fn: any) => void) {\n const requestResolver = createRequestResolver('storage:');\n\n handleSubscribe(subscribe, requestResolver)\n\n return {\n setItem: (keyName: string, keyValue: string): Promise<void> => {\n return new Promise((resolve, reject) => {\n const reqId = requestResolver.add({ resolve, reject });\n storage(reqId, 'setItem', { keyName, keyValue });\n });\n },\n getItem: (keyName: string): Promise<string | null> => {\n return new Promise((resolve, reject) => {\n const reqId = requestResolver.add({ resolve, reject });\n storage(reqId, 'getItem', { keyName });\n });\n },\n clear: (): Promise<void> => {\n return new Promise((resolve, reject) => {\n const reqId = requestResolver.add({ resolve, reject });\n storage(reqId, 'clear', {});\n });\n },\n }\n}\n\nexport function promisifyInvoke(invoke, subscribe: (fn: any) => void) {\n const requestResolver = createRequestResolver('invoke:');\n\n handleSubscribe(subscribe, requestResolver)\n\n return function promisifiedFunc(invokeMethodName: string, props: any = {}): Promise<any | void> {\n return new Promise((resolve, reject) => {\n const reqId = requestResolver.add({ resolve, reject }, invokeMethodName + ':');\n\n invoke(reqId, invokeMethodName, props);\n });\n };\n}\n\nexport function promisifyMethod(method: Function, methodName: string, subscribe: (fn: any) => void) {\n const requestResolver = createRequestResolver(methodName + ':');\n\n handleSubscribe(subscribe, requestResolver)\n\n return function promisifiedFunc(...args: any[]): Promise<any | void> {\n return new Promise((resolve, reject) => {\n const reqId = requestResolver.add({ resolve, reject });\n method(reqId, ...args);\n });\n };\n}\n\n\n\n","import type { AituBridge } from './index';\n\nconst AITU_DOMAIN_PARAM = '__aitu-domain'\n\nconst searchParams = new URLSearchParams(window.location.search)\n\nlet aituOrigin = searchParams.get(AITU_DOMAIN_PARAM)\n\nif(aituOrigin){\n localStorage.setItem('mini-app-domain', aituOrigin)\n}else{\n aituOrigin = localStorage.getItem('mini-app-domain')\n}\ninterface WebBridge {\n execute(method: keyof AituBridge, reqId: string, ...payload: any[] ): void\n origin: string\n}\n\nlet WebBridge: WebBridge | null = null\n\nif (aituOrigin) {\n WebBridge = {\n origin: aituOrigin,\n execute: (method, reqId, ...payload) => {\n window.top.postMessage({\n source: 'aitu-bridge',\n method,\n reqId,\n payload: [...payload],\n },\n WebBridge.origin\n )\n }\n\n }\n window.addEventListener('message', event => {\n if (event.origin === aituOrigin && event.data) {\n\n // dispatch aitu events\n window.dispatchEvent(new CustomEvent('aituEvents', { detail: event.data }));\n\n // try to detect handler call\n if (typeof event.data !== 'string' || event.data === '') {\n return;\n }\n\n try {\n const message = JSON.parse(event.data)\n\n if (message && message['method']) {\n if (message.method === 'setCustomBackArrowOnClickHandler') {\n (window as any).onAituBridgeBackArrowClick()\n } else if (message.method === 'setHeaderMenuItemClickHandler') {\n (window as any).onAituBridgeHeaderMenuItemClick(message.param)\n }\n }\n } catch (e) {\n console.log('Error parsing message data: ' + e);\n }\n }\n })\n}\n\nexport default WebBridge\n","import { LIB_VERSION } from './version';\n\nimport {\n promisifyMethod,\n promisifyStorage,\n promisifyInvoke,\n} from './utils'\n\nimport WebBridge from './webBridge';\n\nenum EInvokeRequest {\n getMe = 'GetMe',\n getPhone = 'GetPhone',\n getContacts = 'GetContacts',\n getUserProfile = 'GetUserProfile',\n enableNotifications = 'AllowNotifications',\n disableNotifications = 'DisableNotifications',\n enablePrivateMessaging = 'EnablePrivateMessaging',\n disablePrivateMessaging = 'DisablePrivateMessaging',\n}\n\ntype SetItemType = (keyName: string, keyValue: string) => Promise<void>;\ntype GetItemType = (keyName: string) => Promise<string | null>;\ntype ClearType = () => Promise<void>;\n\ntype HeaderMenuItemClickHandlerType = (id: string) => Promise<void>;\ntype BackArrowClickHandlerType = () => Promise<void>;\n\nexport interface GetPhoneResponse {\n phone: string;\n sign: string;\n}\n\nexport interface GetMeResponse {\n name: string;\n lastname: string;\n id: string;\n avatar?: string;\n avatarThumb?: string;\n notifications_allowed: boolean;\n private_messaging_enabled: boolean;\n sign: string;\n}\n\nexport interface ResponseObject {\n phone?: string;\n name?: string;\n lastname?: string;\n}\n\nexport interface GetGeoResponse {\n latitude: number;\n longitude: number;\n}\n\nexport interface GetContactsResponse {\n contacts: Array<{\n first_name: string;\n last_name: string;\n phone: string;\n }>;\n sign: string;\n}\n\nexport interface SelectContactResponse {\n phone: string;\n name: string;\n lastname: string;\n}\n\nexport interface GetUserProfileResponse {\n name: string;\n lastname?: string;\n phone?: string;\n avatar?: string;\n avatarThumb?: string;\n}\n\nconst MAX_HEADER_MENU_ITEMS_COUNT = 3;\n\nexport enum HeaderMenuIcon {\n Search = \"Search\",\n ShoppingCart = \"ShoppingCart\",\n Menu = \"Menu\",\n Share = \"Share\",\n Notifications = \"Notifications\",\n Help = \"Help\",\n Error = \"Error\",\n Person = \"Person\",\n Sort = \"Sort\",\n Filter = \"Filter\",\n Close = \"Close\"\n}\n\nexport enum NavigationItemMode {\n SystemBackArrow = \"SystemBackArrow\",\n CustomBackArrow = \"CustomBackArrow\",\n NoItem = \"NoItem\",\n UserProfile = \"UserProfile\",\n}\n\nexport interface HeaderMenuItem {\n id: string;\n icon: HeaderMenuIcon;\n badge?: string;\n}\n\nexport interface UserStepsPerDay {\n date: string;\n steps: number;\n}\n\nexport interface UserStepInfoResponse {\n steps: UserStepsPerDay[];\n}\n\nexport class PermissionDeniedError extends Error {\n constructor() {\n super(\"No permission\");\n }\n}\n\ntype OpenSettingsResponse = 'success' | 'failed';\ntype ShareResponse = 'success' | 'failed';\ntype CopyToClipboardResponse = 'success' | 'failed';\ntype VibrateResponse = 'success' | 'failed';\n// todo: remove duplicates\ntype ResponseType = 'success' | 'failed';\n\ntype BridgeInvoke<T extends EInvokeRequest, R> = (method: T, data?: {}) => Promise<R>;\n\ninterface BridgeStorage {\n setItem: SetItemType,\n getItem: GetItemType,\n clear: ClearType\n}\n\nexport interface AituBridge {\n version: string;\n invoke: BridgeInvoke<EInvokeRequest, ResponseObject>;\n storage: BridgeStorage;\n getMe: () => Promise<GetMeResponse>;\n getPhone: () => Promise<GetPhoneResponse>;\n getContacts: () => Promise<GetContactsResponse>;\n getGeo: () => Promise<GetGeoResponse>;\n selectContact: () => Promise<SelectContactResponse>;\n getQr: () => Promise<string>;\n getSMSCode: () => Promise<string>;\n getUserProfile: (userId: string) => Promise<GetUserProfileResponse>;\n share: (text: string) => Promise<ShareResponse>;\n setTitle: (text: string) => Promise<ResponseType>;\n copyToClipboard: (text: string) => Promise<CopyToClipboardResponse>;\n shareImage: (text: string, image: string) => Promise<ShareResponse>;\n shareFile: (text: string, filename: string, base64Data: string) => Promise<ShareResponse>;\n enableNotifications: () => Promise<{}>;\n disableNotifications: () => Promise<{}>;\n enablePrivateMessaging: (appId: string) => Promise<string>;\n disablePrivateMessaging: (appId: string) => Promise<string>;\n openSettings: () => Promise<OpenSettingsResponse>;\n closeApplication: () => Promise<ResponseType>;\n setShakeHandler: (handler: any) => void;\n setTabActiveHandler: (handler: (tabname: string) => void) => void;\n vibrate: (pattern: number[]) => Promise<VibratePattern>;\n isSupported: () => boolean;\n supports: (method: string) => boolean;\n sub: any;\n enableScreenCapture: () => Promise<{}>;\n disableScreenCapture: () => Promise<{}>;\n setHeaderMenuItems: (items: Array<HeaderMenuItem>) => Promise<ResponseType>;\n setHeaderMenuItemClickHandler: (handler: HeaderMenuItemClickHandlerType) => void;\n setCustomBackArrowMode: (enabled: boolean) => Promise<ResponseType>;\n getCustomBackArrowMode: () => Promise<boolean>;\n setCustomBackArrowVisible: (visible: boolean) => Promise<ResponseType>;\n openPayment: (transactionId: string) => Promise<ResponseType>;\n setCustomBackArrowOnClickHandler: (handler: BackArrowClickHandlerType) => void;\n checkBiometry: () => Promise<ResponseType>;\n openExternalUrl: (url: string) => Promise<ResponseType>;\n enableSwipeBack: () => Promise<ResponseType>;\n disableSwipeBack: () => Promise<ResponseType>;\n setNavigationItemMode: (mode: NavigationItemMode) => Promise<void>;\n getNavigationItemMode: () => Promise<NavigationItemMode>;\n getUserStepInfo: () => Promise<UserStepInfoResponse>;\n}\n\nconst invokeMethod = 'invoke';\nconst storageMethod = 'storage';\nconst getGeoMethod = 'getGeo';\nconst getQrMethod = 'getQr';\nconst getSMSCodeMethod = 'getSMSCode';\nconst selectContactMethod = 'selectContact';\nconst openSettingsMethod = 'openSettings';\nconst closeApplicationMethod = 'closeApplication';\nconst shareMethod = 'share';\nconst setTitleMethod = 'setTitle';\nconst copyToClipboardMethod = 'copyToClipboard';\nconst shareImageMethod = 'shareImage';\nconst shareFileMethod = 'shareFile';\nconst setShakeHandlerMethod = 'setShakeHandler';\nconst vibrateMethod = 'vibrate';\nconst enableScreenCaptureMethod = 'enableScreenCapture';\nconst disableScreenCaptureMethod = 'disableScreenCapture';\nconst setTabActiveHandlerMethod = 'setTabActiveHandler';\nconst setHeaderMenuItemsMethod = 'setHeaderMenuItems';\nconst setHeaderMenuItemClickHandlerMethod = 'setHeaderMenuItemClickHandler';\nconst setCustomBackArrowModeMethod = 'setCustomBackArrowMode';\nconst getCustomBackArrowModeMethod = 'getCustomBackArrowMode';\nconst setCustomBackArrowVisibleMethod = 'setCustomBackArrowVisible';\nconst openPaymentMethod = 'openPayment'\nconst setCustomBackArrowOnClickHandlerMethod = 'setCustomBackArrowOnClickHandler';\nconst checkBiometryMethod = 'checkBiometry';\nconst openExternalUrlMethod = 'openExternalUrl';\nconst enableSwipeBackMethod = 'enableSwipeBack';\nconst disableSwipeBackMethod = 'disableSwipeBack';\nconst setNavigationItemModeMethod = 'setNavigationItemMode';\nconst getNavigationItemModeMethod = 'getNavigationItemMode';\nconst getUserStepInfoMethod = 'getUserStepInfo'\n\nconst android = typeof window !== 'undefined' && (window as any).AndroidBridge;\nconst ios = typeof window !== 'undefined' && (window as any).webkit && (window as any).webkit.messageHandlers;\nconst web = typeof window !== 'undefined' && (window.top !== window) && WebBridge;\n\nconst buildBridge = (): AituBridge => {\n const subs = [];\n\n if (typeof window !== 'undefined') {\n window.addEventListener('aituEvents', (e: any) => {\n [...subs].map((fn) => fn.call(null, e));\n })\n }\n\n const invoke = (reqId, method, data = {}) => {\n const isAndroid = android && android[invokeMethod];\n const isIos = ios && ios[invokeMethod];\n\n if (isAndroid) {\n android[invokeMethod](reqId, method, JSON.stringify(data));\n } else if (isIos) {\n ios[invokeMethod].postMessage({ reqId, method, data });\n } else if (web) {\n web.execute(invokeMethod, reqId, method, data)\n } else if (typeof window !== 'undefined') {\n console.log('--invoke-isUnknown');\n }\n };\n\n const storage = (reqId, method, data = {}) => {\n const isAndroid = android && android[storageMethod];\n const isIos = ios && ios[storageMethod];\n\n if (isAndroid) {\n android[storageMethod](reqId, method, JSON.stringify(data));\n } else if (isIos) {\n ios[storageMethod].postMessage({ reqId, method, data });\n } else if (web) {\n web.execute(storageMethod, reqId, method, data);\n } else if (typeof window !== 'undefined') {\n console.log('--storage-isUnknown');\n }\n }\n\n const getGeo = (reqId) => {\n const isAndroid = android && android[getGeoMethod];\n const isIos = ios && ios[getGeoMethod];\n\n if (isAndroid) {\n android[getGeoMethod](reqId);\n } else if (isIos) {\n ios[getGeoMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(getGeoMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--getGeo-isUnknown');\n }\n }\n\n const getQr = (reqId) => {\n const isAndroid = android && android[getQrMethod];\n const isIos = ios && ios[getQrMethod];\n\n if (isAndroid) {\n android[getQrMethod](reqId);\n } else if (isIos) {\n ios[getQrMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(getQrMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--getQr-isUnknown');\n }\n }\n\n const getSMSCode = (reqId) => {\n const isAndroid = android && android[getSMSCodeMethod];\n const isIos = ios && ios[getSMSCodeMethod];\n\n if (isAndroid) {\n android[getSMSCodeMethod](reqId);\n } else if (isIos) {\n ios[getSMSCodeMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(getSMSCodeMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--getSMSCode-isUnknown');\n }\n }\n\n const selectContact = (reqId) => {\n const isAndroid = android && android[selectContactMethod];\n const isIos = ios && ios[selectContactMethod];\n\n if (isAndroid) {\n android[selectContactMethod](reqId);\n } else if (isIos) {\n ios[selectContactMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(selectContactMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--selectContact-isUnknown');\n }\n }\n\n const openSettings = (reqId) => {\n const isAndroid = android && android[openSettingsMethod];\n const isIos = ios && ios[openSettingsMethod];\n\n if (isAndroid) {\n android[openSettingsMethod](reqId);\n } else if (isIos) {\n ios[openSettingsMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(openSettingsMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--openSettings-isUnknown');\n }\n }\n\n const closeApplication = (reqId) => {\n const isAndroid = android && android[closeApplicationMethod];\n const isIos = ios && ios[closeApplicationMethod];\n\n if (isAndroid) {\n android[closeApplicationMethod](reqId);\n } else if (isIos) {\n ios[closeApplicationMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(closeApplicationMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--closeApplication-isUnknown');\n }\n }\n\n const share = (reqId, text) => {\n const isAndroid = android && android[shareMethod];\n const isIos = ios && ios[shareMethod];\n\n if (isAndroid) {\n android[shareMethod](reqId, text);\n } else if (isIos) {\n ios[shareMethod].postMessage({ reqId, text });\n } else if (web) {\n web.execute(shareMethod, reqId, text);\n } else if (typeof window !== 'undefined') {\n console.log('--share-isUnknown');\n }\n }\n\n const setTitle = (reqId, text) => {\n const isAndroid = android && android[setTitleMethod];\n const isIos = ios && ios[setTitleMethod];\n\n if (isAndroid) {\n android[setTitleMethod](reqId, text);\n } else if (isIos) {\n ios[setTitleMethod].postMessage({ reqId, text });\n } else if (web) {\n web.execute(setTitleMethod, reqId, text);\n } else if (typeof window !== 'undefined') {\n console.log('--setTitle-isUnknown');\n }\n }\n\n const copyToClipboard = (reqId, text) => {\n const isAndroid = android && android[copyToClipboardMethod];\n const isIos = ios && ios[copyToClipboardMethod];\n\n if (isAndroid) {\n android[copyToClipboardMethod](reqId, text);\n } else if (isIos) {\n ios[copyToClipboardMethod].postMessage({ reqId, text });\n } else if (web) {\n web.execute(copyToClipboardMethod, reqId, text);\n } else if (typeof window !== 'undefined') {\n console.log('--copyToClipboard-isUnknown');\n }\n }\n\n const enableScreenCapture = (reqId) => {\n const isAndroid = android && android[enableScreenCaptureMethod];\n const isIos = ios && ios[enableScreenCaptureMethod];\n\n if (isAndroid) {\n android[enableScreenCaptureMethod](reqId);\n } else if (isIos) {\n ios[enableScreenCaptureMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(enableScreenCaptureMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--enableScreenCapture-isUnknown');\n }\n }\n\n const disableScreenCapture = (reqId) => {\n const isAndroid = android && android[disableScreenCaptureMethod];\n const isIos = ios && ios[disableScreenCaptureMethod];\n\n if (isAndroid) {\n android[disableScreenCaptureMethod](reqId);\n } else if (isIos) {\n ios[disableScreenCaptureMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(disableScreenCaptureMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--disableScreenCapture-isUnknown');\n }\n }\n\n const shareImage = (reqId, text, image) => {\n // !!!======================!!!\n // !!!===== Deprecated =====!!!\n // !!!======================!!!\n\n // const isAndroid = android && android[shareImageMethod];\n // const isIos = ios && ios[shareImageMethod];\n\n // if (isAndroid) {\n // android[shareImageMethod](reqId, text, image);\n // } else if (isIos) {\n // ios[shareImageMethod].postMessage({ reqId, text, image });\n // } else if (typeof window !== 'undefined') {\n // console.log('--shareImage-isWeb');\n // }\n\n // new one - fallback to shareFile\n const isAndroid = android && android[shareFileMethod];\n const isIos = ios && ios[shareFileMethod];\n\n // get extension from base64 mime type and merge with name\n const ext = image.split(';')[0].split('/')[1];\n const filename = 'image.' + ext;\n // remove mime type\n const base64Data = image.substr(image.indexOf(',') + 1);\n\n if (isAndroid) {\n android[shareFileMethod](reqId, text, filename, base64Data);\n } else if (isIos) {\n ios[shareFileMethod].postMessage({ reqId, text, filename, base64Data });\n } else if (web) {\n web.execute(shareFileMethod, reqId, { text, filename, base64Data });\n } else if (typeof window !== 'undefined') {\n console.log('--shareFile-isUnknown');\n }\n }\n\n const shareFile = (reqId, text, filename, base64Data) => {\n const isAndroid = android && android[shareFileMethod];\n const isIos = ios && ios[shareFileMethod];\n\n if (isAndroid) {\n android[shareFileMethod](reqId, text, filename, base64Data);\n } else if (isIos) {\n ios[shareFileMethod].postMessage({ reqId, text, filename, base64Data });\n } else if (web) {\n web.execute(shareFileMethod, reqId, text, filename, base64Data);\n } else if (typeof window !== 'undefined') {\n console.log('--shareFile-isUnknown');\n }\n }\n\n const enableNotifications = () => invokePromise(EInvokeRequest.enableNotifications);\n\n const disableNotifications = () => invokePromise(EInvokeRequest.disableNotifications);\n\n const setShakeHandler = (handler) => {\n const isAndroid = android && android[setShakeHandlerMethod];\n const isIos = ios && ios[setShakeHandlerMethod];\n\n if (isAndroid || isIos || web) {\n (window as any).onAituBridgeShake = handler;\n } else if (typeof window !== 'undefined') {\n console.log('--setShakeHandler-isUnknown');\n }\n };\n\n const setTabActiveHandler = (handler: (tabname: string) => void) => {\n const isAndroid = android && android[setTabActiveHandlerMethod];\n const isIos = ios && ios[setTabActiveHandlerMethod];\n\n if (isAndroid || isIos || web) {\n (window as any).onAituBridgeTabActive = handler;\n } else if (typeof window !== 'undefined') {\n console.log('--setTabActiveHandler-isUnknown');\n }\n };\n\n const vibrate = (reqId, pattern) => {\n if (\n !Array.isArray(pattern) ||\n pattern.some((timing) => timing < 1 || timing !== Math.floor(timing)) ||\n pattern.reduce((total, timing) => total + timing) > 10000\n ) {\n console.error('Pattern should be an array of positive integers no longer than 10000ms total');\n return;\n }\n\n const isAndroid = android && android[vibrateMethod];\n const isIos = ios && ios[vibrateMethod];\n\n if (isAndroid) {\n android[vibrateMethod](reqId, JSON.stringify(pattern));\n } else if (isIos) {\n ios[vibrateMethod].postMessage({ reqId, pattern });\n } else if (web) {\n web.execute(vibrateMethod, reqId, pattern);\n } else if (typeof window !== 'undefined') {\n console.log('--vibrate-isUnknown');\n }\n }\n\n const isSupported = () => {\n const iosSup = ios && (window as any).webkit.messageHandlers.invoke;\n return Boolean(android || iosSup || web);\n }\n\n // TODO: implement web support\n const supports = (method) =>\n (android && typeof android[method] === 'function') ||\n (ios && ios[method] && typeof ios[method].postMessage === 'function') ||\n (web && typeof web[method] === 'function');\n\n const sub = (listener: any) => {\n subs.push(listener);\n }\n\n const setHeaderMenuItems = (reqId, items: Array<HeaderMenuItem>) => {\n if (items.length > MAX_HEADER_MENU_ITEMS_COUNT) {\n console.error('SetHeaderMenuItems: items count should not be more than ' + MAX_HEADER_MENU_ITEMS_COUNT);\n return;\n }\n\n const isAndroid = android && android[setHeaderMenuItemsMethod];\n const isIos = ios && ios[setHeaderMenuItemsMethod];\n\n const itemsJsonArray = JSON.stringify(items);\n\n if (isAndroid) {\n android[setHeaderMenuItemsMethod](reqId, itemsJsonArray);\n } else if (isIos) {\n ios[setHeaderMenuItemsMethod].postMessage({ reqId, itemsJsonArray });\n } else if (web) {\n web.execute(setHeaderMenuItemsMethod, reqId, itemsJsonArray);\n } else if (typeof window !== 'undefined') {\n console.log('--setHeaderMenuItems-isUnknown');\n }\n }\n\n const setHeaderMenuItemClickHandler = (handler: HeaderMenuItemClickHandlerType) => {\n const isAndroid = android && android[setHeaderMenuItemClickHandlerMethod];\n const isIos = ios && ios[setHeaderMenuItemClickHandlerMethod];\n\n if (isAndroid || isIos || web) {\n (window as any).onAituBridgeHeaderMenuItemClick = handler;\n } else if (typeof window !== 'undefined') {\n console.log('--setHeaderMenuItemClickHandler-isUnknown');\n }\n }\n\n /**\n * @deprecated данный метод не рекомендуется использовать\n * вместо него используйте setNavigationItemMode\n */\n const setCustomBackArrowMode = (reqId, enabled: boolean) => {\n const isAndroid = android && android[setCustomBackArrowModeMethod];\n const isIos = ios && ios[setCustomBackArrowModeMethod];\n\n if (isAndroid) {\n android[setCustomBackArrowModeMethod](reqId, enabled);\n } else if (isIos) {\n ios[setCustomBackArrowModeMethod].postMessage({ reqId, enabled });\n } else if (web) {\n web.execute(setCustomBackArrowModeMethod, reqId, enabled);\n } else if (typeof window !== 'undefined') {\n console.log('--setCustomBackArrowMode-isUnknown');\n }\n }\n\n /**\n * @deprecated данный метод не рекомендуется использовать\n * вместо него используйте getNavigationItemMode\n */\n const getCustomBackArrowMode = (reqId) => {\n const isAndroid = android && android[getCustomBackArrowModeMethod];\n const isIos = ios && ios[getCustomBackArrowModeMethod];\n\n if (isAndroid) {\n android[getCustomBackArrowModeMethod](reqId);\n } else if (isIos) {\n ios[getCustomBackArrowModeMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(getCustomBackArrowModeMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--getCustomBackArrowMode-isUnknown');\n }\n }\n\n /**\n * @deprecated данный метод не рекомендуется использовать\n * вместо него используйте setNavigationItemMode\n */\n const setCustomBackArrowVisible = (reqId, visible: boolean) => {\n const isAndroid = android && android[setCustomBackArrowVisibleMethod];\n const isIos = ios && ios[setCustomBackArrowVisibleMethod];\n\n if (isAndroid) {\n android[setCustomBackArrowVisibleMethod](reqId, visible);\n } else if (isIos) {\n ios[setCustomBackArrowVisibleMethod].postMessage({ reqId, visible });\n } else if (web) {\n web.execute(setCustomBackArrowVisibleMethod, reqId, visible);\n } else if (typeof window !== 'undefined') {\n console.log('--setCustomBackArrowVisible-isUnknown');\n }\n }\n\n const setCustomBackArrowOnClickHandler = (handler: BackArrowClickHandlerType) => {\n const isAndroid = android && android[setCustomBackArrowOnClickHandlerMethod];\n const isIos = ios && ios[setCustomBackArrowOnClickHandlerMethod];\n\n if (isAndroid || isIos || web) {\n (window as any).onAituBridgeBackArrowClick = handler;\n } else if (typeof window !== 'undefined') {\n console.log('--setCustomBackArrowOnClickHandler-isUnknown');\n }\n }\n\n const openPayment = (reqId, transactionId: string) => {\n const isAndroid = android && android[openPaymentMethod];\n const isIos = ios && ios[openPaymentMethod];\n\n if (isAndroid) {\n android[openPaymentMethod](reqId, transactionId);\n } else if (isIos) {\n ios[openPaymentMethod].postMessage({ reqId, transactionId });\n } else {\n console.log('--openPayment-isUnknown');\n }\n }\n\n const checkBiometry = (reqId) => {\n const isAndroid = android && android[checkBiometryMethod];\n const isIos = ios && ios[checkBiometryMethod];\n\n if (isAndroid) {\n android[checkBiometryMethod](reqId);\n } else if (isIos) {\n ios[checkBiometryMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(checkBiometryMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--checkBiometry-isUnknown');\n }\n }\n\n const openExternalUrl = (reqId, url: string) => {\n const isAndroid = android && android[openExternalUrlMethod];\n const isIos = ios && ios[openExternalUrlMethod];\n\n if (isAndroid) {\n android[openExternalUrlMethod](reqId, url);\n } else if (isIos) {\n ios[openExternalUrlMethod].postMessage({ reqId, url });\n } else {\n console.log(\"--openExternalUrlMethod-isUnknown\");\n }\n };\n\n const enableSwipeBack = (reqId) => {\n const isAndroid = android && android[enableSwipeBackMethod];\n const isIos = ios && ios[enableSwipeBackMethod];\n\n if (isAndroid) {\n android[enableSwipeBackMethod](reqId);\n } else if (isIos) {\n ios[enableSwipeBackMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(enableSwipeBackMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--enableSwipeBack-isUnknown');\n }\n }\n\n const disableSwipeBack = (reqId) => {\n const isAndroid = android && android[disableSwipeBackMethod];\n const isIos = ios && ios[disableSwipeBackMethod];\n\n if (isAndroid) {\n android[disableSwipeBackMethod](reqId);\n } else if (isIos) {\n ios[disableSwipeBackMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(disableSwipeBackMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--disableSwipeBack-isUnknown');\n }\n }\n\n const setNavigationItemMode = (reqId, mode: NavigationItemMode) => {\n const isAndroid = android && android[setNavigationItemModeMethod];\n const isIos = ios && ios[setNavigationItemModeMethod];\n\n if (isAndroid) {\n android[setNavigationItemModeMethod](reqId, mode);\n } else if (isIos) {\n ios[setNavigationItemModeMethod].postMessage({ reqId, mode });\n } else if (web) {\n web.execute(setNavigationItemModeMethod, reqId, mode);\n } else if (typeof window !== 'undefined') {\n console.log('--setNavigationItemMode-isUnknown');\n }\n }\n\n const getNavigationItemMode = (reqId) => {\n const isAndroid = android && android[getNavigationItemModeMethod];\n const isIos = ios && ios[getNavigationItemModeMethod];\n\n if (isAndroid) {\n android[getNavigationItemModeMethod](reqId);\n } else if (isIos) {\n ios[getNavigationItemModeMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(getNavigationItemModeMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--getNavigationItemMode-isUnknown');\n }\n }\n\n const getUserStepInfo = (reqId) => {\n const isAndroid = android && android[getUserStepInfoMethod];\n const isIos = ios && ios[getUserStepInfoMethod];\n\n if (isAndroid) {\n android[getUserStepInfoMethod](reqId);\n } else if (isIos) {\n ios[getUserStepInfoMethod].postMessage({ reqId });\n } else if (web) {\n console.log('--getUserStepInfo-isWeb');\n } else if (typeof window !== 'undefined') {\n console.log('--getUserStepInfo-isUnknown');\n }\n }\n\n\n const invokePromise = promisifyInvoke(invoke, sub);\n const storagePromise = promisifyStorage(storage, sub);\n const getGeoPromise = promisifyMethod(getGeo, getGeoMethod, sub);\n const getQrPromise = promisifyMethod(getQr, getQrMethod, sub);\n const getSMSCodePromise = promisifyMethod(getSMSCode, getSMSCodeMethod, sub);\n const selectContactPromise = promisifyMethod(selectContact, selectContactMethod, sub);\n const openSettingsPromise = promisifyMethod(openSettings, openSettingsMethod, sub);\n const closeApplicationPromise = promisifyMethod(closeApplication, closeApplicationMethod, sub);\n const sharePromise = promisifyMethod(share, shareMethod, sub);\n const setTitlePromise = promisifyMethod(setTitle, setTitleMethod, sub);\n const copyToClipboardPromise = promisifyMethod(copyToClipboard, copyToClipboardMethod, sub);\n const shareImagePromise = promisifyMethod(shareImage, shareImageMethod, sub);\n const shareFilePromise = promisifyMethod(shareFile, shareFileMethod, sub);\n const vibratePromise = promisifyMethod(vibrate, vibrateMethod, sub);\n const enableScreenCapturePromise = promisifyMethod(enableScreenCapture, enableScreenCaptureMethod, sub);\n const disableScreenCapturePromise = promisifyMethod(disableScreenCapture, disableScreenCaptureMethod, sub);\n const setHeaderMenuItemsPromise = promisifyMethod(setHeaderMenuItems, setHeaderMenuItemsMethod, sub);\n const setCustomBackArrowModePromise = promisifyMethod(setCustomBackArrowMode, setCustomBackArrowModeMethod, sub);\n const getCustomBackArrowModePromise = promisifyMethod(getCustomBackArrowMode, getCustomBackArrowModeMethod, sub);\n const setCustomBackArrowVisiblePromise = promisifyMethod(setCustomBackArrowVisible, setCustomBackArrowVisibleMethod, sub);\n const openPaymentPromise = promisifyMethod(openPayment, openPaymentMethod, sub);\n const checkBiometryPromise = promisifyMethod(checkBiometry, checkBiometryMethod, sub);\n const openExternalUrlPromise = promisifyMethod(openExternalUrl, openExternalUrlMethod, sub);\n const enableSwipeBackPromise = promisifyMethod(enableSwipeBack, enableSwipeBackMethod, sub);\n const disableSwipeBackPromise = promisifyMethod(disableSwipeBack, disableSwipeBackMethod, sub);\n const setNavigationItemModePromise = promisifyMethod(setNavigationItemMode, setNavigationItemModeMethod, sub);\n const getNavigationItemModePromise = promisifyMethod(getNavigationItemMode, getNavigationItemModeMethod, sub);\n const getUserStepInfoPromise = promisifyMethod(getUserStepInfo, getUserStepInfoMethod, sub);\n\n return {\n version: String(LIB_VERSION),\n copyToClipboard: copyToClipboardPromise,\n invoke: invokePromise,\n storage: storagePromise,\n getMe: () => invokePromise(EInvokeRequest.getMe),\n getPhone: () => invokePromise(EInvokeRequest.getPhone),\n getContacts: () => invokePromise(EInvokeRequest.getContacts),\n getGeo: getGeoPromise,\n getQr: getQrPromise,\n getSMSCode: getSMSCodePromise,\n getUserProfile: (id: string) =>\n invokePromise(EInvokeRequest.getUserProfile, { id }),\n selectContact: selectContactPromise,\n enableNotifications,\n disableNotifications,\n enablePrivateMessaging: (appId: string) =>\n invokePromise(EInvokeRequest.enablePrivateMessaging, { appId }),\n disablePrivateMessaging: (appId: string) =>\n invokePromise(EInvokeRequest.disablePrivateMessaging, { appId }),\n openSettings: openSettingsPromise,\n closeApplication: closeApplicationPromise,\n setTitle: setTitlePromise,\n share: sharePromise,\n shareImage: shareImagePromise,\n shareFile: shareFilePromise,\n setShakeHandler,\n setTabActiveHandler,\n vibrate: vibratePromise,\n isSupported,\n supports,\n sub,\n enableScreenCapture: enableScreenCapturePromise,\n disableScreenCapture: disableScreenCapturePromise,\n setHeaderMenuItems: setHeaderMenuItemsPromise,\n setHeaderMenuItemClickHandler,\n setCustomBackArrowMode: setCustomBackArrowModePromise,\n getCustomBackArrowMode: getCustomBackArrowModePromise,\n setCustomBackArrowVisible: setCustomBackArrowVisiblePromise,\n openPayment: openPaymentPromise,\n setCustomBackArrowOnClickHandler,\n checkBiometry: checkBiometryPromise,\n openExternalUrl: openExternalUrlPromise,\n enableSwipeBack: enableSwipeBackPromise,\n disableSwipeBack: disableSwipeBackPromise,\n setNavigationItemMode: setNavigationItemModePromise,\n getNavigationItemMode: getNavigationItemModePromise,\n getUserStepInfo: getUserStepInfoPromise,\n };\n}\n\nconst bridge = buildBridge();\n\nexport default bridge;\n","export const LIB_VERSION = \"0.3.55\";\n"],"names":["createRequestResolver","prefix","counter","current","next","this","createCounter","promiseControllers","add","controller","customId","id","resolve","reqId","data","isSuccess","error","requestPromise","reject","handleSubscribe","subscribe","requestResolver","event","detail","promisifyMethod","method","methodName","Promise","aituOrigin","URLSearchParams","window","location","search","get","localStorage","setItem","getItem","WebBridge","origin","execute","top","postMessage","source","payload","addEventListener","dispatchEvent","CustomEvent","message","JSON","parse","onAituBridgeBackArrowClick","onAituBridgeHeaderMenuItemClick","param","e","console","log","EInvokeRequest","HeaderMenuIcon","NavigationItemMode","PermissionDeniedError","Error","android","AndroidBridge","ios","webkit","messageHandlers","web","bridge","subs","map","fn","call","sub","listener","push","invokePromise","invokeMethodName","props","isIos","stringify","invoke","storagePromise","storage","keyName","keyValue","clear","promisifyStorage","getGeoPromise","getQrPromise","getSMSCodePromise","selectContactPromise","openSettingsPromise","closeApplicationPromise","sharePromise","text","setTitlePromise","copyToClipboardPromise","shareImagePromise","image","isAndroid","filename","split","base64Data","substr","indexOf","shareFilePromise","vibratePromise","pattern","Array","isArray","some","timing","Math","floor","reduce","total","enableScreenCapturePromise","disableScreenCapturePromise","setHeaderMenuItemsPromise","items","length","itemsJsonArray","setCustomBackArrowModePromise","enabled","getCustomBackArrowModePromise","setCustomBackArrowVisiblePromise","visible","openPaymentPromise","transactionId","checkBiometryPromise","openExternalUrlPromise","url","enableSwipeBackPromise","disableSwipeBackPromise","setNavigationItemModePromise","mode","getNavigationItemModePromise","getUserStepInfoPromise","version","String","copyToClipboard","getMe","getPhone","getContacts","getGeo","getQr","getSMSCode","getUserProfile","selectContact","enableNotifications","disableNotifications","enablePrivateMessaging","appId","disablePrivateMessaging","openSettings","closeApplication","setTitle","share","shareImage","shareFile","setShakeHandler","handler","onAituBridgeShake","setTabActiveHandler","onAituBridgeTabActive","vibrate","isSupported","iosSup","Boolean","supports","enableScreenCapture","disableScreenCapture","setHeaderMenuItems","setHeaderMenuItemClickHandler","setCustomBackArrowMode","getCustomBackArrowMode","setCustomBackArrowVisible","openPayment","setCustomBackArrowOnClickHandler","checkBiometry","openExternalUrl","enableSwipeBack","disableSwipeBack","setNavigationItemMode","getNavigationItemMode","getUserStepInfo","buildBridge"],"mappings":"gzCASA,SAASA,EAAsBC,GAM3B,IAAMC,EAfV,SAAuBD,GACnB,gBADmBA,IAAAA,EAAS,MACrB,CACHE,QAAS,EACTC,gBACI,OAAOH,KAAWI,KAAKF,UAWfG,CAAcL,GACxBM,EAA+D,GAErE,MAAO,CACHC,aAAIC,EAA+BC,YAAAA,IAAAA,EAAW,IAC1C,IAAMC,EAAKD,EAAWR,EAAQE,OAE9B,OADAG,EAAmBI,GAAMF,EAClBE,GAGXC,iBAAWC,EAAwBC,EAASC,EAAiCC,GACzE,IAAMC,EAAiBV,EAAmBM,GAEtCI,IACIF,EAAUC,GACVC,EAAeL,QAAQE,GAEvBG,EAAeC,OAAOF,GAG1BT,EAAmBM,GAAS,QAM5C,SAASM,EAAgBC,EAAoDC,GACzED,EAAU,SAAAE,GACN,GAAKA,EAAMC,QAIP,UAAWD,EAAMC,OAAQ,OACMD,EAAMC,OAA7BV,IAAAA,MAEJA,GACAQ,EAAgBT,QAAQC,IAHbC,KAG0B,SAACE,UAAYA,KAHjCA,mBAkDjBQ,EAAgBC,EAAkBC,EAAoBN,GAClE,IAAMC,EAAk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AAwBnD,EACxBoD,0BAA2BnD,EAC3BoD,YAAalD,EACbmD,iCArMuC,SAACjB,GACtBpG,GAAWA,EAAO,kCACtBE,GAAOA,EAAG,kCAEEG,EACvBpC,OAAeoB,2BAA6B+G,EAClB,oBAAXnI,QAChBwB,QAAQC,IAAI,iDA+Ld4H,cAAelD,EACfmD,gBAAiBlD,EACjBmD,gBAAiBjD,EACjBkD,iBAAkBjD,EAClBkD,sBAAuBjD,EACvBkD,sBAAuBhD,EACvBiD,gBAAiBhD,GAINiD"}
1
+ {"version":3,"file":"index.umd.js","sources":["../src/utils.ts","../src/webBridge.ts","../src/index.ts","../src/version.ts"],"sourcesContent":["function createCounter(prefix = 'm:') {\n return {\n current: 0,\n next() {\n return prefix + ++this.current;\n },\n };\n}\n\nfunction createRequestResolver(prefix: string) {\n type PromiseController = {\n resolve: (value: any) => any;\n reject: (reason: any) => any;\n };\n\n const counter = createCounter(prefix);\n const promiseControllers: Record<string, PromiseController | null> = {};\n\n return {\n add(controller: PromiseController, customId = ''): number | string {\n const id = customId + counter.next()\n promiseControllers[id] = controller;\n return id;\n },\n\n resolve<T>(reqId: number | string, data: T, isSuccess: (data: T) => boolean, error: any) {\n const requestPromise = promiseControllers[reqId];\n\n if (requestPromise) {\n if (isSuccess(error)) {\n requestPromise.resolve(data);\n } else {\n requestPromise.reject(error);\n }\n\n promiseControllers[reqId] = null;\n }\n },\n };\n}\n\nfunction handleSubscribe(subscribe: (handler: (event: any) => void) => void, requestResolver: ReturnType<typeof createRequestResolver>) {\n subscribe(event => {\n if (!event.detail) {\n return;\n }\n\n if ('reqId' in event.detail) {\n const { reqId, data, error } = event.detail;\n\n if (reqId) {\n requestResolver.resolve(reqId, data, (error) => !(error), error);\n }\n }\n })\n}\n\nexport function promisifyStorage(storage, subscribe: (fn: any) => void) {\n const requestResolver = createRequestResolver('storage:');\n\n handleSubscribe(subscribe, requestResolver)\n\n return {\n setItem: (keyName: string, keyValue: string): Promise<void> => {\n return new Promise((resolve, reject) => {\n const reqId = requestResolver.add({ resolve, reject });\n storage(reqId, 'setItem', { keyName, keyValue });\n });\n },\n getItem: (keyName: string): Promise<string | null> => {\n return new Promise((resolve, reject) => {\n const reqId = requestResolver.add({ resolve, reject });\n storage(reqId, 'getItem', { keyName });\n });\n },\n clear: (): Promise<void> => {\n return new Promise((resolve, reject) => {\n const reqId = requestResolver.add({ resolve, reject });\n storage(reqId, 'clear', {});\n });\n },\n }\n}\n\nexport function promisifyInvoke(invoke, subscribe: (fn: any) => void) {\n const requestResolver = createRequestResolver('invoke:');\n\n handleSubscribe(subscribe, requestResolver)\n\n return function promisifiedFunc(invokeMethodName: string, props: any = {}): Promise<any | void> {\n return new Promise((resolve, reject) => {\n const reqId = requestResolver.add({ resolve, reject }, invokeMethodName + ':');\n\n invoke(reqId, invokeMethodName, props);\n });\n };\n}\n\nexport function promisifyMethod(method: Function, methodName: string, subscribe: (fn: any) => void) {\n const requestResolver = createRequestResolver(methodName + ':');\n\n handleSubscribe(subscribe, requestResolver)\n\n return function promisifiedFunc(...args: any[]): Promise<any | void> {\n return new Promise((resolve, reject) => {\n const reqId = requestResolver.add({ resolve, reject });\n method(reqId, ...args);\n });\n };\n}\n\n\n\n","import type { AituBridge } from './index';\n\nconst AITU_DOMAIN_PARAM = '__aitu-domain'\n\nconst searchParams = new URLSearchParams(window.location.search)\n\nlet aituOrigin = searchParams.get(AITU_DOMAIN_PARAM)\n\nif(aituOrigin){\n localStorage.setItem('mini-app-domain', aituOrigin)\n}else{\n aituOrigin = localStorage.getItem('mini-app-domain')\n}\ninterface WebBridge {\n execute(method: keyof AituBridge, reqId: string, ...payload: any[] ): void\n origin: string\n}\n\nlet WebBridge: WebBridge | null = null\n\nif (aituOrigin) {\n WebBridge = {\n origin: aituOrigin,\n execute: (method, reqId, ...payload) => {\n window.top.postMessage({\n source: 'aitu-bridge',\n method,\n reqId,\n payload: [...payload],\n },\n WebBridge.origin\n )\n }\n\n }\n window.addEventListener('message', event => {\n if (event.origin === aituOrigin && event.data) {\n\n // dispatch aitu events\n window.dispatchEvent(new CustomEvent('aituEvents', { detail: event.data }));\n\n // try to detect handler call\n if (typeof event.data !== 'string' || event.data === '') {\n return;\n }\n\n try {\n const message = JSON.parse(event.data)\n\n if (message && message['method']) {\n if (message.method === 'setCustomBackArrowOnClickHandler') {\n (window as any).onAituBridgeBackArrowClick()\n } else if (message.method === 'setHeaderMenuItemClickHandler') {\n (window as any).onAituBridgeHeaderMenuItemClick(message.param)\n }\n }\n } catch (e) {\n console.log('Error parsing message data: ' + e);\n }\n }\n })\n}\n\nexport default WebBridge\n","import { LIB_VERSION } from './version';\n\nimport {\n promisifyMethod,\n promisifyStorage,\n promisifyInvoke,\n} from './utils'\n\nimport WebBridge from './webBridge';\n\nenum EInvokeRequest {\n getMe = 'GetMe',\n getPhone = 'GetPhone',\n getContacts = 'GetContacts',\n getUserProfile = 'GetUserProfile',\n enableNotifications = 'AllowNotifications',\n disableNotifications = 'DisableNotifications',\n enablePrivateMessaging = 'EnablePrivateMessaging',\n disablePrivateMessaging = 'DisablePrivateMessaging',\n}\n\ntype SetItemType = (keyName: string, keyValue: string) => Promise<void>;\ntype GetItemType = (keyName: string) => Promise<string | null>;\ntype ClearType = () => Promise<void>;\n\ntype HeaderMenuItemClickHandlerType = (id: string) => Promise<void>;\ntype BackArrowClickHandlerType = () => Promise<void>;\n\nexport interface GetPhoneResponse {\n phone: string;\n sign: string;\n}\n\nexport interface GetMeResponse {\n name: string;\n lastname: string;\n id: string;\n avatar?: string;\n avatarThumb?: string;\n notifications_allowed: boolean;\n private_messaging_enabled: boolean;\n sign: string;\n}\n\nexport interface ResponseObject {\n phone?: string;\n name?: string;\n lastname?: string;\n}\n\nexport interface GetGeoResponse {\n latitude: number;\n longitude: number;\n}\n\nexport interface GetContactsResponse {\n contacts: Array<{\n first_name: string;\n last_name: string;\n phone: string;\n }>;\n sign: string;\n}\n\nexport interface SelectContactResponse {\n phone: string;\n name: string;\n lastname: string;\n}\n\nexport interface GetUserProfileResponse {\n name: string;\n lastname?: string;\n phone?: string;\n avatar?: string;\n avatarThumb?: string;\n}\n\nconst MAX_HEADER_MENU_ITEMS_COUNT = 3;\n\nexport enum HeaderMenuIcon {\n Search = \"Search\",\n ShoppingCart = \"ShoppingCart\",\n Menu = \"Menu\",\n Share = \"Share\",\n Notifications = \"Notifications\",\n Help = \"Help\",\n Error = \"Error\",\n Person = \"Person\",\n Sort = \"Sort\",\n Filter = \"Filter\",\n Close = \"Close\"\n}\n\nexport enum NavigationItemMode {\n SystemBackArrow = \"SystemBackArrow\",\n CustomBackArrow = \"CustomBackArrow\",\n NoItem = \"NoItem\",\n UserProfile = \"UserProfile\",\n}\n\nexport interface HeaderMenuItem {\n id: string;\n icon: HeaderMenuIcon;\n badge?: string;\n}\n\nexport interface UserStepsPerDay {\n date: string;\n steps: number;\n}\n\nexport interface UserStepInfoResponse {\n steps: UserStepsPerDay[];\n}\n\ntype OpenSettingsResponse = 'success' | 'failed';\ntype ShareResponse = 'success' | 'failed';\ntype CopyToClipboardResponse = 'success' | 'failed';\ntype VibrateResponse = 'success' | 'failed';\n// todo: remove duplicates\ntype ResponseType = 'success' | 'failed';\ntype BiometryResponse = 'success' | 'failed' | 'unavailable' | 'cancelled';\n\ntype BridgeInvoke<T extends EInvokeRequest, R> = (method: T, data?: {}) => Promise<R>;\n\ninterface BridgeStorage {\n setItem: SetItemType,\n getItem: GetItemType,\n clear: ClearType\n}\n\nexport interface AituBridge {\n version: string;\n invoke: BridgeInvoke<EInvokeRequest, ResponseObject>;\n storage: BridgeStorage;\n getMe: () => Promise<GetMeResponse>;\n getPhone: () => Promise<GetPhoneResponse>;\n getContacts: () => Promise<GetContactsResponse>;\n getGeo: () => Promise<GetGeoResponse>;\n selectContact: () => Promise<SelectContactResponse>;\n getQr: () => Promise<string>;\n getSMSCode: () => Promise<string>;\n getUserProfile: (userId: string) => Promise<GetUserProfileResponse>;\n share: (text: string) => Promise<ShareResponse>;\n setTitle: (text: string) => Promise<ResponseType>;\n copyToClipboard: (text: string) => Promise<CopyToClipboardResponse>;\n shareImage: (text: string, image: string) => Promise<ShareResponse>;\n shareFile: (text: string, filename: string, base64Data: string) => Promise<ShareResponse>;\n enableNotifications: () => Promise<{}>;\n disableNotifications: () => Promise<{}>;\n enablePrivateMessaging: (appId: string) => Promise<string>;\n disablePrivateMessaging: (appId: string) => Promise<string>;\n openSettings: () => Promise<OpenSettingsResponse>;\n closeApplication: () => Promise<ResponseType>;\n setShakeHandler: (handler: any) => void;\n setTabActiveHandler: (handler: (tabname: string) => void) => void;\n vibrate: (pattern: number[]) => Promise<VibratePattern>;\n isSupported: () => boolean;\n supports: (method: string) => boolean;\n sub: any;\n enableScreenCapture: () => Promise<{}>;\n disableScreenCapture: () => Promise<{}>;\n setHeaderMenuItems: (items: Array<HeaderMenuItem>) => Promise<ResponseType>;\n setHeaderMenuItemClickHandler: (handler: HeaderMenuItemClickHandlerType) => void;\n setCustomBackArrowMode: (enabled: boolean) => Promise<ResponseType>;\n getCustomBackArrowMode: () => Promise<boolean>;\n setCustomBackArrowVisible: (visible: boolean) => Promise<ResponseType>;\n openPayment: (transactionId: string) => Promise<ResponseType>;\n setCustomBackArrowOnClickHandler: (handler: BackArrowClickHandlerType) => void;\n checkBiometry: () => Promise<BiometryResponse>;\n openExternalUrl: (url: string) => Promise<ResponseType>;\n enableSwipeBack: () => Promise<ResponseType>;\n disableSwipeBack: () => Promise<ResponseType>;\n setNavigationItemMode: (mode: NavigationItemMode) => Promise<void>;\n getNavigationItemMode: () => Promise<NavigationItemMode>;\n getUserStepInfo: () => Promise<UserStepInfoResponse>;\n isBiometryAvailable: () =>Promise<boolean>;\n}\n\nconst invokeMethod = 'invoke';\nconst storageMethod = 'storage';\nconst getGeoMethod = 'getGeo';\nconst getQrMethod = 'getQr';\nconst getSMSCodeMethod = 'getSMSCode';\nconst selectContactMethod = 'selectContact';\nconst openSettingsMethod = 'openSettings';\nconst closeApplicationMethod = 'closeApplication';\nconst shareMethod = 'share';\nconst setTitleMethod = 'setTitle';\nconst copyToClipboardMethod = 'copyToClipboard';\nconst shareImageMethod = 'shareImage';\nconst shareFileMethod = 'shareFile';\nconst setShakeHandlerMethod = 'setShakeHandler';\nconst vibrateMethod = 'vibrate';\nconst enableScreenCaptureMethod = 'enableScreenCapture';\nconst disableScreenCaptureMethod = 'disableScreenCapture';\nconst setTabActiveHandlerMethod = 'setTabActiveHandler';\nconst setHeaderMenuItemsMethod = 'setHeaderMenuItems';\nconst setHeaderMenuItemClickHandlerMethod = 'setHeaderMenuItemClickHandler';\nconst setCustomBackArrowModeMethod = 'setCustomBackArrowMode';\nconst getCustomBackArrowModeMethod = 'getCustomBackArrowMode';\nconst setCustomBackArrowVisibleMethod = 'setCustomBackArrowVisible';\nconst openPaymentMethod = 'openPayment'\nconst setCustomBackArrowOnClickHandlerMethod = 'setCustomBackArrowOnClickHandler';\nconst checkBiometryMethod = 'checkBiometry';\nconst openExternalUrlMethod = 'openExternalUrl';\nconst enableSwipeBackMethod = 'enableSwipeBack';\nconst disableSwipeBackMethod = 'disableSwipeBack';\nconst setNavigationItemModeMethod = 'setNavigationItemMode';\nconst getNavigationItemModeMethod = 'getNavigationItemMode';\nconst getUserStepInfoMethod = 'getUserStepInfo';\nconst isBiometryAvailableMethod = 'isBiometryAvailable';\n\nconst android = typeof window !== 'undefined' && (window as any).AndroidBridge;\nconst ios = typeof window !== 'undefined' && (window as any).webkit && (window as any).webkit.messageHandlers;\nconst web = typeof window !== 'undefined' && (window.top !== window) && WebBridge;\n\nconst buildBridge = (): AituBridge => {\n const subs = [];\n\n if (typeof window !== 'undefined') {\n window.addEventListener('aituEvents', (e: any) => {\n [...subs].map((fn) => fn.call(null, e));\n })\n }\n\n const invoke = (reqId, method, data = {}) => {\n const isAndroid = android && android[invokeMethod];\n const isIos = ios && ios[invokeMethod];\n\n if (isAndroid) {\n android[invokeMethod](reqId, method, JSON.stringify(data));\n } else if (isIos) {\n ios[invokeMethod].postMessage({ reqId, method, data });\n } else if (web) {\n web.execute(invokeMethod, reqId, method, data)\n } else if (typeof window !== 'undefined') {\n console.log('--invoke-isUnknown');\n }\n };\n\n const storage = (reqId, method, data = {}) => {\n const isAndroid = android && android[storageMethod];\n const isIos = ios && ios[storageMethod];\n\n if (isAndroid) {\n android[storageMethod](reqId, method, JSON.stringify(data));\n } else if (isIos) {\n ios[storageMethod].postMessage({ reqId, method, data });\n } else if (web) {\n web.execute(storageMethod, reqId, method, data);\n } else if (typeof window !== 'undefined') {\n console.log('--storage-isUnknown');\n }\n }\n\n const getGeo = (reqId) => {\n const isAndroid = android && android[getGeoMethod];\n const isIos = ios && ios[getGeoMethod];\n\n if (isAndroid) {\n android[getGeoMethod](reqId);\n } else if (isIos) {\n ios[getGeoMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(getGeoMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--getGeo-isUnknown');\n }\n }\n\n const getQr = (reqId) => {\n const isAndroid = android && android[getQrMethod];\n const isIos = ios && ios[getQrMethod];\n\n if (isAndroid) {\n android[getQrMethod](reqId);\n } else if (isIos) {\n ios[getQrMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(getQrMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--getQr-isUnknown');\n }\n }\n\n const getSMSCode = (reqId) => {\n const isAndroid = android && android[getSMSCodeMethod];\n const isIos = ios && ios[getSMSCodeMethod];\n\n if (isAndroid) {\n android[getSMSCodeMethod](reqId);\n } else if (isIos) {\n ios[getSMSCodeMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(getSMSCodeMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--getSMSCode-isUnknown');\n }\n }\n\n const selectContact = (reqId) => {\n const isAndroid = android && android[selectContactMethod];\n const isIos = ios && ios[selectContactMethod];\n\n if (isAndroid) {\n android[selectContactMethod](reqId);\n } else if (isIos) {\n ios[selectContactMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(selectContactMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--selectContact-isUnknown');\n }\n }\n\n const openSettings = (reqId) => {\n const isAndroid = android && android[openSettingsMethod];\n const isIos = ios && ios[openSettingsMethod];\n\n if (isAndroid) {\n android[openSettingsMethod](reqId);\n } else if (isIos) {\n ios[openSettingsMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(openSettingsMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--openSettings-isUnknown');\n }\n }\n\n const closeApplication = (reqId) => {\n const isAndroid = android && android[closeApplicationMethod];\n const isIos = ios && ios[closeApplicationMethod];\n\n if (isAndroid) {\n android[closeApplicationMethod](reqId);\n } else if (isIos) {\n ios[closeApplicationMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(closeApplicationMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--closeApplication-isUnknown');\n }\n }\n\n const share = (reqId, text) => {\n const isAndroid = android && android[shareMethod];\n const isIos = ios && ios[shareMethod];\n\n if (isAndroid) {\n android[shareMethod](reqId, text);\n } else if (isIos) {\n ios[shareMethod].postMessage({ reqId, text });\n } else if (web) {\n web.execute(shareMethod, reqId, text);\n } else if (typeof window !== 'undefined') {\n console.log('--share-isUnknown');\n }\n }\n\n const setTitle = (reqId, text) => {\n const isAndroid = android && android[setTitleMethod];\n const isIos = ios && ios[setTitleMethod];\n\n if (isAndroid) {\n android[setTitleMethod](reqId, text);\n } else if (isIos) {\n ios[setTitleMethod].postMessage({ reqId, text });\n } else if (web) {\n web.execute(setTitleMethod, reqId, text);\n } else if (typeof window !== 'undefined') {\n console.log('--setTitle-isUnknown');\n }\n }\n\n const copyToClipboard = (reqId, text) => {\n const isAndroid = android && android[copyToClipboardMethod];\n const isIos = ios && ios[copyToClipboardMethod];\n\n if (isAndroid) {\n android[copyToClipboardMethod](reqId, text);\n } else if (isIos) {\n ios[copyToClipboardMethod].postMessage({ reqId, text });\n } else if (web) {\n web.execute(copyToClipboardMethod, reqId, text);\n } else if (typeof window !== 'undefined') {\n console.log('--copyToClipboard-isUnknown');\n }\n }\n\n const enableScreenCapture = (reqId) => {\n const isAndroid = android && android[enableScreenCaptureMethod];\n const isIos = ios && ios[enableScreenCaptureMethod];\n\n if (isAndroid) {\n android[enableScreenCaptureMethod](reqId);\n } else if (isIos) {\n ios[enableScreenCaptureMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(enableScreenCaptureMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--enableScreenCapture-isUnknown');\n }\n }\n\n const disableScreenCapture = (reqId) => {\n const isAndroid = android && android[disableScreenCaptureMethod];\n const isIos = ios && ios[disableScreenCaptureMethod];\n\n if (isAndroid) {\n android[disableScreenCaptureMethod](reqId);\n } else if (isIos) {\n ios[disableScreenCaptureMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(disableScreenCaptureMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--disableScreenCapture-isUnknown');\n }\n }\n\n const shareImage = (reqId, text, image) => {\n // !!!======================!!!\n // !!!===== Deprecated =====!!!\n // !!!======================!!!\n\n // const isAndroid = android && android[shareImageMethod];\n // const isIos = ios && ios[shareImageMethod];\n\n // if (isAndroid) {\n // android[shareImageMethod](reqId, text, image);\n // } else if (isIos) {\n // ios[shareImageMethod].postMessage({ reqId, text, image });\n // } else if (typeof window !== 'undefined') {\n // console.log('--shareImage-isWeb');\n // }\n\n // new one - fallback to shareFile\n const isAndroid = android && android[shareFileMethod];\n const isIos = ios && ios[shareFileMethod];\n\n // get extension from base64 mime type and merge with name\n const ext = image.split(';')[0].split('/')[1];\n const filename = 'image.' + ext;\n // remove mime type\n const base64Data = image.substr(image.indexOf(',') + 1);\n\n if (isAndroid) {\n android[shareFileMethod](reqId, text, filename, base64Data);\n } else if (isIos) {\n ios[shareFileMethod].postMessage({ reqId, text, filename, base64Data });\n } else if (web) {\n web.execute(shareFileMethod, reqId, { text, filename, base64Data });\n } else if (typeof window !== 'undefined') {\n console.log('--shareFile-isUnknown');\n }\n }\n\n const shareFile = (reqId, text, filename, base64Data) => {\n const isAndroid = android && android[shareFileMethod];\n const isIos = ios && ios[shareFileMethod];\n\n if (isAndroid) {\n android[shareFileMethod](reqId, text, filename, base64Data);\n } else if (isIos) {\n ios[shareFileMethod].postMessage({ reqId, text, filename, base64Data });\n } else if (web) {\n web.execute(shareFileMethod, reqId, text, filename, base64Data);\n } else if (typeof window !== 'undefined') {\n console.log('--shareFile-isUnknown');\n }\n }\n\n const enableNotifications = () => invokePromise(EInvokeRequest.enableNotifications);\n\n const disableNotifications = () => invokePromise(EInvokeRequest.disableNotifications);\n\n const setShakeHandler = (handler) => {\n const isAndroid = android && android[setShakeHandlerMethod];\n const isIos = ios && ios[setShakeHandlerMethod];\n\n if (isAndroid || isIos || web) {\n (window as any).onAituBridgeShake = handler;\n } else if (typeof window !== 'undefined') {\n console.log('--setShakeHandler-isUnknown');\n }\n };\n\n const setTabActiveHandler = (handler: (tabname: string) => void) => {\n const isAndroid = android && android[setTabActiveHandlerMethod];\n const isIos = ios && ios[setTabActiveHandlerMethod];\n\n if (isAndroid || isIos || web) {\n (window as any).onAituBridgeTabActive = handler;\n } else if (typeof window !== 'undefined') {\n console.log('--setTabActiveHandler-isUnknown');\n }\n };\n\n const vibrate = (reqId, pattern) => {\n if (\n !Array.isArray(pattern) ||\n pattern.some((timing) => timing < 1 || timing !== Math.floor(timing)) ||\n pattern.reduce((total, timing) => total + timing) > 10000\n ) {\n console.error('Pattern should be an array of positive integers no longer than 10000ms total');\n return;\n }\n\n const isAndroid = android && android[vibrateMethod];\n const isIos = ios && ios[vibrateMethod];\n\n if (isAndroid) {\n android[vibrateMethod](reqId, JSON.stringify(pattern));\n } else if (isIos) {\n ios[vibrateMethod].postMessage({ reqId, pattern });\n } else if (web) {\n web.execute(vibrateMethod, reqId, pattern);\n } else if (typeof window !== 'undefined') {\n console.log('--vibrate-isUnknown');\n }\n }\n\n const isSupported = () => {\n const iosSup = ios && (window as any).webkit.messageHandlers.invoke;\n return Boolean(android || iosSup || web);\n }\n\n // TODO: implement web support\n const supports = (method) =>\n (android && typeof android[method] === 'function') ||\n (ios && ios[method] && typeof ios[method].postMessage === 'function') ||\n (web && typeof web[method] === 'function');\n\n const sub = (listener: any) => {\n subs.push(listener);\n }\n\n const setHeaderMenuItems = (reqId, items: Array<HeaderMenuItem>) => {\n if (items.length > MAX_HEADER_MENU_ITEMS_COUNT) {\n console.error('SetHeaderMenuItems: items count should not be more than ' + MAX_HEADER_MENU_ITEMS_COUNT);\n return;\n }\n\n const isAndroid = android && android[setHeaderMenuItemsMethod];\n const isIos = ios && ios[setHeaderMenuItemsMethod];\n\n const itemsJsonArray = JSON.stringify(items);\n\n if (isAndroid) {\n android[setHeaderMenuItemsMethod](reqId, itemsJsonArray);\n } else if (isIos) {\n ios[setHeaderMenuItemsMethod].postMessage({ reqId, itemsJsonArray });\n } else if (web) {\n web.execute(setHeaderMenuItemsMethod, reqId, itemsJsonArray);\n } else if (typeof window !== 'undefined') {\n console.log('--setHeaderMenuItems-isUnknown');\n }\n }\n\n const setHeaderMenuItemClickHandler = (handler: HeaderMenuItemClickHandlerType) => {\n const isAndroid = android && android[setHeaderMenuItemClickHandlerMethod];\n const isIos = ios && ios[setHeaderMenuItemClickHandlerMethod];\n\n if (isAndroid || isIos || web) {\n (window as any).onAituBridgeHeaderMenuItemClick = handler;\n } else if (typeof window !== 'undefined') {\n console.log('--setHeaderMenuItemClickHandler-isUnknown');\n }\n }\n\n /**\n * @deprecated данный метод не рекомендуется использовать\n * вместо него используйте setNavigationItemMode\n */\n const setCustomBackArrowMode = (reqId, enabled: boolean) => {\n const isAndroid = android && android[setCustomBackArrowModeMethod];\n const isIos = ios && ios[setCustomBackArrowModeMethod];\n\n if (isAndroid) {\n android[setCustomBackArrowModeMethod](reqId, enabled);\n } else if (isIos) {\n ios[setCustomBackArrowModeMethod].postMessage({ reqId, enabled });\n } else if (web) {\n web.execute(setCustomBackArrowModeMethod, reqId, enabled);\n } else if (typeof window !== 'undefined') {\n console.log('--setCustomBackArrowMode-isUnknown');\n }\n }\n\n /**\n * @deprecated данный метод не рекомендуется использовать\n * вместо него используйте getNavigationItemMode\n */\n const getCustomBackArrowMode = (reqId) => {\n const isAndroid = android && android[getCustomBackArrowModeMethod];\n const isIos = ios && ios[getCustomBackArrowModeMethod];\n\n if (isAndroid) {\n android[getCustomBackArrowModeMethod](reqId);\n } else if (isIos) {\n ios[getCustomBackArrowModeMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(getCustomBackArrowModeMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--getCustomBackArrowMode-isUnknown');\n }\n }\n\n /**\n * @deprecated данный метод не рекомендуется использовать\n * вместо него используйте setNavigationItemMode\n */\n const setCustomBackArrowVisible = (reqId, visible: boolean) => {\n const isAndroid = android && android[setCustomBackArrowVisibleMethod];\n const isIos = ios && ios[setCustomBackArrowVisibleMethod];\n\n if (isAndroid) {\n android[setCustomBackArrowVisibleMethod](reqId, visible);\n } else if (isIos) {\n ios[setCustomBackArrowVisibleMethod].postMessage({ reqId, visible });\n } else if (web) {\n web.execute(setCustomBackArrowVisibleMethod, reqId, visible);\n } else if (typeof window !== 'undefined') {\n console.log('--setCustomBackArrowVisible-isUnknown');\n }\n }\n\n const setCustomBackArrowOnClickHandler = (handler: BackArrowClickHandlerType) => {\n const isAndroid = android && android[setCustomBackArrowOnClickHandlerMethod];\n const isIos = ios && ios[setCustomBackArrowOnClickHandlerMethod];\n\n if (isAndroid || isIos || web) {\n (window as any).onAituBridgeBackArrowClick = handler;\n } else if (typeof window !== 'undefined') {\n console.log('--setCustomBackArrowOnClickHandler-isUnknown');\n }\n }\n\n const openPayment = (reqId, transactionId: string) => {\n const isAndroid = android && android[openPaymentMethod];\n const isIos = ios && ios[openPaymentMethod];\n\n if (isAndroid) {\n android[openPaymentMethod](reqId, transactionId);\n } else if (isIos) {\n ios[openPaymentMethod].postMessage({ reqId, transactionId });\n } else {\n console.log('--openPayment-isUnknown');\n }\n }\n\n const checkBiometry = (reqId) => {\n const isAndroid = android && android[checkBiometryMethod];\n const isIos = ios && ios[checkBiometryMethod];\n\n if (isAndroid) {\n android[checkBiometryMethod](reqId);\n } else if (isIos) {\n ios[checkBiometryMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(checkBiometryMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--checkBiometry-isUnknown');\n }\n }\n\n const openExternalUrl = (reqId, url: string) => {\n const isAndroid = android && android[openExternalUrlMethod];\n const isIos = ios && ios[openExternalUrlMethod];\n\n if (isAndroid) {\n android[openExternalUrlMethod](reqId, url);\n } else if (isIos) {\n ios[openExternalUrlMethod].postMessage({ reqId, url });\n } else {\n console.log(\"--openExternalUrlMethod-isUnknown\");\n }\n };\n\n const enableSwipeBack = (reqId) => {\n const isAndroid = android && android[enableSwipeBackMethod];\n const isIos = ios && ios[enableSwipeBackMethod];\n\n if (isAndroid) {\n android[enableSwipeBackMethod](reqId);\n } else if (isIos) {\n ios[enableSwipeBackMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(enableSwipeBackMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--enableSwipeBack-isUnknown');\n }\n }\n\n const disableSwipeBack = (reqId) => {\n const isAndroid = android && android[disableSwipeBackMethod];\n const isIos = ios && ios[disableSwipeBackMethod];\n\n if (isAndroid) {\n android[disableSwipeBackMethod](reqId);\n } else if (isIos) {\n ios[disableSwipeBackMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(disableSwipeBackMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--disableSwipeBack-isUnknown');\n }\n }\n\n const setNavigationItemMode = (reqId, mode: NavigationItemMode) => {\n const isAndroid = android && android[setNavigationItemModeMethod];\n const isIos = ios && ios[setNavigationItemModeMethod];\n\n if (isAndroid) {\n android[setNavigationItemModeMethod](reqId, mode);\n } else if (isIos) {\n ios[setNavigationItemModeMethod].postMessage({ reqId, mode });\n } else if (web) {\n web.execute(setNavigationItemModeMethod, reqId, mode);\n } else if (typeof window !== 'undefined') {\n console.log('--setNavigationItemMode-isUnknown');\n }\n }\n\n const getNavigationItemMode = (reqId) => {\n const isAndroid = android && android[getNavigationItemModeMethod];\n const isIos = ios && ios[getNavigationItemModeMethod];\n\n if (isAndroid) {\n android[getNavigationItemModeMethod](reqId);\n } else if (isIos) {\n ios[getNavigationItemModeMethod].postMessage({ reqId });\n } else if (web) {\n web.execute(getNavigationItemModeMethod, reqId);\n } else if (typeof window !== 'undefined') {\n console.log('--getNavigationItemMode-isUnknown');\n }\n }\n\n const getUserStepInfo = (reqId) => {\n const isAndroid = android && android[getUserStepInfoMethod];\n const isIos = ios && ios[getUserStepInfoMethod];\n\n if (isAndroid) {\n android[getUserStepInfoMethod](reqId);\n } else if (isIos) {\n ios[getUserStepInfoMethod].postMessage({ reqId });\n } else if (web) {\n console.log('--getUserStepInfo-isWeb');\n } else if (typeof window !== 'undefined') {\n console.log('--getUserStepInfo-isUnknown');\n }\n }\n\n const isBiometryAvailable = (reqId) => {\n const isAndroid = android && android[isBiometryAvailableMethod];\n const isIos = ios && ios[isBiometryAvailableMethod];\n\n if (isAndroid) {\n android[isBiometryAvailableMethod](reqId);\n } else if (isIos) {\n ios[isBiometryAvailableMethod].postMessage({ reqId });\n } else if (web) {\n console.log('--isBiometryAvailable-isWeb');\n } else if (typeof window !== 'undefined') {\n console.log('--isBiometryAvailable-isUnknown');\n }\n }\n\n\n const invokePromise = promisifyInvoke(invoke, sub);\n const storagePromise = promisifyStorage(storage, sub);\n const getGeoPromise = promisifyMethod(getGeo, getGeoMethod, sub);\n const getQrPromise = promisifyMethod(getQr, getQrMethod, sub);\n const getSMSCodePromise = promisifyMethod(getSMSCode, getSMSCodeMethod, sub);\n const selectContactPromise = promisifyMethod(selectContact, selectContactMethod, sub);\n const openSettingsPromise = promisifyMethod(openSettings, openSettingsMethod, sub);\n const closeApplicationPromise = promisifyMethod(closeApplication, closeApplicationMethod, sub);\n const sharePromise = promisifyMethod(share, shareMethod, sub);\n const setTitlePromise = promisifyMethod(setTitle, setTitleMethod, sub);\n const copyToClipboardPromise = promisifyMethod(copyToClipboard, copyToClipboardMethod, sub);\n const shareImagePromise = promisifyMethod(shareImage, shareImageMethod, sub);\n const shareFilePromise = promisifyMethod(shareFile, shareFileMethod, sub);\n const vibratePromise = promisifyMethod(vibrate, vibrateMethod, sub);\n const enableScreenCapturePromise = promisifyMethod(enableScreenCapture, enableScreenCaptureMethod, sub);\n const disableScreenCapturePromise = promisifyMethod(disableScreenCapture, disableScreenCaptureMethod, sub);\n const setHeaderMenuItemsPromise = promisifyMethod(setHeaderMenuItems, setHeaderMenuItemsMethod, sub);\n const setCustomBackArrowModePromise = promisifyMethod(setCustomBackArrowMode, setCustomBackArrowModeMethod, sub);\n const getCustomBackArrowModePromise = promisifyMethod(getCustomBackArrowMode, getCustomBackArrowModeMethod, sub);\n const setCustomBackArrowVisiblePromise = promisifyMethod(setCustomBackArrowVisible, setCustomBackArrowVisibleMethod, sub);\n const openPaymentPromise = promisifyMethod(openPayment, openPaymentMethod, sub);\n const checkBiometryPromise = promisifyMethod(checkBiometry, checkBiometryMethod, sub);\n const openExternalUrlPromise = promisifyMethod(openExternalUrl, openExternalUrlMethod, sub);\n const enableSwipeBackPromise = promisifyMethod(enableSwipeBack, enableSwipeBackMethod, sub);\n const disableSwipeBackPromise = promisifyMethod(disableSwipeBack, disableSwipeBackMethod, sub);\n const setNavigationItemModePromise = promisifyMethod(setNavigationItemMode, setNavigationItemModeMethod, sub);\n const getNavigationItemModePromise = promisifyMethod(getNavigationItemMode, getNavigationItemModeMethod, sub);\n const getUserStepInfoPromise = promisifyMethod(getUserStepInfo, getUserStepInfoMethod, sub);\n const isBiometryAvailablePromise = promisifyMethod(isBiometryAvailable, isBiometryAvailableMethod, sub);\n\n return {\n version: String(LIB_VERSION),\n copyToClipboard: copyToClipboardPromise,\n invoke: invokePromise,\n storage: storagePromise,\n getMe: () => invokePromise(EInvokeRequest.getMe),\n getPhone: () => invokePromise(EInvokeRequest.getPhone),\n getContacts: () => invokePromise(EInvokeRequest.getContacts),\n getGeo: getGeoPromise,\n getQr: getQrPromise,\n getSMSCode: getSMSCodePromise,\n getUserProfile: (id: string) =>\n invokePromise(EInvokeRequest.getUserProfile, { id }),\n selectContact: selectContactPromise,\n enableNotifications,\n disableNotifications,\n enablePrivateMessaging: (appId: string) =>\n invokePromise(EInvokeRequest.enablePrivateMessaging, { appId }),\n disablePrivateMessaging: (appId: string) =>\n invokePromise(EInvokeRequest.disablePrivateMessaging, { appId }),\n openSettings: openSettingsPromise,\n closeApplication: closeApplicationPromise,\n setTitle: setTitlePromise,\n share: sharePromise,\n shareImage: shareImagePromise,\n shareFile: shareFilePromise,\n setShakeHandler,\n setTabActiveHandler,\n vibrate: vibratePromise,\n isSupported,\n supports,\n sub,\n enableScreenCapture: enableScreenCapturePromise,\n disableScreenCapture: disableScreenCapturePromise,\n setHeaderMenuItems: setHeaderMenuItemsPromise,\n setHeaderMenuItemClickHandler,\n setCustomBackArrowMode: setCustomBackArrowModePromise,\n getCustomBackArrowMode: getCustomBackArrowModePromise,\n setCustomBackArrowVisible: setCustomBackArrowVisiblePromise,\n openPayment: openPaymentPromise,\n setCustomBackArrowOnClickHandler,\n checkBiometry: checkBiometryPromise,\n openExternalUrl: openExternalUrlPromise,\n enableSwipeBack: enableSwipeBackPromise,\n disableSwipeBack: disableSwipeBackPromise,\n setNavigationItemMode: setNavigationItemModePromise,\n getNavigationItemMode: getNavigationItemModePromise,\n getUserStepInfo: getUserStepInfoPromise,\n isBiometryAvailable: isBiometryAvailablePromise,\n };\n}\n\nconst bridge = buildBridge();\n\nexport default bridge;\n","export const LIB_VERSION = \"0.3.56\";\n"],"names":["createRequestResolver","prefix","counter","current","next","this","createCounter","promiseControllers","add","controller","customId","id","resolve","reqId","data","isSuccess","error","requestPromise","reject","handleSubscribe","subscribe","requestResolver","event","detail","promisifyMethod","method","methodName","Promise","aituOrigin","URLSearchParams","window","location","search","get","localStorage","setItem","getItem","WebBridge","origin","execute","top","postMessage","source","payload","addEventListener","dispatchEvent","CustomEvent","message","JSON","parse","onAituBridgeBackArrowClick","onAituBridgeHeaderMenuItemClick","param","e","console","log","EInvokeRequest","HeaderMenuIcon","NavigationItemMode","android","AndroidBridge","ios","webkit","messageHandlers","web","bridge","subs","map","fn","call","sub","listener","push","invokePromise","invokeMethodName","props","isIos","stringify","invoke","storagePromise","storage","keyName","keyValue","clear","promisifyStorage","getGeoPromise","getQrPromise","getSMSCodePromise","selectContactPromise","openSettingsPromise","closeApplicationPromise","sharePromise","text","setTitlePromise","copyToClipboardPromise","shareImagePromise","image","isAndroid","filename","split","base64Data","substr","indexOf","shareFilePromise","vibratePromise","pattern","Array","isArray","some","timing","Math","floor","reduce","total","enableScreenCapturePromise","disableScreenCapturePromise","setHeaderMenuItemsPromise","items","length","itemsJsonArray","setCustomBackArrowModePromise","enabled","getCustomBackArrowModePromise","setCustomBackArrowVisiblePromise","visible","openPaymentPromise","transactionId","checkBiometryPromise","openExternalUrlPromise","url","enableSwipeBackPromise","disableSwipeBackPromise","setNavigationItemModePromise","mode","getNavigationItemModePromise","getUserStepInfoPromise","isBiometryAvailablePromise","version","String","copyToClipboard","getMe","getPhone","getContacts","getGeo","getQr","getSMSCode","getUserProfile","selectContact","enableNotifications","disableNotifications","enablePrivateMessaging","appId","disablePrivateMessaging","openSettings","closeApplication","setTitle","share","shareImage","shareFile","setShakeHandler","handler","onAituBridgeShake","setTabActiveHandler","onAituBridgeTabActive","vibrate","isSupported","iosSup","Boolean","supports","enableScreenCapture","disableScreenCapture","setHeaderMenuItems","setHeaderMenuItemClickHandler","setCustomBackArrowMode","getCustomBackArrowMode","setCustomBackArrowVisible","openPayment","setCustomBackArrowOnClickHandler","checkBiometry","openExternalUrl","enableSwipeBack","disableSwipeBack","setNavigationItemMode","getNavigationItemMode","getUserStepInfo","isBiometryAvailable","buildBridge"],"mappings":"0LASA,SAASA,EAAsBC,GAM3B,IAAMC,EAfV,SAAuBD,GACnB,gB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AWvD,EACXwD,gBA9VsB,SAACC,GACLrG,GAAWA,EAAO,iBACtBE,GAAOA,EAAG,iBAEEG,EACvBlC,OAAemI,kBAAoBD,EACT,oBAAXlI,QAChBwB,QAAQC,IAAI,gCAwVd2G,oBApV0B,SAACF,GACTrG,GAAWA,EAAO,qBACtBE,GAAOA,EAAG,qBAEEG,EACvBlC,OAAeqI,sBAAwBH,EACb,oBAAXlI,QAChBwB,QAAQC,IAAI,oCA8Ud6G,QAAS5D,EACT6D,YAnTkB,WAClB,IAAMC,EAASzG,GAAQ/B,OAAegC,OAAOC,gBAAgBe,OAC7D,OAAOyF,QAAQ5G,GAAW2G,GAAUtG,IAkTpCwG,SA9Se,SAAC/I,UACfkC,GAAsC,mBAApBA,EAAQlC,IAC1BoC,GAAOA,EAAIpC,IAA8C,mBAA5BoC,EAAIpC,GAAQgB,aACzCuB,GAA8B,mBAAhBA,EAAIvC,IA4SnB6C,IAAAA,EACAmG,oBAAqBvD,EACrBwD,qBAAsBvD,EACtBwD,mBAAoBvD,EACpBwD,8BApRoC,SAACZ,GACnBrG,GAAWA,EAAO,+BACtBE,GAAOA,EAAG,+BAEEG,EACvBlC,OAAeqB,gCAAkC6G,EACvB,oBAAXlI,QAChBwB,QAAQC,IAAI,8CA8QdsH,uBAAwBrD,EACxBsD,uBAAwBpD,EACxBqD,0BAA2BpD,EAC3BqD,YAAanD,EACboD,iCArNuC,SAACjB,GACtBrG,GAAWA,EAAO,kCACtBE,GAAOA,EAAG,kCAEEG,EACvBlC,OAAeoB,2BAA6B8G,EAClB,oBAAXlI,QAChBwB,QAAQC,IAAI,iDA+Md2H,cAAenD,EACfoD,gBAAiBnD,EACjBoD,gBAAiBlD,EACjBmD,iBAAkBlD,EAClBmD,sBAAuBlD,EACvBmD,sBAAuBjD,EACvBkD,gBAAiBjD,EACjBkD,oBAAqBjD,GAIVkD"}
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const LIB_VERSION = "0.3.55";
1
+ export declare const LIB_VERSION = "0.3.56";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@btsd/aitu-bridge",
3
- "version": "0.3.55",
3
+ "version": "0.3.56",
4
4
  "description": "",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/index.js",
package/src/index.ts CHANGED
@@ -114,18 +114,13 @@ export interface UserStepInfoResponse {
114
114
  steps: UserStepsPerDay[];
115
115
  }
116
116
 
117
- export class PermissionDeniedError extends Error {
118
- constructor() {
119
- super("No permission");
120
- }
121
- }
122
-
123
117
  type OpenSettingsResponse = 'success' | 'failed';
124
118
  type ShareResponse = 'success' | 'failed';
125
119
  type CopyToClipboardResponse = 'success' | 'failed';
126
120
  type VibrateResponse = 'success' | 'failed';
127
121
  // todo: remove duplicates
128
122
  type ResponseType = 'success' | 'failed';
123
+ type BiometryResponse = 'success' | 'failed' | 'unavailable' | 'cancelled';
129
124
 
130
125
  type BridgeInvoke<T extends EInvokeRequest, R> = (method: T, data?: {}) => Promise<R>;
131
126
 
@@ -173,13 +168,14 @@ export interface AituBridge {
173
168
  setCustomBackArrowVisible: (visible: boolean) => Promise<ResponseType>;
174
169
  openPayment: (transactionId: string) => Promise<ResponseType>;
175
170
  setCustomBackArrowOnClickHandler: (handler: BackArrowClickHandlerType) => void;
176
- checkBiometry: () => Promise<ResponseType>;
171
+ checkBiometry: () => Promise<BiometryResponse>;
177
172
  openExternalUrl: (url: string) => Promise<ResponseType>;
178
173
  enableSwipeBack: () => Promise<ResponseType>;
179
174
  disableSwipeBack: () => Promise<ResponseType>;
180
175
  setNavigationItemMode: (mode: NavigationItemMode) => Promise<void>;
181
176
  getNavigationItemMode: () => Promise<NavigationItemMode>;
182
177
  getUserStepInfo: () => Promise<UserStepInfoResponse>;
178
+ isBiometryAvailable: () =>Promise<boolean>;
183
179
  }
184
180
 
185
181
  const invokeMethod = 'invoke';
@@ -213,7 +209,8 @@ const enableSwipeBackMethod = 'enableSwipeBack';
213
209
  const disableSwipeBackMethod = 'disableSwipeBack';
214
210
  const setNavigationItemModeMethod = 'setNavigationItemMode';
215
211
  const getNavigationItemModeMethod = 'getNavigationItemMode';
216
- const getUserStepInfoMethod = 'getUserStepInfo'
212
+ const getUserStepInfoMethod = 'getUserStepInfo';
213
+ const isBiometryAvailableMethod = 'isBiometryAvailable';
217
214
 
218
215
  const android = typeof window !== 'undefined' && (window as any).AndroidBridge;
219
216
  const ios = typeof window !== 'undefined' && (window as any).webkit && (window as any).webkit.messageHandlers;
@@ -757,6 +754,21 @@ const buildBridge = (): AituBridge => {
757
754
  }
758
755
  }
759
756
 
757
+ const isBiometryAvailable = (reqId) => {
758
+ const isAndroid = android && android[isBiometryAvailableMethod];
759
+ const isIos = ios && ios[isBiometryAvailableMethod];
760
+
761
+ if (isAndroid) {
762
+ android[isBiometryAvailableMethod](reqId);
763
+ } else if (isIos) {
764
+ ios[isBiometryAvailableMethod].postMessage({ reqId });
765
+ } else if (web) {
766
+ console.log('--isBiometryAvailable-isWeb');
767
+ } else if (typeof window !== 'undefined') {
768
+ console.log('--isBiometryAvailable-isUnknown');
769
+ }
770
+ }
771
+
760
772
 
761
773
  const invokePromise = promisifyInvoke(invoke, sub);
762
774
  const storagePromise = promisifyStorage(storage, sub);
@@ -786,6 +798,7 @@ const buildBridge = (): AituBridge => {
786
798
  const setNavigationItemModePromise = promisifyMethod(setNavigationItemMode, setNavigationItemModeMethod, sub);
787
799
  const getNavigationItemModePromise = promisifyMethod(getNavigationItemMode, getNavigationItemModeMethod, sub);
788
800
  const getUserStepInfoPromise = promisifyMethod(getUserStepInfo, getUserStepInfoMethod, sub);
801
+ const isBiometryAvailablePromise = promisifyMethod(isBiometryAvailable, isBiometryAvailableMethod, sub);
789
802
 
790
803
  return {
791
804
  version: String(LIB_VERSION),
@@ -835,6 +848,7 @@ const buildBridge = (): AituBridge => {
835
848
  setNavigationItemMode: setNavigationItemModePromise,
836
849
  getNavigationItemMode: getNavigationItemModePromise,
837
850
  getUserStepInfo: getUserStepInfoPromise,
851
+ isBiometryAvailable: isBiometryAvailablePromise,
838
852
  };
839
853
  }
840
854
 
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const LIB_VERSION = "0.3.55";
1
+ export const LIB_VERSION = "0.3.56";