@btsd/aitu-bridge 0.3.54 → 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.
- package/dist/index.d.ts +17 -11
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +1 -1
- package/dist/index.modern.js.map +1 -1
- package/dist/index.module.js +1 -1
- package/dist/index.module.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/index.ts +41 -16
- package/src/version.ts +1 -1
package/dist/index.umd.js.map
CHANGED
|
@@ -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\ninterface GetPhoneResponse {\n phone: string;\n sign: string;\n}\n\ninterface 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\ninterface ResponseObject {\n phone?: string;\n name?: string;\n lastname?: string;\n}\n\ninterface GetGeoResponse {\n latitude: number;\n longitude: number;\n}\n\ninterface GetContactsResponse {\n contacts: Array<{\n first_name: string;\n last_name: string;\n phone: string;\n }>;\n sign: string;\n}\n\ninterface SelectContactResponse {\n phone: string;\n name: string;\n lastname: string;\n}\n\ninterface 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\ninterface HeaderMenuItem {\n id: string;\n icon: HeaderMenuIcon;\n badge?: string;\n}\n\ninterface UserStepInfoResponse {\n steps: number\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: (startDate: string, endDate: string) => 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, startDate, endDate) => {\n const isAndroid = android && android[getUserStepInfoMethod];\n const isIos = ios && ios[getUserStepInfoMethod];\n\n if (isAndroid) {\n android[getUserStepInfoMethod](reqId, startDate, endDate);\n } else if (isIos) {\n ios[getUserStepInfoMethod].postMessage({ reqId, startDate, endDate });\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.54\";\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","startDate","endDate","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":"0LASA,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,EA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,oBAAqBxD,EACrByD,qBAAsBxD,EACtByD,mBAAoBxD,EACpByD,8BApQoC,SAACZ,GACnBtG,GAAWA,EAAO,+BACtBE,GAAOA,EAAG,+BAEEG,EACvBlC,OAAeqB,gCAAkC8G,EACvB,oBAAXnI,QAChBwB,QAAQC,IAAI,8CA8PduH,uBAAwBtD,EACxBuD,uBAAwBrD,EACxBsD,0BAA2BrD,EAC3BsD,YAAapD,EACbqD,iCArMuC,SAACjB,GACtBtG,GAAWA,EAAO,kCACtBE,GAAOA,EAAG,kCAEEG,EACvBlC,OAAeoB,2BAA6B+G,EAClB,oBAAXnI,QAChBwB,QAAQC,IAAI,iDA+Ld4H,cAAepD,EACfqD,gBAAiBpD,EACjBqD,gBAAiBnD,EACjBoD,iBAAkBnD,EAClBoD,sBAAuBnD,EACvBoD,sBAAuBlD,EACvBmD,gBAAiBlD,GAINmD"}
|
|
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,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,EAAkBrB,EAAsB0B,EAAa,KAI3D,OAFAP,EAAgBC,EAAWC,8BAGvB,WAAWM,QAAQ,SAACf,EAASM,GACzB,IAAML,EAAQQ,EAAgBb,IAAI,CAAEI,QAAAA,EAASM,OAAAA,IAC7CO,gBAAOZ,gCCxGnB,IAIIe,EAFiB,IAAIC,gBAAgBC,OAAOC,SAASC,QAE3BC,IAJJ,iBAMvBL,EACCM,aAAaC,QAAQ,kBAAmBP,GAExCA,EAAaM,aAAaE,QAAQ,mBAOtC,IAAIC,EAA8B,KAE9BT,IACAS,EAAY,CACRC,OAAQV,EACRW,QAAS,SAAC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AAenD,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.
|
|
1
|
+
export declare const LIB_VERSION = "0.3.56";
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -26,12 +26,12 @@ type ClearType = () => Promise<void>;
|
|
|
26
26
|
type HeaderMenuItemClickHandlerType = (id: string) => Promise<void>;
|
|
27
27
|
type BackArrowClickHandlerType = () => Promise<void>;
|
|
28
28
|
|
|
29
|
-
interface GetPhoneResponse {
|
|
29
|
+
export interface GetPhoneResponse {
|
|
30
30
|
phone: string;
|
|
31
31
|
sign: string;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
interface GetMeResponse {
|
|
34
|
+
export interface GetMeResponse {
|
|
35
35
|
name: string;
|
|
36
36
|
lastname: string;
|
|
37
37
|
id: string;
|
|
@@ -42,18 +42,18 @@ interface GetMeResponse {
|
|
|
42
42
|
sign: string;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
interface ResponseObject {
|
|
45
|
+
export interface ResponseObject {
|
|
46
46
|
phone?: string;
|
|
47
47
|
name?: string;
|
|
48
48
|
lastname?: string;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
interface GetGeoResponse {
|
|
51
|
+
export interface GetGeoResponse {
|
|
52
52
|
latitude: number;
|
|
53
53
|
longitude: number;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
interface GetContactsResponse {
|
|
56
|
+
export interface GetContactsResponse {
|
|
57
57
|
contacts: Array<{
|
|
58
58
|
first_name: string;
|
|
59
59
|
last_name: string;
|
|
@@ -62,13 +62,13 @@ interface GetContactsResponse {
|
|
|
62
62
|
sign: string;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
interface SelectContactResponse {
|
|
65
|
+
export interface SelectContactResponse {
|
|
66
66
|
phone: string;
|
|
67
67
|
name: string;
|
|
68
68
|
lastname: string;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
interface GetUserProfileResponse {
|
|
71
|
+
export interface GetUserProfileResponse {
|
|
72
72
|
name: string;
|
|
73
73
|
lastname?: string;
|
|
74
74
|
phone?: string;
|
|
@@ -99,14 +99,19 @@ export enum NavigationItemMode {
|
|
|
99
99
|
UserProfile = "UserProfile",
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
interface HeaderMenuItem {
|
|
102
|
+
export interface HeaderMenuItem {
|
|
103
103
|
id: string;
|
|
104
104
|
icon: HeaderMenuIcon;
|
|
105
105
|
badge?: string;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
interface
|
|
109
|
-
|
|
108
|
+
export interface UserStepsPerDay {
|
|
109
|
+
date: string;
|
|
110
|
+
steps: number;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export interface UserStepInfoResponse {
|
|
114
|
+
steps: UserStepsPerDay[];
|
|
110
115
|
}
|
|
111
116
|
|
|
112
117
|
type OpenSettingsResponse = 'success' | 'failed';
|
|
@@ -115,6 +120,7 @@ type CopyToClipboardResponse = 'success' | 'failed';
|
|
|
115
120
|
type VibrateResponse = 'success' | 'failed';
|
|
116
121
|
// todo: remove duplicates
|
|
117
122
|
type ResponseType = 'success' | 'failed';
|
|
123
|
+
type BiometryResponse = 'success' | 'failed' | 'unavailable' | 'cancelled';
|
|
118
124
|
|
|
119
125
|
type BridgeInvoke<T extends EInvokeRequest, R> = (method: T, data?: {}) => Promise<R>;
|
|
120
126
|
|
|
@@ -162,13 +168,14 @@ export interface AituBridge {
|
|
|
162
168
|
setCustomBackArrowVisible: (visible: boolean) => Promise<ResponseType>;
|
|
163
169
|
openPayment: (transactionId: string) => Promise<ResponseType>;
|
|
164
170
|
setCustomBackArrowOnClickHandler: (handler: BackArrowClickHandlerType) => void;
|
|
165
|
-
checkBiometry: () => Promise<
|
|
171
|
+
checkBiometry: () => Promise<BiometryResponse>;
|
|
166
172
|
openExternalUrl: (url: string) => Promise<ResponseType>;
|
|
167
173
|
enableSwipeBack: () => Promise<ResponseType>;
|
|
168
174
|
disableSwipeBack: () => Promise<ResponseType>;
|
|
169
175
|
setNavigationItemMode: (mode: NavigationItemMode) => Promise<void>;
|
|
170
176
|
getNavigationItemMode: () => Promise<NavigationItemMode>;
|
|
171
|
-
getUserStepInfo: (
|
|
177
|
+
getUserStepInfo: () => Promise<UserStepInfoResponse>;
|
|
178
|
+
isBiometryAvailable: () =>Promise<boolean>;
|
|
172
179
|
}
|
|
173
180
|
|
|
174
181
|
const invokeMethod = 'invoke';
|
|
@@ -202,7 +209,8 @@ const enableSwipeBackMethod = 'enableSwipeBack';
|
|
|
202
209
|
const disableSwipeBackMethod = 'disableSwipeBack';
|
|
203
210
|
const setNavigationItemModeMethod = 'setNavigationItemMode';
|
|
204
211
|
const getNavigationItemModeMethod = 'getNavigationItemMode';
|
|
205
|
-
const getUserStepInfoMethod = 'getUserStepInfo'
|
|
212
|
+
const getUserStepInfoMethod = 'getUserStepInfo';
|
|
213
|
+
const isBiometryAvailableMethod = 'isBiometryAvailable';
|
|
206
214
|
|
|
207
215
|
const android = typeof window !== 'undefined' && (window as any).AndroidBridge;
|
|
208
216
|
const ios = typeof window !== 'undefined' && (window as any).webkit && (window as any).webkit.messageHandlers;
|
|
@@ -731,14 +739,14 @@ const buildBridge = (): AituBridge => {
|
|
|
731
739
|
}
|
|
732
740
|
}
|
|
733
741
|
|
|
734
|
-
const getUserStepInfo = (reqId
|
|
742
|
+
const getUserStepInfo = (reqId) => {
|
|
735
743
|
const isAndroid = android && android[getUserStepInfoMethod];
|
|
736
744
|
const isIos = ios && ios[getUserStepInfoMethod];
|
|
737
745
|
|
|
738
746
|
if (isAndroid) {
|
|
739
|
-
android[getUserStepInfoMethod](reqId
|
|
747
|
+
android[getUserStepInfoMethod](reqId);
|
|
740
748
|
} else if (isIos) {
|
|
741
|
-
ios[getUserStepInfoMethod].postMessage({ reqId
|
|
749
|
+
ios[getUserStepInfoMethod].postMessage({ reqId });
|
|
742
750
|
} else if (web) {
|
|
743
751
|
console.log('--getUserStepInfo-isWeb');
|
|
744
752
|
} else if (typeof window !== 'undefined') {
|
|
@@ -746,6 +754,21 @@ const buildBridge = (): AituBridge => {
|
|
|
746
754
|
}
|
|
747
755
|
}
|
|
748
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
|
+
|
|
749
772
|
|
|
750
773
|
const invokePromise = promisifyInvoke(invoke, sub);
|
|
751
774
|
const storagePromise = promisifyStorage(storage, sub);
|
|
@@ -775,6 +798,7 @@ const buildBridge = (): AituBridge => {
|
|
|
775
798
|
const setNavigationItemModePromise = promisifyMethod(setNavigationItemMode, setNavigationItemModeMethod, sub);
|
|
776
799
|
const getNavigationItemModePromise = promisifyMethod(getNavigationItemMode, getNavigationItemModeMethod, sub);
|
|
777
800
|
const getUserStepInfoPromise = promisifyMethod(getUserStepInfo, getUserStepInfoMethod, sub);
|
|
801
|
+
const isBiometryAvailablePromise = promisifyMethod(isBiometryAvailable, isBiometryAvailableMethod, sub);
|
|
778
802
|
|
|
779
803
|
return {
|
|
780
804
|
version: String(LIB_VERSION),
|
|
@@ -824,6 +848,7 @@ const buildBridge = (): AituBridge => {
|
|
|
824
848
|
setNavigationItemMode: setNavigationItemModePromise,
|
|
825
849
|
getNavigationItemMode: getNavigationItemModePromise,
|
|
826
850
|
getUserStepInfo: getUserStepInfoPromise,
|
|
851
|
+
isBiometryAvailable: isBiometryAvailablePromise,
|
|
827
852
|
};
|
|
828
853
|
}
|
|
829
854
|
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const LIB_VERSION = "0.3.
|
|
1
|
+
export const LIB_VERSION = "0.3.56";
|