@tef-novum/webview-bridge
Advanced tools
Comparing version 3.17.0 to 3.18.0
@@ -7,3 +7,3 @@ export { isWebViewBridgeAvailable, onNativeEvent, NativeEventHandler, setLogger, } from './src/post-message'; | ||
export { createCalendarEvent } from './src/calendar'; | ||
export { requestContact, fetchContactsByPhone } from './src/contacts'; | ||
export { requestContact, fetchContactsByPhone, fetchPhoneNumbers, updatePhoneNumbers, } from './src/contacts'; | ||
export { highlightNavigationTab } from './src/navigation-tabs'; | ||
@@ -10,0 +10,0 @@ export { logEvent, logEcommerceEvent, logTiming, setScreenName, setUserProperty, CD_WEBAPP_INSTALLED, CD_NOVUM_UID, CD_EVENT_VALUE, setCustomerHash, getCustomerHash, setTrackingProperty, sanitizeAnalyticsParam, sanitizeAnalyticsParams, } from './src/analytics'; |
@@ -6,1 +6,6 @@ import { NativeAppResponsePayload } from './post-message'; | ||
export declare const fetchContactsByPhone: (phoneNumbers: ReadonlyArray<string>) => Promise<NativeAppResponsePayload<'FETCH_CONTACTS_DATA'>>; | ||
export declare const fetchPhoneNumbers: () => Promise<NativeAppResponsePayload<'FETCH_PHONE_NUMBERS'>>; | ||
export declare const updatePhoneNumbers: (phoneNumbers: ReadonlyArray<{ | ||
id: string; | ||
value: string; | ||
}>) => Promise<NativeAppResponsePayload<'UPDATE_PHONE_NUMBERS'>>; |
export declare const requestSimIcc: () => Promise<string | null>; | ||
export declare const requestSimImsi: () => Promise<string | null>; | ||
export declare const requestDeviceImei: () => Promise<string | null>; | ||
declare type RoutesAvalaible = 'notification-settings'; | ||
declare type RoutesAvalaible = 'notification-settings' | 'contact-settings'; | ||
export declare const internalNavigation: (feature: RoutesAvalaible) => Promise<void>; | ||
@@ -6,0 +6,0 @@ export declare const dismiss: (onCompletionUrl?: string | undefined) => Promise<void>; |
@@ -264,2 +264,15 @@ /** | ||
}; | ||
FETCH_PHONE_NUMBERS: { | ||
type: 'FETCH_PHONE_NUMBERS'; | ||
id: string; | ||
payload: Array<{ | ||
id: string; | ||
value: string; | ||
}>; | ||
}; | ||
UPDATE_PHONE_NUMBERS: { | ||
type: 'UPDATE_PHONE_NUMBERS'; | ||
id: string; | ||
payload: void; | ||
}; | ||
}; | ||
@@ -266,0 +279,0 @@ export declare type NativeAppResponsePayload<Type extends keyof ResponsesFromNativeApp> = ResponsesFromNativeApp[Type]['payload']; |
@@ -45,3 +45,3 @@ import { NativeAppResponsePayload } from './post-message'; | ||
}) => Promise<NativeAppResponsePayload<'FETCH'>>; | ||
declare type PermissionsStatus = 'notifications'; | ||
declare type PermissionsStatus = 'notifications' | 'read-contacts' | 'write-contacts'; | ||
export declare const checkPermissionStatus: (feature: PermissionsStatus, params?: { | ||
@@ -48,0 +48,0 @@ [key: string]: string; |
@@ -459,2 +459,13 @@ define(['exports'], (function (exports) { 'use strict'; | ||
}; | ||
var fetchPhoneNumbers = function () { | ||
return postMessageToNativeApp({ | ||
type: 'FETCH_PHONE_NUMBERS', | ||
}); | ||
}; | ||
var updatePhoneNumbers = function (phoneNumbers) { | ||
return postMessageToNativeApp({ | ||
type: 'UPDATE_PHONE_NUMBERS', | ||
payload: { phoneNumbers: phoneNumbers }, | ||
}); | ||
}; | ||
@@ -1037,2 +1048,3 @@ var highlightNavigationTab = function (_a) { | ||
exports.fetchContactsByPhone = fetchContactsByPhone; | ||
exports.fetchPhoneNumbers = fetchPhoneNumbers; | ||
exports.getAppMetadata = getAppMetadata; | ||
@@ -1077,2 +1089,3 @@ exports.getCustomerHash = getCustomerHash; | ||
exports.updateNavigationBar = updateNavigationBar; | ||
exports.updatePhoneNumbers = updatePhoneNumbers; | ||
@@ -1079,0 +1092,0 @@ Object.defineProperty(exports, '__esModule', { value: true }); |
@@ -461,2 +461,13 @@ 'use strict'; | ||
}; | ||
var fetchPhoneNumbers = function () { | ||
return postMessageToNativeApp({ | ||
type: 'FETCH_PHONE_NUMBERS', | ||
}); | ||
}; | ||
var updatePhoneNumbers = function (phoneNumbers) { | ||
return postMessageToNativeApp({ | ||
type: 'UPDATE_PHONE_NUMBERS', | ||
payload: { phoneNumbers: phoneNumbers }, | ||
}); | ||
}; | ||
@@ -1039,2 +1050,3 @@ var highlightNavigationTab = function (_a) { | ||
exports.fetchContactsByPhone = fetchContactsByPhone; | ||
exports.fetchPhoneNumbers = fetchPhoneNumbers; | ||
exports.getAppMetadata = getAppMetadata; | ||
@@ -1079,1 +1091,2 @@ exports.getCustomerHash = getCustomerHash; | ||
exports.updateNavigationBar = updateNavigationBar; | ||
exports.updatePhoneNumbers = updatePhoneNumbers; |
@@ -460,2 +460,13 @@ var webviewBridge = (function (exports) { | ||
}; | ||
var fetchPhoneNumbers = function () { | ||
return postMessageToNativeApp({ | ||
type: 'FETCH_PHONE_NUMBERS', | ||
}); | ||
}; | ||
var updatePhoneNumbers = function (phoneNumbers) { | ||
return postMessageToNativeApp({ | ||
type: 'UPDATE_PHONE_NUMBERS', | ||
payload: { phoneNumbers: phoneNumbers }, | ||
}); | ||
}; | ||
@@ -1038,2 +1049,3 @@ var highlightNavigationTab = function (_a) { | ||
exports.fetchContactsByPhone = fetchContactsByPhone; | ||
exports.fetchPhoneNumbers = fetchPhoneNumbers; | ||
exports.getAppMetadata = getAppMetadata; | ||
@@ -1078,2 +1090,3 @@ exports.getCustomerHash = getCustomerHash; | ||
exports.updateNavigationBar = updateNavigationBar; | ||
exports.updatePhoneNumbers = updatePhoneNumbers; | ||
@@ -1080,0 +1093,0 @@ Object.defineProperty(exports, '__esModule', { value: true }); |
@@ -1,1 +0,1 @@ | ||
var webviewBridge=function(e){"use strict";var t=1,n="".concat(Date.now(),"-").concat(String(Math.random()).slice(-8)),o="__tuenti_webview_bridge",r=function(){return!("undefined"==typeof window||!window.tuentiWebView||!window.tuentiWebView.postMessage)},i=function(){return!!("undefined"!=typeof window&&window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.tuentiWebView&&window.webkit.messageHandlers.tuentiWebView.postMessage)},a=function(){return"undefined"==typeof window?null:r()?function(e){window.tuentiWebView.postMessage(e)}:i()?function(e){window.webkit.messageHandlers.tuentiWebView.postMessage(e)}:null},u=[],s=function(e){u.push(e)},c=function(e){u=u.filter(function(t){return t!==e})},l=function(){var e;return"undefined"!=typeof window&&(!!function(){try{return window.self!==window.top}catch(e){return!0}}()&&!(null===(e=null===window||void 0===window?void 0:window.frameElement)||void 0===e?void 0:e.hasAttribute("data-enable-webview-bridge")))},d=void 0,f=function(){return!l()&&(r()||i())},p=function(e,o){var r=e.type,i=e.id,u=void 0===i?"web-".concat(t++,"-").concat(n):i,l=e.payload,f=a(),p=JSON.stringify({type:r,id:u,payload:l});return null===d||void 0===d||d("[WebView Bridge] SEND:",p),f?(setTimeout(function(){f(p)}),new Promise(function(e,t){var n=!1,i=function(o){o.id!==u||n||(o.type===r?e(o.payload):"ERROR"===o.type?t(o.payload):t({code:500,reason:"bad type: ".concat(o.type,". Expecting ").concat(r)}),c(i))};s(i),o&&setTimeout(function(){n=!0,c(i),t({code:408,reason:"request timeout"})},o)})):Promise.reject({code:500,reason:"WebView postMessage not available"})};"undefined"!=typeof window&&(window[o]=window[o]||{postMessage:function(e){var t;null===d||void 0===d||d("[WebView Bridge] RCVD:",e);try{t=JSON.parse(e)}catch(t){throw Error("Problem parsing webview message: ".concat(e))}u.forEach(function(e){return e(t)})}});var y=function(e,t){var n=function(n){n.type===e&&Promise.resolve(t(n.payload)).then(function(e){var t=a();t&&t(JSON.stringify({type:n.type,id:n.id,payload:e}))})};return s(n),function(){c(n)}},m=function(e){var t=e.title,n=e.expandedTitle,o=e.showBackButton,r=e.showReloadButton,i=e.showProfileButton,a=e.backgroundColor;return f()?p({type:"NAVIGATION_BAR",payload:{title:t,expandedTitle:n,showBackButton:o,showReloadButton:r,showProfileButton:i,backgroundColor:a}}):(void 0!==t&&"undefined"!=typeof document&&(document.title=t),Promise.resolve())},v=null,w=function(e){return"true"===v.result[e]},g=function(e){return Math.floor(e/1e3)},b=function(){return(b=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)};function h(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n}function T(e,t,n,o){return new(n||(n=Promise))(function(r,i){function a(e){try{s(o.next(e))}catch(e){i(e)}}function u(e){try{s(o.throw(e))}catch(e){i(e)}}function s(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,u)}s((o=o.apply(e,t||[])).next())})}function E(e,t){var n,o,r,i,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,o=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(r=(r=a.trys).length>0&&r[r.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){a.label=i[1];break}if(6===i[0]&&a.label<r[1]){a.label=r[1],r=i;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(i);break}r[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}var S=0,I=function(e){var t=setTimeout(function(){e(),S++},500);return function(){clearTimeout(t),S=0,e()}},A=function(e){var t=e.onAndroid,n=e.onIos,o=e.onWeb;return"undefined"==typeof window?Promise.resolve():window.AnalyticsWebInterface?t(window.AnalyticsWebInterface):window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.firebase?n(window.webkit.messageHandlers.firebase):window.gtag&&S<3?o(window.gtag):Promise.resolve()},P=function(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"")},_=function(e){return P(e).toLocaleLowerCase().replace(/[^a-z0-9\s\-\_\/\|\:]/g,"").replace(/\s+/g," ").trim().replace(/\s/g,"_").slice(0,100)},N=function(e){var t={};return Object.entries(e).forEach(function(e){var n=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var o,r,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(o=i.next()).done;)a.push(o.value)}catch(e){r={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return a}(e,2),o=n[0],r=n[1],i=r,a=o.slice(0,40);"string"==typeof r&&(i=_(r)),t[a]=i}),t},O={sanitize:!0},C="",M=!1,R=function(e){return T(void 0,void 0,void 0,function(){var t,n,o;return E(this,function(r){switch(r.label){case 0:if(M)throw{code:423,reason:"BottomSheet is locked. You can only have one bottom sheet in the screen"};M=!0,t=setTimeout(function(){M=!1},1e3),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,p({type:"SHEET",payload:e})];case 2:return n=r.sent(),M=!1,clearTimeout(t),[2,n];case 3:throw o=r.sent(),M=!1,clearTimeout(t),o;case 4:return[2]}})})};return e.CD_EVENT_VALUE=8,e.CD_NOVUM_UID=7,e.CD_WEBAPP_INSTALLED=4,e.attachToEmail=function(e){var t=e.url,n=e.subject,o=e.fileName,r=e.recipient,i=e.body;return p({type:"ATTACH_TO_EMAIL",payload:{url:t,subject:n,fileName:o,recipient:r,body:i}})},e.bottomSheet=R,e.bottomSheetActionSelector=function(e){var t=e.title,n=e.subtitle,o=e.description,r=e.items;return R({title:t,subtitle:n,description:o,content:[{type:"LIST",id:"list-0",listType:"ACTIONS",autoSubmit:!0,selectedIds:[],items:r}]}).then(function(e){var t=e.action,n=e.result;return"SUBMIT"===t?{action:t,selectedId:n[0].selectedIds[0]}:{action:t,selectedId:null}})},e.bottomSheetInfo=function(e){var t=e.title,n=e.subtitle,o=e.description,r=e.items;return T(void 0,void 0,void 0,function(){return E(this,function(e){switch(e.label){case 0:return[4,R({title:t,subtitle:n,description:o,content:[{type:"LIST",id:"list-0",listType:"INFORMATIVE",autoSubmit:!1,selectedIds:[],items:r}]})];case 1:return e.sent(),[2]}})})},e.bottomSheetSingleSelector=function(e){var t=e.title,n=e.subtitle,o=e.description,r=e.selectedId,i=e.items;return R({title:t,subtitle:n,description:o,content:[{type:"LIST",id:"list-0",listType:"SINGLE_SELECTION",autoSubmit:!0,selectedIds:"string"==typeof r?[r]:[],items:i}]}).then(function(e){var t=e.action,n=e.result;return"SUBMIT"===t?{action:t,selectedId:n[0].selectedIds[0]}:{action:t,selectedId:null}})},e.checkPermissionStatus=function(e,t){return p({type:"OS_PERMISSION_STATUS",payload:{feature:e,params:t}}).then(function(e){return e.granted})},e.createCalendarEvent=function(e){var t=e.beginTime,n=e.endTime,o=e.title;return p({type:"CREATE_CALENDAR_EVENT",payload:{beginTime:g(t),endTime:g(n),title:o}})},e.dismiss=function(e){return p({type:"DISMISS",payload:{onCompletionUrl:e}})},e.fetch=function(e){var t=e.url,n=e.method,o=e.headers,r=e.body;return f()?p({type:"FETCH",payload:{url:t,method:n,headers:o,body:r}}).catch(function(){return{status:500,headers:{},body:"Bridge call failed"}}):Promise.resolve({status:500,headers:{},body:"Bridge not available"})},e.fetchContactsByPhone=function(e){return p({type:"FETCH_CONTACTS_DATA",payload:{phoneNumbers:e}})},e.getAppMetadata=function(e){return p({type:"GET_APP_METADATA",payload:{appToken:e}})},e.getCustomerHash=function(){return p({type:"GET_CUSTOMER_HASH"})},e.getDiskSpaceInfo=function(){return p({type:"GET_DISK_SPACE_INFO"})},e.getEsimInfo=function(){return p({type:"GET_ESIM_INFO"}).catch(function(){return{supportsEsim:!1}})},e.getTopazToken=function(e){return void 0===e&&(e={}),p({type:"GET_TOPAZ_TOKEN",payload:{}},e.timeout)},e.highlightNavigationTab=function(e){var t=e.tab,n=e.highlight,o=e.count;return p({type:"HIGHLIGHT_TAB",payload:{tab:t,highlight:n,count:o}})},e.internalNavigation=function(e){return p({type:"INTERNAL_NAVIGATION",payload:{feature:e}})},e.isABTestingAvailable=function(e){if(v)return Promise.resolve(w(e));var t=new Promise(function(e){setTimeout(function(){e(!1)},500)}),n=p({type:"GET_REMOTE_CONFIG"}).then(function(t){return v=t,w(e)});return Promise.race([t,n])},e.isWebViewBridgeAvailable=f,e.logEcommerceEvent=function(e,t){return t=b(b({},t),{screenName:t.screenName||C}),A({onAndroid:function(n){return n.logEvent&&n.logEvent(e,JSON.stringify(t)),Promise.resolve()},onIos:function(n){return n.postMessage({command:"logEvent",name:e,parameters:t}),Promise.resolve()},onWeb:function(){return Promise.resolve()}})},e.logEvent=function(e,t){var n,o,r,i,a,u,s=b(b({},O),t).sanitize,c=e.name,l=h(e,["name"]);if(c)Object.keys(l).length>25&&console.warn("Trying to log FirebaseEvent with name ".concat(c," exceeding the limit of ").concat(25," params")),s&&(l=N(l),c=_(c));else{if(!e.category||!e.action)return console.warn('LegacyAnalyticsEvent should have "category" and "action"',{category:e.category,action:e.action}),Promise.resolve();o=(n=e).category,r=n.action,i=n.label,a=n.value,u=h(n,["category","action","label","value"]),i||(i="null_label"),a||(a=0),l=b({eventCategory:o,eventAction:r,eventLabel:P(i),eventValue:a},u),c=e.category}return l=b(b({},l),{screenName:l.screenName||C}),A({onAndroid:function(e){return e.logEvent&&e.logEvent(c,JSON.stringify(l)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:c,parameters:l}),Promise.resolve()},onWeb:function(e){return new Promise(function(t){e("event",c,b(b({},l),{event_callback:I(t)}))})}})},e.logTiming=function(e){var t=e.category,n=void 0===t?"performance_timer":t,o=e.variable,r=e.value,i=e.label;if(!n||!o||!r)return console.warn('Analytics timing should have "category", "variable" and "value"',{category:n,variable:o,value:r}),Promise.resolve();var a={timingCategory:n,timingVar:o,timingValue:r=Math.round(r),timingLabel:i},u=n;return A({onAndroid:function(e){return e.logEvent&&e.logEvent(u,JSON.stringify(a)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:u,parameters:a}),Promise.resolve()},onWeb:function(){return new Promise(function(e){gtag("event",u,b(b({},a),{event_callback:I(e)}))})}})},e.logout=function(){return p({type:"LOG_OUT"})},e.nativeAlert=function(e){var t=e.message,n=e.title,o=e.buttonText;return f()?p({type:"ALERT",payload:{title:n,message:t,buttonText:o}}):("undefined"!=typeof window&&window.alert(t),Promise.resolve())},e.nativeConfirm=function(e){var t=e.message,n=e.title,o=e.acceptText,r=e.cancelText;return f()?p({type:"CONFIRM",payload:{message:t,title:n,acceptText:o,cancelText:r}}).then(function(e){return e.result}):Promise.resolve("undefined"!=typeof window&&window.confirm(t))},e.nativeMessage=function(e){var t=e.message,n=e.duration,o=e.buttonText,r=e.type;return f()?p({type:"MESSAGE",payload:{message:t,duration:n,buttonText:o,type:r}}):("undefined"!=typeof window&&window.alert(t),Promise.resolve())},e.notifyBridgeReady=function(){return p({type:"BRIDGE_READY"})},e.notifyPageLoaded=function(){return p({type:"PAGE_LOADED"})},e.onNativeEvent=function(e){return y("NATIVE_EVENT",function(t){return{action:e({event:t.event}).action||"default"}})},e.onSessionRenewed=function(e){return y("SESSION_RENEWED",function(t){var n=t.accessToken;return e(n)})},e.renewSession=function(e,t){return void 0===t&&(t={}),p({type:"RENEW_SESSION",payload:{accessToken:e||null}},t.timeout).then(function(e){return e.accessToken})},e.reportStatus=function(e){var t=e.feature,n=e.status,o=e.reason;return p({type:"STATUS_REPORT",payload:{feature:t,status:n,reason:o}})},e.requestContact=function(e){var t=(void 0===e?{}:e).filter;return p({type:"GET_CONTACT_DATA",payload:{filter:void 0===t?"phone":t}})},e.requestDeviceImei=function(){return p({type:"IMEI"},200).then(function(e){return e.imei}).catch(function(){return null})},e.requestSimIcc=function(){return p({type:"SIM_ICC"},200).then(function(e){return e.icc}).catch(function(){return null})},e.requestSimImsi=function(){return p({type:"IMSI"},200).then(function(e){return e.imsi}).catch(function(){return null})},e.requestVibration=function(e){return p({type:"VIBRATION",payload:{type:e}})},e.sanitizeAnalyticsParam=_,e.sanitizeAnalyticsParams=N,e.setActionBehavior=function(e){return p({type:"SET_ACTION_BEHAVIOR",payload:{actions:e}}).catch(function(){})},e.setCustomerHash=function(e){return p({type:"SET_CUSTOMER_HASH",payload:{hash:e}})},e.setLogger=function(e){d=e},e.setScreenName=function(e,t){if(!e)return console.warn("Missing analytics screenName"),Promise.resolve();var n=C;return C=e,A({onAndroid:function(n){return n.setScreenNameWithParams?n.setScreenNameWithParams(e,JSON.stringify(t)):n.setScreenName&&n.setScreenName(e),Promise.resolve()},onIos:function(n){return n.postMessage({command:"setScreenName",name:e,parameters:t}),Promise.resolve()},onWeb:function(o){return new Promise(function(r){o("event","page_view",b(b({screenName:e,page_title:e,previousScreenName:n},N(null!==t&&void 0!==t?t:{})),{event_callback:I(r)}))})}})},e.setTrackingProperty=function(e,t,n){return p({type:"SET_TRACKING_PROPERTY",payload:{system:e,name:t,value:n}}).catch(function(){})},e.setUserProperty=function(e,t){return e&&t?(t=String(t),A({onAndroid:function(n){return n.setUserProperty&&n.setUserProperty(e,t),Promise.resolve()},onIos:function(n){return n.postMessage({command:"setUserProperty",name:e,value:t}),Promise.resolve()},onWeb:function(n){var o;return n("set","user_properties",((o={})[e]=_(t),o)),Promise.resolve()}})):(console.warn("Trying to set analytics user property without name or value",e,t),Promise.resolve())},e.setWebViewTitle=function(e){return f()?m({title:e}):("undefined"!=typeof document&&(document.title=e),Promise.resolve())},e.share=function(e){return p({type:"SHARE",payload:e})},e.showAppRating=function(){return p({type:"SHOW_APP_RATING"})},e.updateNavigationBar=m,Object.defineProperty(e,"__esModule",{value:!0}),e}({}); | ||
var webviewBridge=function(e){"use strict";var t=1,n="".concat(Date.now(),"-").concat(String(Math.random()).slice(-8)),o="__tuenti_webview_bridge",r=function(){return!("undefined"==typeof window||!window.tuentiWebView||!window.tuentiWebView.postMessage)},i=function(){return!!("undefined"!=typeof window&&window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.tuentiWebView&&window.webkit.messageHandlers.tuentiWebView.postMessage)},a=function(){return"undefined"==typeof window?null:r()?function(e){window.tuentiWebView.postMessage(e)}:i()?function(e){window.webkit.messageHandlers.tuentiWebView.postMessage(e)}:null},u=[],s=function(e){u.push(e)},c=function(e){u=u.filter(function(t){return t!==e})},l=function(){var e;return"undefined"!=typeof window&&(!!function(){try{return window.self!==window.top}catch(e){return!0}}()&&!(null===(e=null===window||void 0===window?void 0:window.frameElement)||void 0===e?void 0:e.hasAttribute("data-enable-webview-bridge")))},d=void 0,f=function(){return!l()&&(r()||i())},p=function(e,o){var r=e.type,i=e.id,u=void 0===i?"web-".concat(t++,"-").concat(n):i,l=e.payload,f=a(),p=JSON.stringify({type:r,id:u,payload:l});return null===d||void 0===d||d("[WebView Bridge] SEND:",p),f?(setTimeout(function(){f(p)}),new Promise(function(e,t){var n=!1,i=function(o){o.id!==u||n||(o.type===r?e(o.payload):"ERROR"===o.type?t(o.payload):t({code:500,reason:"bad type: ".concat(o.type,". Expecting ").concat(r)}),c(i))};s(i),o&&setTimeout(function(){n=!0,c(i),t({code:408,reason:"request timeout"})},o)})):Promise.reject({code:500,reason:"WebView postMessage not available"})};"undefined"!=typeof window&&(window[o]=window[o]||{postMessage:function(e){var t;null===d||void 0===d||d("[WebView Bridge] RCVD:",e);try{t=JSON.parse(e)}catch(t){throw Error("Problem parsing webview message: ".concat(e))}u.forEach(function(e){return e(t)})}});var y=function(e,t){var n=function(n){n.type===e&&Promise.resolve(t(n.payload)).then(function(e){var t=a();t&&t(JSON.stringify({type:n.type,id:n.id,payload:e}))})};return s(n),function(){c(n)}},m=function(e){var t=e.title,n=e.expandedTitle,o=e.showBackButton,r=e.showReloadButton,i=e.showProfileButton,a=e.backgroundColor;return f()?p({type:"NAVIGATION_BAR",payload:{title:t,expandedTitle:n,showBackButton:o,showReloadButton:r,showProfileButton:i,backgroundColor:a}}):(void 0!==t&&"undefined"!=typeof document&&(document.title=t),Promise.resolve())},v=null,w=function(e){return"true"===v.result[e]},g=function(e){return Math.floor(e/1e3)},b=function(){return(b=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)};function h(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n}function T(e,t,n,o){return new(n||(n=Promise))(function(r,i){function a(e){try{s(o.next(e))}catch(e){i(e)}}function u(e){try{s(o.throw(e))}catch(e){i(e)}}function s(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,u)}s((o=o.apply(e,t||[])).next())})}function E(e,t){var n,o,r,i,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,o=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(r=(r=a.trys).length>0&&r[r.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){a.label=i[1];break}if(6===i[0]&&a.label<r[1]){a.label=r[1],r=i;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(i);break}r[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}var S=0,P=function(e){var t=setTimeout(function(){e(),S++},500);return function(){clearTimeout(t),S=0,e()}},I=function(e){var t=e.onAndroid,n=e.onIos,o=e.onWeb;return"undefined"==typeof window?Promise.resolve():window.AnalyticsWebInterface?t(window.AnalyticsWebInterface):window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.firebase?n(window.webkit.messageHandlers.firebase):window.gtag&&S<3?o(window.gtag):Promise.resolve()},A=function(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"")},N=function(e){return A(e).toLocaleLowerCase().replace(/[^a-z0-9\s\-\_\/\|\:]/g,"").replace(/\s+/g," ").trim().replace(/\s/g,"_").slice(0,100)},_=function(e){var t={};return Object.entries(e).forEach(function(e){var n=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var o,r,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(o=i.next()).done;)a.push(o.value)}catch(e){r={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return a}(e,2),o=n[0],r=n[1],i=r,a=o.slice(0,40);"string"==typeof r&&(i=N(r)),t[a]=i}),t},O={sanitize:!0},C="",M=!1,R=function(e){return T(void 0,void 0,void 0,function(){var t,n,o;return E(this,function(r){switch(r.label){case 0:if(M)throw{code:423,reason:"BottomSheet is locked. You can only have one bottom sheet in the screen"};M=!0,t=setTimeout(function(){M=!1},1e3),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,p({type:"SHEET",payload:e})];case 2:return n=r.sent(),M=!1,clearTimeout(t),[2,n];case 3:throw o=r.sent(),M=!1,clearTimeout(t),o;case 4:return[2]}})})};return e.CD_EVENT_VALUE=8,e.CD_NOVUM_UID=7,e.CD_WEBAPP_INSTALLED=4,e.attachToEmail=function(e){var t=e.url,n=e.subject,o=e.fileName,r=e.recipient,i=e.body;return p({type:"ATTACH_TO_EMAIL",payload:{url:t,subject:n,fileName:o,recipient:r,body:i}})},e.bottomSheet=R,e.bottomSheetActionSelector=function(e){var t=e.title,n=e.subtitle,o=e.description,r=e.items;return R({title:t,subtitle:n,description:o,content:[{type:"LIST",id:"list-0",listType:"ACTIONS",autoSubmit:!0,selectedIds:[],items:r}]}).then(function(e){var t=e.action,n=e.result;return"SUBMIT"===t?{action:t,selectedId:n[0].selectedIds[0]}:{action:t,selectedId:null}})},e.bottomSheetInfo=function(e){var t=e.title,n=e.subtitle,o=e.description,r=e.items;return T(void 0,void 0,void 0,function(){return E(this,function(e){switch(e.label){case 0:return[4,R({title:t,subtitle:n,description:o,content:[{type:"LIST",id:"list-0",listType:"INFORMATIVE",autoSubmit:!1,selectedIds:[],items:r}]})];case 1:return e.sent(),[2]}})})},e.bottomSheetSingleSelector=function(e){var t=e.title,n=e.subtitle,o=e.description,r=e.selectedId,i=e.items;return R({title:t,subtitle:n,description:o,content:[{type:"LIST",id:"list-0",listType:"SINGLE_SELECTION",autoSubmit:!0,selectedIds:"string"==typeof r?[r]:[],items:i}]}).then(function(e){var t=e.action,n=e.result;return"SUBMIT"===t?{action:t,selectedId:n[0].selectedIds[0]}:{action:t,selectedId:null}})},e.checkPermissionStatus=function(e,t){return p({type:"OS_PERMISSION_STATUS",payload:{feature:e,params:t}}).then(function(e){return e.granted})},e.createCalendarEvent=function(e){var t=e.beginTime,n=e.endTime,o=e.title;return p({type:"CREATE_CALENDAR_EVENT",payload:{beginTime:g(t),endTime:g(n),title:o}})},e.dismiss=function(e){return p({type:"DISMISS",payload:{onCompletionUrl:e}})},e.fetch=function(e){var t=e.url,n=e.method,o=e.headers,r=e.body;return f()?p({type:"FETCH",payload:{url:t,method:n,headers:o,body:r}}).catch(function(){return{status:500,headers:{},body:"Bridge call failed"}}):Promise.resolve({status:500,headers:{},body:"Bridge not available"})},e.fetchContactsByPhone=function(e){return p({type:"FETCH_CONTACTS_DATA",payload:{phoneNumbers:e}})},e.fetchPhoneNumbers=function(){return p({type:"FETCH_PHONE_NUMBERS"})},e.getAppMetadata=function(e){return p({type:"GET_APP_METADATA",payload:{appToken:e}})},e.getCustomerHash=function(){return p({type:"GET_CUSTOMER_HASH"})},e.getDiskSpaceInfo=function(){return p({type:"GET_DISK_SPACE_INFO"})},e.getEsimInfo=function(){return p({type:"GET_ESIM_INFO"}).catch(function(){return{supportsEsim:!1}})},e.getTopazToken=function(e){return void 0===e&&(e={}),p({type:"GET_TOPAZ_TOKEN",payload:{}},e.timeout)},e.highlightNavigationTab=function(e){var t=e.tab,n=e.highlight,o=e.count;return p({type:"HIGHLIGHT_TAB",payload:{tab:t,highlight:n,count:o}})},e.internalNavigation=function(e){return p({type:"INTERNAL_NAVIGATION",payload:{feature:e}})},e.isABTestingAvailable=function(e){if(v)return Promise.resolve(w(e));var t=new Promise(function(e){setTimeout(function(){e(!1)},500)}),n=p({type:"GET_REMOTE_CONFIG"}).then(function(t){return v=t,w(e)});return Promise.race([t,n])},e.isWebViewBridgeAvailable=f,e.logEcommerceEvent=function(e,t){return t=b(b({},t),{screenName:t.screenName||C}),I({onAndroid:function(n){return n.logEvent&&n.logEvent(e,JSON.stringify(t)),Promise.resolve()},onIos:function(n){return n.postMessage({command:"logEvent",name:e,parameters:t}),Promise.resolve()},onWeb:function(){return Promise.resolve()}})},e.logEvent=function(e,t){var n,o,r,i,a,u,s=b(b({},O),t).sanitize,c=e.name,l=h(e,["name"]);if(c)Object.keys(l).length>25&&console.warn("Trying to log FirebaseEvent with name ".concat(c," exceeding the limit of ").concat(25," params")),s&&(l=_(l),c=N(c));else{if(!e.category||!e.action)return console.warn('LegacyAnalyticsEvent should have "category" and "action"',{category:e.category,action:e.action}),Promise.resolve();o=(n=e).category,r=n.action,i=n.label,a=n.value,u=h(n,["category","action","label","value"]),i||(i="null_label"),a||(a=0),l=b({eventCategory:o,eventAction:r,eventLabel:A(i),eventValue:a},u),c=e.category}return l=b(b({},l),{screenName:l.screenName||C}),I({onAndroid:function(e){return e.logEvent&&e.logEvent(c,JSON.stringify(l)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:c,parameters:l}),Promise.resolve()},onWeb:function(e){return new Promise(function(t){e("event",c,b(b({},l),{event_callback:P(t)}))})}})},e.logTiming=function(e){var t=e.category,n=void 0===t?"performance_timer":t,o=e.variable,r=e.value,i=e.label;if(!n||!o||!r)return console.warn('Analytics timing should have "category", "variable" and "value"',{category:n,variable:o,value:r}),Promise.resolve();var a={timingCategory:n,timingVar:o,timingValue:r=Math.round(r),timingLabel:i},u=n;return I({onAndroid:function(e){return e.logEvent&&e.logEvent(u,JSON.stringify(a)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:u,parameters:a}),Promise.resolve()},onWeb:function(){return new Promise(function(e){gtag("event",u,b(b({},a),{event_callback:P(e)}))})}})},e.logout=function(){return p({type:"LOG_OUT"})},e.nativeAlert=function(e){var t=e.message,n=e.title,o=e.buttonText;return f()?p({type:"ALERT",payload:{title:n,message:t,buttonText:o}}):("undefined"!=typeof window&&window.alert(t),Promise.resolve())},e.nativeConfirm=function(e){var t=e.message,n=e.title,o=e.acceptText,r=e.cancelText;return f()?p({type:"CONFIRM",payload:{message:t,title:n,acceptText:o,cancelText:r}}).then(function(e){return e.result}):Promise.resolve("undefined"!=typeof window&&window.confirm(t))},e.nativeMessage=function(e){var t=e.message,n=e.duration,o=e.buttonText,r=e.type;return f()?p({type:"MESSAGE",payload:{message:t,duration:n,buttonText:o,type:r}}):("undefined"!=typeof window&&window.alert(t),Promise.resolve())},e.notifyBridgeReady=function(){return p({type:"BRIDGE_READY"})},e.notifyPageLoaded=function(){return p({type:"PAGE_LOADED"})},e.onNativeEvent=function(e){return y("NATIVE_EVENT",function(t){return{action:e({event:t.event}).action||"default"}})},e.onSessionRenewed=function(e){return y("SESSION_RENEWED",function(t){var n=t.accessToken;return e(n)})},e.renewSession=function(e,t){return void 0===t&&(t={}),p({type:"RENEW_SESSION",payload:{accessToken:e||null}},t.timeout).then(function(e){return e.accessToken})},e.reportStatus=function(e){var t=e.feature,n=e.status,o=e.reason;return p({type:"STATUS_REPORT",payload:{feature:t,status:n,reason:o}})},e.requestContact=function(e){var t=(void 0===e?{}:e).filter;return p({type:"GET_CONTACT_DATA",payload:{filter:void 0===t?"phone":t}})},e.requestDeviceImei=function(){return p({type:"IMEI"},200).then(function(e){return e.imei}).catch(function(){return null})},e.requestSimIcc=function(){return p({type:"SIM_ICC"},200).then(function(e){return e.icc}).catch(function(){return null})},e.requestSimImsi=function(){return p({type:"IMSI"},200).then(function(e){return e.imsi}).catch(function(){return null})},e.requestVibration=function(e){return p({type:"VIBRATION",payload:{type:e}})},e.sanitizeAnalyticsParam=N,e.sanitizeAnalyticsParams=_,e.setActionBehavior=function(e){return p({type:"SET_ACTION_BEHAVIOR",payload:{actions:e}}).catch(function(){})},e.setCustomerHash=function(e){return p({type:"SET_CUSTOMER_HASH",payload:{hash:e}})},e.setLogger=function(e){d=e},e.setScreenName=function(e,t){if(!e)return console.warn("Missing analytics screenName"),Promise.resolve();var n=C;return C=e,I({onAndroid:function(n){return n.setScreenNameWithParams?n.setScreenNameWithParams(e,JSON.stringify(t)):n.setScreenName&&n.setScreenName(e),Promise.resolve()},onIos:function(n){return n.postMessage({command:"setScreenName",name:e,parameters:t}),Promise.resolve()},onWeb:function(o){return new Promise(function(r){o("event","page_view",b(b({screenName:e,page_title:e,previousScreenName:n},_(null!==t&&void 0!==t?t:{})),{event_callback:P(r)}))})}})},e.setTrackingProperty=function(e,t,n){return p({type:"SET_TRACKING_PROPERTY",payload:{system:e,name:t,value:n}}).catch(function(){})},e.setUserProperty=function(e,t){return e&&t?(t=String(t),I({onAndroid:function(n){return n.setUserProperty&&n.setUserProperty(e,t),Promise.resolve()},onIos:function(n){return n.postMessage({command:"setUserProperty",name:e,value:t}),Promise.resolve()},onWeb:function(n){var o;return n("set","user_properties",((o={})[e]=N(t),o)),Promise.resolve()}})):(console.warn("Trying to set analytics user property without name or value",e,t),Promise.resolve())},e.setWebViewTitle=function(e){return f()?m({title:e}):("undefined"!=typeof document&&(document.title=e),Promise.resolve())},e.share=function(e){return p({type:"SHARE",payload:e})},e.showAppRating=function(){return p({type:"SHOW_APP_RATING"})},e.updateNavigationBar=m,e.updatePhoneNumbers=function(e){return p({type:"UPDATE_PHONE_NUMBERS",payload:{phoneNumbers:e}})},Object.defineProperty(e,"__esModule",{value:!0}),e}({}); |
@@ -463,2 +463,13 @@ (function (global, factory) { | ||
}; | ||
var fetchPhoneNumbers = function () { | ||
return postMessageToNativeApp({ | ||
type: 'FETCH_PHONE_NUMBERS', | ||
}); | ||
}; | ||
var updatePhoneNumbers = function (phoneNumbers) { | ||
return postMessageToNativeApp({ | ||
type: 'UPDATE_PHONE_NUMBERS', | ||
payload: { phoneNumbers: phoneNumbers }, | ||
}); | ||
}; | ||
@@ -1041,2 +1052,3 @@ var highlightNavigationTab = function (_a) { | ||
exports.fetchContactsByPhone = fetchContactsByPhone; | ||
exports.fetchPhoneNumbers = fetchPhoneNumbers; | ||
exports.getAppMetadata = getAppMetadata; | ||
@@ -1081,2 +1093,3 @@ exports.getCustomerHash = getCustomerHash; | ||
exports.updateNavigationBar = updateNavigationBar; | ||
exports.updatePhoneNumbers = updatePhoneNumbers; | ||
@@ -1083,0 +1096,0 @@ Object.defineProperty(exports, '__esModule', { value: true }); |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).webviewBridge={})}(this,function(e){"use strict";var t=1,n="".concat(Date.now(),"-").concat(String(Math.random()).slice(-8)),o="__tuenti_webview_bridge",r=function(){return!("undefined"==typeof window||!window.tuentiWebView||!window.tuentiWebView.postMessage)},i=function(){return!!("undefined"!=typeof window&&window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.tuentiWebView&&window.webkit.messageHandlers.tuentiWebView.postMessage)},a=function(){return"undefined"==typeof window?null:r()?function(e){window.tuentiWebView.postMessage(e)}:i()?function(e){window.webkit.messageHandlers.tuentiWebView.postMessage(e)}:null},u=[],s=function(e){u.push(e)},c=function(e){u=u.filter(function(t){return t!==e})},l=function(){var e;return"undefined"!=typeof window&&(!!function(){try{return window.self!==window.top}catch(e){return!0}}()&&!(null===(e=null===window||void 0===window?void 0:window.frameElement)||void 0===e?void 0:e.hasAttribute("data-enable-webview-bridge")))},f=void 0,d=function(){return!l()&&(r()||i())},p=function(e,o){var r=e.type,i=e.id,u=void 0===i?"web-".concat(t++,"-").concat(n):i,l=e.payload,d=a(),p=JSON.stringify({type:r,id:u,payload:l});return null===f||void 0===f||f("[WebView Bridge] SEND:",p),d?(setTimeout(function(){d(p)}),new Promise(function(e,t){var n=!1,i=function(o){o.id!==u||n||(o.type===r?e(o.payload):"ERROR"===o.type?t(o.payload):t({code:500,reason:"bad type: ".concat(o.type,". Expecting ").concat(r)}),c(i))};s(i),o&&setTimeout(function(){n=!0,c(i),t({code:408,reason:"request timeout"})},o)})):Promise.reject({code:500,reason:"WebView postMessage not available"})};"undefined"!=typeof window&&(window[o]=window[o]||{postMessage:function(e){var t;null===f||void 0===f||f("[WebView Bridge] RCVD:",e);try{t=JSON.parse(e)}catch(t){throw Error("Problem parsing webview message: ".concat(e))}u.forEach(function(e){return e(t)})}});var y=function(e,t){var n=function(n){n.type===e&&Promise.resolve(t(n.payload)).then(function(e){var t=a();t&&t(JSON.stringify({type:n.type,id:n.id,payload:e}))})};return s(n),function(){c(n)}},m=function(e){var t=e.title,n=e.expandedTitle,o=e.showBackButton,r=e.showReloadButton,i=e.showProfileButton,a=e.backgroundColor;return d()?p({type:"NAVIGATION_BAR",payload:{title:t,expandedTitle:n,showBackButton:o,showReloadButton:r,showProfileButton:i,backgroundColor:a}}):(void 0!==t&&"undefined"!=typeof document&&(document.title=t),Promise.resolve())},v=null,w=function(e){return"true"===v.result[e]},g=function(e){return Math.floor(e/1e3)},b=function(){return(b=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)};function h(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n}function T(e,t,n,o){return new(n||(n=Promise))(function(r,i){function a(e){try{s(o.next(e))}catch(e){i(e)}}function u(e){try{s(o.throw(e))}catch(e){i(e)}}function s(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,u)}s((o=o.apply(e,t||[])).next())})}function E(e,t){var n,o,r,i,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,o=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(r=(r=a.trys).length>0&&r[r.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){a.label=i[1];break}if(6===i[0]&&a.label<r[1]){a.label=r[1],r=i;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(i);break}r[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}var S=0,I=function(e){var t=setTimeout(function(){e(),S++},500);return function(){clearTimeout(t),S=0,e()}},A=function(e){var t=e.onAndroid,n=e.onIos,o=e.onWeb;return"undefined"==typeof window?Promise.resolve():window.AnalyticsWebInterface?t(window.AnalyticsWebInterface):window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.firebase?n(window.webkit.messageHandlers.firebase):window.gtag&&S<3?o(window.gtag):Promise.resolve()},P=function(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"")},_=function(e){return P(e).toLocaleLowerCase().replace(/[^a-z0-9\s\-\_\/\|\:]/g,"").replace(/\s+/g," ").trim().replace(/\s/g,"_").slice(0,100)},N=function(e){var t={};return Object.entries(e).forEach(function(e){var n=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var o,r,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(o=i.next()).done;)a.push(o.value)}catch(e){r={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return a}(e,2),o=n[0],r=n[1],i=r,a=o.slice(0,40);"string"==typeof r&&(i=_(r)),t[a]=i}),t},O={sanitize:!0},C="",M=!1,R=function(e){return T(void 0,void 0,void 0,function(){var t,n,o;return E(this,function(r){switch(r.label){case 0:if(M)throw{code:423,reason:"BottomSheet is locked. You can only have one bottom sheet in the screen"};M=!0,t=setTimeout(function(){M=!1},1e3),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,p({type:"SHEET",payload:e})];case 2:return n=r.sent(),M=!1,clearTimeout(t),[2,n];case 3:throw o=r.sent(),M=!1,clearTimeout(t),o;case 4:return[2]}})})};e.CD_EVENT_VALUE=8,e.CD_NOVUM_UID=7,e.CD_WEBAPP_INSTALLED=4,e.attachToEmail=function(e){var t=e.url,n=e.subject,o=e.fileName,r=e.recipient,i=e.body;return p({type:"ATTACH_TO_EMAIL",payload:{url:t,subject:n,fileName:o,recipient:r,body:i}})},e.bottomSheet=R,e.bottomSheetActionSelector=function(e){var t=e.title,n=e.subtitle,o=e.description,r=e.items;return R({title:t,subtitle:n,description:o,content:[{type:"LIST",id:"list-0",listType:"ACTIONS",autoSubmit:!0,selectedIds:[],items:r}]}).then(function(e){var t=e.action,n=e.result;return"SUBMIT"===t?{action:t,selectedId:n[0].selectedIds[0]}:{action:t,selectedId:null}})},e.bottomSheetInfo=function(e){var t=e.title,n=e.subtitle,o=e.description,r=e.items;return T(void 0,void 0,void 0,function(){return E(this,function(e){switch(e.label){case 0:return[4,R({title:t,subtitle:n,description:o,content:[{type:"LIST",id:"list-0",listType:"INFORMATIVE",autoSubmit:!1,selectedIds:[],items:r}]})];case 1:return e.sent(),[2]}})})},e.bottomSheetSingleSelector=function(e){var t=e.title,n=e.subtitle,o=e.description,r=e.selectedId,i=e.items;return R({title:t,subtitle:n,description:o,content:[{type:"LIST",id:"list-0",listType:"SINGLE_SELECTION",autoSubmit:!0,selectedIds:"string"==typeof r?[r]:[],items:i}]}).then(function(e){var t=e.action,n=e.result;return"SUBMIT"===t?{action:t,selectedId:n[0].selectedIds[0]}:{action:t,selectedId:null}})},e.checkPermissionStatus=function(e,t){return p({type:"OS_PERMISSION_STATUS",payload:{feature:e,params:t}}).then(function(e){return e.granted})},e.createCalendarEvent=function(e){var t=e.beginTime,n=e.endTime,o=e.title;return p({type:"CREATE_CALENDAR_EVENT",payload:{beginTime:g(t),endTime:g(n),title:o}})},e.dismiss=function(e){return p({type:"DISMISS",payload:{onCompletionUrl:e}})},e.fetch=function(e){var t=e.url,n=e.method,o=e.headers,r=e.body;return d()?p({type:"FETCH",payload:{url:t,method:n,headers:o,body:r}}).catch(function(){return{status:500,headers:{},body:"Bridge call failed"}}):Promise.resolve({status:500,headers:{},body:"Bridge not available"})},e.fetchContactsByPhone=function(e){return p({type:"FETCH_CONTACTS_DATA",payload:{phoneNumbers:e}})},e.getAppMetadata=function(e){return p({type:"GET_APP_METADATA",payload:{appToken:e}})},e.getCustomerHash=function(){return p({type:"GET_CUSTOMER_HASH"})},e.getDiskSpaceInfo=function(){return p({type:"GET_DISK_SPACE_INFO"})},e.getEsimInfo=function(){return p({type:"GET_ESIM_INFO"}).catch(function(){return{supportsEsim:!1}})},e.getTopazToken=function(e){return void 0===e&&(e={}),p({type:"GET_TOPAZ_TOKEN",payload:{}},e.timeout)},e.highlightNavigationTab=function(e){var t=e.tab,n=e.highlight,o=e.count;return p({type:"HIGHLIGHT_TAB",payload:{tab:t,highlight:n,count:o}})},e.internalNavigation=function(e){return p({type:"INTERNAL_NAVIGATION",payload:{feature:e}})},e.isABTestingAvailable=function(e){if(v)return Promise.resolve(w(e));var t=new Promise(function(e){setTimeout(function(){e(!1)},500)}),n=p({type:"GET_REMOTE_CONFIG"}).then(function(t){return v=t,w(e)});return Promise.race([t,n])},e.isWebViewBridgeAvailable=d,e.logEcommerceEvent=function(e,t){return t=b(b({},t),{screenName:t.screenName||C}),A({onAndroid:function(n){return n.logEvent&&n.logEvent(e,JSON.stringify(t)),Promise.resolve()},onIos:function(n){return n.postMessage({command:"logEvent",name:e,parameters:t}),Promise.resolve()},onWeb:function(){return Promise.resolve()}})},e.logEvent=function(e,t){var n,o,r,i,a,u,s=b(b({},O),t).sanitize,c=e.name,l=h(e,["name"]);if(c)Object.keys(l).length>25&&console.warn("Trying to log FirebaseEvent with name ".concat(c," exceeding the limit of ").concat(25," params")),s&&(l=N(l),c=_(c));else{if(!e.category||!e.action)return console.warn('LegacyAnalyticsEvent should have "category" and "action"',{category:e.category,action:e.action}),Promise.resolve();o=(n=e).category,r=n.action,i=n.label,a=n.value,u=h(n,["category","action","label","value"]),i||(i="null_label"),a||(a=0),l=b({eventCategory:o,eventAction:r,eventLabel:P(i),eventValue:a},u),c=e.category}return l=b(b({},l),{screenName:l.screenName||C}),A({onAndroid:function(e){return e.logEvent&&e.logEvent(c,JSON.stringify(l)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:c,parameters:l}),Promise.resolve()},onWeb:function(e){return new Promise(function(t){e("event",c,b(b({},l),{event_callback:I(t)}))})}})},e.logTiming=function(e){var t=e.category,n=void 0===t?"performance_timer":t,o=e.variable,r=e.value,i=e.label;if(!n||!o||!r)return console.warn('Analytics timing should have "category", "variable" and "value"',{category:n,variable:o,value:r}),Promise.resolve();var a={timingCategory:n,timingVar:o,timingValue:r=Math.round(r),timingLabel:i},u=n;return A({onAndroid:function(e){return e.logEvent&&e.logEvent(u,JSON.stringify(a)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:u,parameters:a}),Promise.resolve()},onWeb:function(){return new Promise(function(e){gtag("event",u,b(b({},a),{event_callback:I(e)}))})}})},e.logout=function(){return p({type:"LOG_OUT"})},e.nativeAlert=function(e){var t=e.message,n=e.title,o=e.buttonText;return d()?p({type:"ALERT",payload:{title:n,message:t,buttonText:o}}):("undefined"!=typeof window&&window.alert(t),Promise.resolve())},e.nativeConfirm=function(e){var t=e.message,n=e.title,o=e.acceptText,r=e.cancelText;return d()?p({type:"CONFIRM",payload:{message:t,title:n,acceptText:o,cancelText:r}}).then(function(e){return e.result}):Promise.resolve("undefined"!=typeof window&&window.confirm(t))},e.nativeMessage=function(e){var t=e.message,n=e.duration,o=e.buttonText,r=e.type;return d()?p({type:"MESSAGE",payload:{message:t,duration:n,buttonText:o,type:r}}):("undefined"!=typeof window&&window.alert(t),Promise.resolve())},e.notifyBridgeReady=function(){return p({type:"BRIDGE_READY"})},e.notifyPageLoaded=function(){return p({type:"PAGE_LOADED"})},e.onNativeEvent=function(e){return y("NATIVE_EVENT",function(t){return{action:e({event:t.event}).action||"default"}})},e.onSessionRenewed=function(e){return y("SESSION_RENEWED",function(t){var n=t.accessToken;return e(n)})},e.renewSession=function(e,t){return void 0===t&&(t={}),p({type:"RENEW_SESSION",payload:{accessToken:e||null}},t.timeout).then(function(e){return e.accessToken})},e.reportStatus=function(e){var t=e.feature,n=e.status,o=e.reason;return p({type:"STATUS_REPORT",payload:{feature:t,status:n,reason:o}})},e.requestContact=function(e){var t=(void 0===e?{}:e).filter;return p({type:"GET_CONTACT_DATA",payload:{filter:void 0===t?"phone":t}})},e.requestDeviceImei=function(){return p({type:"IMEI"},200).then(function(e){return e.imei}).catch(function(){return null})},e.requestSimIcc=function(){return p({type:"SIM_ICC"},200).then(function(e){return e.icc}).catch(function(){return null})},e.requestSimImsi=function(){return p({type:"IMSI"},200).then(function(e){return e.imsi}).catch(function(){return null})},e.requestVibration=function(e){return p({type:"VIBRATION",payload:{type:e}})},e.sanitizeAnalyticsParam=_,e.sanitizeAnalyticsParams=N,e.setActionBehavior=function(e){return p({type:"SET_ACTION_BEHAVIOR",payload:{actions:e}}).catch(function(){})},e.setCustomerHash=function(e){return p({type:"SET_CUSTOMER_HASH",payload:{hash:e}})},e.setLogger=function(e){f=e},e.setScreenName=function(e,t){if(!e)return console.warn("Missing analytics screenName"),Promise.resolve();var n=C;return C=e,A({onAndroid:function(n){return n.setScreenNameWithParams?n.setScreenNameWithParams(e,JSON.stringify(t)):n.setScreenName&&n.setScreenName(e),Promise.resolve()},onIos:function(n){return n.postMessage({command:"setScreenName",name:e,parameters:t}),Promise.resolve()},onWeb:function(o){return new Promise(function(r){o("event","page_view",b(b({screenName:e,page_title:e,previousScreenName:n},N(null!==t&&void 0!==t?t:{})),{event_callback:I(r)}))})}})},e.setTrackingProperty=function(e,t,n){return p({type:"SET_TRACKING_PROPERTY",payload:{system:e,name:t,value:n}}).catch(function(){})},e.setUserProperty=function(e,t){return e&&t?(t=String(t),A({onAndroid:function(n){return n.setUserProperty&&n.setUserProperty(e,t),Promise.resolve()},onIos:function(n){return n.postMessage({command:"setUserProperty",name:e,value:t}),Promise.resolve()},onWeb:function(n){var o;return n("set","user_properties",((o={})[e]=_(t),o)),Promise.resolve()}})):(console.warn("Trying to set analytics user property without name or value",e,t),Promise.resolve())},e.setWebViewTitle=function(e){return d()?m({title:e}):("undefined"!=typeof document&&(document.title=e),Promise.resolve())},e.share=function(e){return p({type:"SHARE",payload:e})},e.showAppRating=function(){return p({type:"SHOW_APP_RATING"})},e.updateNavigationBar=m,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).webviewBridge={})}(this,function(e){"use strict";var t=1,n="".concat(Date.now(),"-").concat(String(Math.random()).slice(-8)),o="__tuenti_webview_bridge",r=function(){return!("undefined"==typeof window||!window.tuentiWebView||!window.tuentiWebView.postMessage)},i=function(){return!!("undefined"!=typeof window&&window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.tuentiWebView&&window.webkit.messageHandlers.tuentiWebView.postMessage)},a=function(){return"undefined"==typeof window?null:r()?function(e){window.tuentiWebView.postMessage(e)}:i()?function(e){window.webkit.messageHandlers.tuentiWebView.postMessage(e)}:null},u=[],s=function(e){u.push(e)},c=function(e){u=u.filter(function(t){return t!==e})},l=function(){var e;return"undefined"!=typeof window&&(!!function(){try{return window.self!==window.top}catch(e){return!0}}()&&!(null===(e=null===window||void 0===window?void 0:window.frameElement)||void 0===e?void 0:e.hasAttribute("data-enable-webview-bridge")))},f=void 0,d=function(){return!l()&&(r()||i())},p=function(e,o){var r=e.type,i=e.id,u=void 0===i?"web-".concat(t++,"-").concat(n):i,l=e.payload,d=a(),p=JSON.stringify({type:r,id:u,payload:l});return null===f||void 0===f||f("[WebView Bridge] SEND:",p),d?(setTimeout(function(){d(p)}),new Promise(function(e,t){var n=!1,i=function(o){o.id!==u||n||(o.type===r?e(o.payload):"ERROR"===o.type?t(o.payload):t({code:500,reason:"bad type: ".concat(o.type,". Expecting ").concat(r)}),c(i))};s(i),o&&setTimeout(function(){n=!0,c(i),t({code:408,reason:"request timeout"})},o)})):Promise.reject({code:500,reason:"WebView postMessage not available"})};"undefined"!=typeof window&&(window[o]=window[o]||{postMessage:function(e){var t;null===f||void 0===f||f("[WebView Bridge] RCVD:",e);try{t=JSON.parse(e)}catch(t){throw Error("Problem parsing webview message: ".concat(e))}u.forEach(function(e){return e(t)})}});var y=function(e,t){var n=function(n){n.type===e&&Promise.resolve(t(n.payload)).then(function(e){var t=a();t&&t(JSON.stringify({type:n.type,id:n.id,payload:e}))})};return s(n),function(){c(n)}},m=function(e){var t=e.title,n=e.expandedTitle,o=e.showBackButton,r=e.showReloadButton,i=e.showProfileButton,a=e.backgroundColor;return d()?p({type:"NAVIGATION_BAR",payload:{title:t,expandedTitle:n,showBackButton:o,showReloadButton:r,showProfileButton:i,backgroundColor:a}}):(void 0!==t&&"undefined"!=typeof document&&(document.title=t),Promise.resolve())},v=null,w=function(e){return"true"===v.result[e]},g=function(e){return Math.floor(e/1e3)},b=function(){return(b=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)};function h(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n}function T(e,t,n,o){return new(n||(n=Promise))(function(r,i){function a(e){try{s(o.next(e))}catch(e){i(e)}}function u(e){try{s(o.throw(e))}catch(e){i(e)}}function s(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,u)}s((o=o.apply(e,t||[])).next())})}function E(e,t){var n,o,r,i,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,o&&(r=2&i[0]?o.return:i[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,i[1])).done)return r;switch(o=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,o=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(r=(r=a.trys).length>0&&r[r.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){a.label=i[1];break}if(6===i[0]&&a.label<r[1]){a.label=r[1],r=i;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(i);break}r[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],o=0}finally{n=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}var S=0,P=function(e){var t=setTimeout(function(){e(),S++},500);return function(){clearTimeout(t),S=0,e()}},I=function(e){var t=e.onAndroid,n=e.onIos,o=e.onWeb;return"undefined"==typeof window?Promise.resolve():window.AnalyticsWebInterface?t(window.AnalyticsWebInterface):window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.firebase?n(window.webkit.messageHandlers.firebase):window.gtag&&S<3?o(window.gtag):Promise.resolve()},A=function(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"")},N=function(e){return A(e).toLocaleLowerCase().replace(/[^a-z0-9\s\-\_\/\|\:]/g,"").replace(/\s+/g," ").trim().replace(/\s/g,"_").slice(0,100)},_=function(e){var t={};return Object.entries(e).forEach(function(e){var n=function(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var o,r,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(o=i.next()).done;)a.push(o.value)}catch(e){r={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return a}(e,2),o=n[0],r=n[1],i=r,a=o.slice(0,40);"string"==typeof r&&(i=N(r)),t[a]=i}),t},O={sanitize:!0},C="",M=!1,R=function(e){return T(void 0,void 0,void 0,function(){var t,n,o;return E(this,function(r){switch(r.label){case 0:if(M)throw{code:423,reason:"BottomSheet is locked. You can only have one bottom sheet in the screen"};M=!0,t=setTimeout(function(){M=!1},1e3),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,p({type:"SHEET",payload:e})];case 2:return n=r.sent(),M=!1,clearTimeout(t),[2,n];case 3:throw o=r.sent(),M=!1,clearTimeout(t),o;case 4:return[2]}})})};e.CD_EVENT_VALUE=8,e.CD_NOVUM_UID=7,e.CD_WEBAPP_INSTALLED=4,e.attachToEmail=function(e){var t=e.url,n=e.subject,o=e.fileName,r=e.recipient,i=e.body;return p({type:"ATTACH_TO_EMAIL",payload:{url:t,subject:n,fileName:o,recipient:r,body:i}})},e.bottomSheet=R,e.bottomSheetActionSelector=function(e){var t=e.title,n=e.subtitle,o=e.description,r=e.items;return R({title:t,subtitle:n,description:o,content:[{type:"LIST",id:"list-0",listType:"ACTIONS",autoSubmit:!0,selectedIds:[],items:r}]}).then(function(e){var t=e.action,n=e.result;return"SUBMIT"===t?{action:t,selectedId:n[0].selectedIds[0]}:{action:t,selectedId:null}})},e.bottomSheetInfo=function(e){var t=e.title,n=e.subtitle,o=e.description,r=e.items;return T(void 0,void 0,void 0,function(){return E(this,function(e){switch(e.label){case 0:return[4,R({title:t,subtitle:n,description:o,content:[{type:"LIST",id:"list-0",listType:"INFORMATIVE",autoSubmit:!1,selectedIds:[],items:r}]})];case 1:return e.sent(),[2]}})})},e.bottomSheetSingleSelector=function(e){var t=e.title,n=e.subtitle,o=e.description,r=e.selectedId,i=e.items;return R({title:t,subtitle:n,description:o,content:[{type:"LIST",id:"list-0",listType:"SINGLE_SELECTION",autoSubmit:!0,selectedIds:"string"==typeof r?[r]:[],items:i}]}).then(function(e){var t=e.action,n=e.result;return"SUBMIT"===t?{action:t,selectedId:n[0].selectedIds[0]}:{action:t,selectedId:null}})},e.checkPermissionStatus=function(e,t){return p({type:"OS_PERMISSION_STATUS",payload:{feature:e,params:t}}).then(function(e){return e.granted})},e.createCalendarEvent=function(e){var t=e.beginTime,n=e.endTime,o=e.title;return p({type:"CREATE_CALENDAR_EVENT",payload:{beginTime:g(t),endTime:g(n),title:o}})},e.dismiss=function(e){return p({type:"DISMISS",payload:{onCompletionUrl:e}})},e.fetch=function(e){var t=e.url,n=e.method,o=e.headers,r=e.body;return d()?p({type:"FETCH",payload:{url:t,method:n,headers:o,body:r}}).catch(function(){return{status:500,headers:{},body:"Bridge call failed"}}):Promise.resolve({status:500,headers:{},body:"Bridge not available"})},e.fetchContactsByPhone=function(e){return p({type:"FETCH_CONTACTS_DATA",payload:{phoneNumbers:e}})},e.fetchPhoneNumbers=function(){return p({type:"FETCH_PHONE_NUMBERS"})},e.getAppMetadata=function(e){return p({type:"GET_APP_METADATA",payload:{appToken:e}})},e.getCustomerHash=function(){return p({type:"GET_CUSTOMER_HASH"})},e.getDiskSpaceInfo=function(){return p({type:"GET_DISK_SPACE_INFO"})},e.getEsimInfo=function(){return p({type:"GET_ESIM_INFO"}).catch(function(){return{supportsEsim:!1}})},e.getTopazToken=function(e){return void 0===e&&(e={}),p({type:"GET_TOPAZ_TOKEN",payload:{}},e.timeout)},e.highlightNavigationTab=function(e){var t=e.tab,n=e.highlight,o=e.count;return p({type:"HIGHLIGHT_TAB",payload:{tab:t,highlight:n,count:o}})},e.internalNavigation=function(e){return p({type:"INTERNAL_NAVIGATION",payload:{feature:e}})},e.isABTestingAvailable=function(e){if(v)return Promise.resolve(w(e));var t=new Promise(function(e){setTimeout(function(){e(!1)},500)}),n=p({type:"GET_REMOTE_CONFIG"}).then(function(t){return v=t,w(e)});return Promise.race([t,n])},e.isWebViewBridgeAvailable=d,e.logEcommerceEvent=function(e,t){return t=b(b({},t),{screenName:t.screenName||C}),I({onAndroid:function(n){return n.logEvent&&n.logEvent(e,JSON.stringify(t)),Promise.resolve()},onIos:function(n){return n.postMessage({command:"logEvent",name:e,parameters:t}),Promise.resolve()},onWeb:function(){return Promise.resolve()}})},e.logEvent=function(e,t){var n,o,r,i,a,u,s=b(b({},O),t).sanitize,c=e.name,l=h(e,["name"]);if(c)Object.keys(l).length>25&&console.warn("Trying to log FirebaseEvent with name ".concat(c," exceeding the limit of ").concat(25," params")),s&&(l=_(l),c=N(c));else{if(!e.category||!e.action)return console.warn('LegacyAnalyticsEvent should have "category" and "action"',{category:e.category,action:e.action}),Promise.resolve();o=(n=e).category,r=n.action,i=n.label,a=n.value,u=h(n,["category","action","label","value"]),i||(i="null_label"),a||(a=0),l=b({eventCategory:o,eventAction:r,eventLabel:A(i),eventValue:a},u),c=e.category}return l=b(b({},l),{screenName:l.screenName||C}),I({onAndroid:function(e){return e.logEvent&&e.logEvent(c,JSON.stringify(l)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:c,parameters:l}),Promise.resolve()},onWeb:function(e){return new Promise(function(t){e("event",c,b(b({},l),{event_callback:P(t)}))})}})},e.logTiming=function(e){var t=e.category,n=void 0===t?"performance_timer":t,o=e.variable,r=e.value,i=e.label;if(!n||!o||!r)return console.warn('Analytics timing should have "category", "variable" and "value"',{category:n,variable:o,value:r}),Promise.resolve();var a={timingCategory:n,timingVar:o,timingValue:r=Math.round(r),timingLabel:i},u=n;return I({onAndroid:function(e){return e.logEvent&&e.logEvent(u,JSON.stringify(a)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:u,parameters:a}),Promise.resolve()},onWeb:function(){return new Promise(function(e){gtag("event",u,b(b({},a),{event_callback:P(e)}))})}})},e.logout=function(){return p({type:"LOG_OUT"})},e.nativeAlert=function(e){var t=e.message,n=e.title,o=e.buttonText;return d()?p({type:"ALERT",payload:{title:n,message:t,buttonText:o}}):("undefined"!=typeof window&&window.alert(t),Promise.resolve())},e.nativeConfirm=function(e){var t=e.message,n=e.title,o=e.acceptText,r=e.cancelText;return d()?p({type:"CONFIRM",payload:{message:t,title:n,acceptText:o,cancelText:r}}).then(function(e){return e.result}):Promise.resolve("undefined"!=typeof window&&window.confirm(t))},e.nativeMessage=function(e){var t=e.message,n=e.duration,o=e.buttonText,r=e.type;return d()?p({type:"MESSAGE",payload:{message:t,duration:n,buttonText:o,type:r}}):("undefined"!=typeof window&&window.alert(t),Promise.resolve())},e.notifyBridgeReady=function(){return p({type:"BRIDGE_READY"})},e.notifyPageLoaded=function(){return p({type:"PAGE_LOADED"})},e.onNativeEvent=function(e){return y("NATIVE_EVENT",function(t){return{action:e({event:t.event}).action||"default"}})},e.onSessionRenewed=function(e){return y("SESSION_RENEWED",function(t){var n=t.accessToken;return e(n)})},e.renewSession=function(e,t){return void 0===t&&(t={}),p({type:"RENEW_SESSION",payload:{accessToken:e||null}},t.timeout).then(function(e){return e.accessToken})},e.reportStatus=function(e){var t=e.feature,n=e.status,o=e.reason;return p({type:"STATUS_REPORT",payload:{feature:t,status:n,reason:o}})},e.requestContact=function(e){var t=(void 0===e?{}:e).filter;return p({type:"GET_CONTACT_DATA",payload:{filter:void 0===t?"phone":t}})},e.requestDeviceImei=function(){return p({type:"IMEI"},200).then(function(e){return e.imei}).catch(function(){return null})},e.requestSimIcc=function(){return p({type:"SIM_ICC"},200).then(function(e){return e.icc}).catch(function(){return null})},e.requestSimImsi=function(){return p({type:"IMSI"},200).then(function(e){return e.imsi}).catch(function(){return null})},e.requestVibration=function(e){return p({type:"VIBRATION",payload:{type:e}})},e.sanitizeAnalyticsParam=N,e.sanitizeAnalyticsParams=_,e.setActionBehavior=function(e){return p({type:"SET_ACTION_BEHAVIOR",payload:{actions:e}}).catch(function(){})},e.setCustomerHash=function(e){return p({type:"SET_CUSTOMER_HASH",payload:{hash:e}})},e.setLogger=function(e){f=e},e.setScreenName=function(e,t){if(!e)return console.warn("Missing analytics screenName"),Promise.resolve();var n=C;return C=e,I({onAndroid:function(n){return n.setScreenNameWithParams?n.setScreenNameWithParams(e,JSON.stringify(t)):n.setScreenName&&n.setScreenName(e),Promise.resolve()},onIos:function(n){return n.postMessage({command:"setScreenName",name:e,parameters:t}),Promise.resolve()},onWeb:function(o){return new Promise(function(r){o("event","page_view",b(b({screenName:e,page_title:e,previousScreenName:n},_(null!==t&&void 0!==t?t:{})),{event_callback:P(r)}))})}})},e.setTrackingProperty=function(e,t,n){return p({type:"SET_TRACKING_PROPERTY",payload:{system:e,name:t,value:n}}).catch(function(){})},e.setUserProperty=function(e,t){return e&&t?(t=String(t),I({onAndroid:function(n){return n.setUserProperty&&n.setUserProperty(e,t),Promise.resolve()},onIos:function(n){return n.postMessage({command:"setUserProperty",name:e,value:t}),Promise.resolve()},onWeb:function(n){var o;return n("set","user_properties",((o={})[e]=N(t),o)),Promise.resolve()}})):(console.warn("Trying to set analytics user property without name or value",e,t),Promise.resolve())},e.setWebViewTitle=function(e){return d()?m({title:e}):("undefined"!=typeof document&&(document.title=e),Promise.resolve())},e.share=function(e){return p({type:"SHARE",payload:e})},e.showAppRating=function(){return p({type:"SHOW_APP_RATING"})},e.updateNavigationBar=m,e.updatePhoneNumbers=function(e){return p({type:"UPDATE_PHONE_NUMBERS",payload:{phoneNumbers:e}})},Object.defineProperty(e,"__esModule",{value:!0})}); |
{ | ||
"name": "@tef-novum/webview-bridge", | ||
"version": "3.17.0", | ||
"version": "3.18.0", | ||
"description": "JavaScript library to access to native functionality. Requires a webview with a postMessage bridge.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/webview-bridge-cjs.js", |
@@ -65,29 +65,2 @@ <p align="center"> | ||
- [isWebViewBridgeAvailable](#isWebViewBridgeAvailable) | ||
- [requestContact](#requestcontact) | ||
- [createCalendarEvent](#createcalendarevent) | ||
- [share](#share) | ||
- [updateNavigationBar](#updateNavigationBar) | ||
- [nativeConfirm](#nativeconfirm) | ||
- [nativeAlert](#nativealert) | ||
- [nativeMessage](#nativemessage) | ||
- [logEvent](#logevent) | ||
- [setScreenName](#setscreenname) | ||
- [setUserProperty](#setUserProperty) | ||
- [reportStatus](#reportStatus) | ||
- [checkPermissionStatus](#checkPermissionStatus) | ||
- [internalNavigation](#internalNavigation) | ||
- [dismiss](#dismiss) | ||
- [fetchContactsByPhone](#fetchContactsByPhone) | ||
- [getAppMetadata](#getAppMetadata) | ||
- [setCustomerHash](#setCustomerHash) | ||
- [getDiskSpaceInfo](#getDiskSpaceInfo) | ||
- [getEsimInfo](#getEsimInfo) | ||
- [setTrackingProperty](#setTrackingProperty) | ||
- [setActionBehavior](#setActionBehavior) | ||
- [renewSession](#renewSession) | ||
- [onSessionRenewed](#onSessionRenewed) | ||
- [logout](#logout) | ||
- [getTopazToken](#getTopazToken) | ||
### isWebViewBridgeAvailable | ||
@@ -510,6 +483,3 @@ | ||
```typescript | ||
setUserProperty: ({ | ||
name: string; | ||
value: string; | ||
}) => Promise<void>; | ||
setUserProperty: (name: string, value: string) => Promise<void>; | ||
``` | ||
@@ -522,6 +492,3 @@ | ||
setUserProperty({ | ||
name: 'obIds', | ||
value: 'any-value', | ||
}).then(() => { | ||
setUserProperty('obIds', 'any-value').then(() => { | ||
console.log('User property logged'); | ||
@@ -587,2 +554,4 @@ }); | ||
- `notifications` | ||
- `read-contacts` (Available for app versions 13.10 and higher) | ||
- `write-contacts` (Available for app versions 13.10 and higher) | ||
@@ -614,2 +583,3 @@ ```typescript | ||
- `notification-settings` | ||
- `contact-settings` (Available for app versions 13.10 and higher) | ||
@@ -959,2 +929,28 @@ ```typescript | ||
### fetchPhoneNumbers | ||
Fetch all the phone numbers of the native phonebook | ||
- Available in Novum app since 13.10 version | ||
```ts | ||
fetchPhoneNumbers:() => Promise<Array<{ | ||
id: string; | ||
value: string; | ||
}>>; | ||
``` | ||
### updatePhoneNumbers | ||
Updates the given phone numbers in the native phonebook | ||
- Available in Novum app since 13.10 version | ||
```ts | ||
updatePhoneNumbers:(Array<{ | ||
id: string; | ||
value: string; | ||
}>) => Promise<Void>; | ||
``` | ||
## Error handling | ||
@@ -961,0 +957,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
312448
5927
962