@tef-novum/webview-bridge
Advanced tools
Comparing version 3.45.0 to 3.46.0
@@ -23,1 +23,2 @@ export { isWebViewBridgeAvailable, onNativeEvent, NativeEventHandler, setLogger, } from './src/post-message'; | ||
export { getUnseenNotificationsBadge, setUnseenNotificationsBadge, } from './src/inbox-notifications'; | ||
export { registerDatamobUser, requestDatamobDeviceAdmin, validateDatamobRequirements, } from './src/datamob'; |
@@ -417,2 +417,28 @@ /** | ||
}; | ||
REQUEST_DATAMOB_DEVICE_ADMIN: { | ||
type: 'REQUEST_DATAMOB_DEVICE_ADMIN'; | ||
id: string; | ||
payload: { | ||
isAdmin: boolean; | ||
}; | ||
}; | ||
REGISTER_DATAMOB_USER: { | ||
type: 'REGISTER_DATAMOB_USER'; | ||
id: string; | ||
payload: void; | ||
}; | ||
VALIDATE_DATAMOB_REQUIREMENTS: { | ||
type: 'VALIDATE_DATAMOB_REQUIREMENTS'; | ||
id: string; | ||
payload: { | ||
requirements: { | ||
deviceAdmin: boolean; | ||
googleAccount: boolean; | ||
lockPassword: boolean; | ||
accessibilityOption: boolean; | ||
invalidPhoneNumber: boolean; | ||
invalidToken: boolean; | ||
}; | ||
}; | ||
}; | ||
}; | ||
@@ -419,0 +445,0 @@ export declare type NativeAppResponsePayload<Type extends keyof ResponsesFromNativeApp> = ResponsesFromNativeApp[Type]['payload']; |
@@ -1111,2 +1111,29 @@ define(['exports'], (function (exports) { 'use strict'; | ||
var requestDatamobDeviceAdmin = function () { | ||
return postMessageToNativeApp({ | ||
type: 'REQUEST_DATAMOB_DEVICE_ADMIN', | ||
payload: {}, | ||
}).then(function (_a) { | ||
var isAdmin = _a.isAdmin; | ||
return ({ isAdmin: isAdmin }); | ||
}); | ||
}; | ||
var registerDatamobUser = function (_a) { | ||
var phoneNumber = _a.phoneNumber, tokenPassword = _a.tokenPassword; | ||
return postMessageToNativeApp({ | ||
type: 'REGISTER_DATAMOB_USER', | ||
payload: { phoneNumber: phoneNumber, tokenPassword: tokenPassword }, | ||
}); | ||
}; | ||
var validateDatamobRequirements = function (_a) { | ||
var phoneNumber = _a.phoneNumber, tokenPassword = _a.tokenPassword; | ||
return postMessageToNativeApp({ | ||
type: 'VALIDATE_DATAMOB_REQUIREMENTS', | ||
payload: { phoneNumber: phoneNumber, tokenPassword: tokenPassword }, | ||
}).then(function (_a) { | ||
var requirements = _a.requirements; | ||
return ({ requirements: requirements }); | ||
}); | ||
}; | ||
exports.CD_EVENT_VALUE = CD_EVENT_VALUE; | ||
@@ -1162,5 +1189,7 @@ exports.CD_NOVUM_UID = CD_NOVUM_UID; | ||
exports.readTextFromClipboard = readTextFromClipboard; | ||
exports.registerDatamobUser = registerDatamobUser; | ||
exports.renewSession = renewSession; | ||
exports.reportStatus = reportStatus; | ||
exports.requestContact = requestContact; | ||
exports.requestDatamobDeviceAdmin = requestDatamobDeviceAdmin; | ||
exports.requestDeviceImei = requestDeviceImei; | ||
@@ -1187,2 +1216,3 @@ exports.requestSimIcc = requestSimIcc; | ||
exports.updatePhoneNumbers = updatePhoneNumbers; | ||
exports.validateDatamobRequirements = validateDatamobRequirements; | ||
exports.writeTextToClipboard = writeTextToClipboard; | ||
@@ -1189,0 +1219,0 @@ |
@@ -1113,2 +1113,29 @@ 'use strict'; | ||
var requestDatamobDeviceAdmin = function () { | ||
return postMessageToNativeApp({ | ||
type: 'REQUEST_DATAMOB_DEVICE_ADMIN', | ||
payload: {}, | ||
}).then(function (_a) { | ||
var isAdmin = _a.isAdmin; | ||
return ({ isAdmin: isAdmin }); | ||
}); | ||
}; | ||
var registerDatamobUser = function (_a) { | ||
var phoneNumber = _a.phoneNumber, tokenPassword = _a.tokenPassword; | ||
return postMessageToNativeApp({ | ||
type: 'REGISTER_DATAMOB_USER', | ||
payload: { phoneNumber: phoneNumber, tokenPassword: tokenPassword }, | ||
}); | ||
}; | ||
var validateDatamobRequirements = function (_a) { | ||
var phoneNumber = _a.phoneNumber, tokenPassword = _a.tokenPassword; | ||
return postMessageToNativeApp({ | ||
type: 'VALIDATE_DATAMOB_REQUIREMENTS', | ||
payload: { phoneNumber: phoneNumber, tokenPassword: tokenPassword }, | ||
}).then(function (_a) { | ||
var requirements = _a.requirements; | ||
return ({ requirements: requirements }); | ||
}); | ||
}; | ||
exports.CD_EVENT_VALUE = CD_EVENT_VALUE; | ||
@@ -1164,5 +1191,7 @@ exports.CD_NOVUM_UID = CD_NOVUM_UID; | ||
exports.readTextFromClipboard = readTextFromClipboard; | ||
exports.registerDatamobUser = registerDatamobUser; | ||
exports.renewSession = renewSession; | ||
exports.reportStatus = reportStatus; | ||
exports.requestContact = requestContact; | ||
exports.requestDatamobDeviceAdmin = requestDatamobDeviceAdmin; | ||
exports.requestDeviceImei = requestDeviceImei; | ||
@@ -1189,2 +1218,3 @@ exports.requestSimIcc = requestSimIcc; | ||
exports.updatePhoneNumbers = updatePhoneNumbers; | ||
exports.validateDatamobRequirements = validateDatamobRequirements; | ||
exports.writeTextToClipboard = writeTextToClipboard; |
@@ -1112,2 +1112,29 @@ var webviewBridge = (function (exports) { | ||
var requestDatamobDeviceAdmin = function () { | ||
return postMessageToNativeApp({ | ||
type: 'REQUEST_DATAMOB_DEVICE_ADMIN', | ||
payload: {}, | ||
}).then(function (_a) { | ||
var isAdmin = _a.isAdmin; | ||
return ({ isAdmin: isAdmin }); | ||
}); | ||
}; | ||
var registerDatamobUser = function (_a) { | ||
var phoneNumber = _a.phoneNumber, tokenPassword = _a.tokenPassword; | ||
return postMessageToNativeApp({ | ||
type: 'REGISTER_DATAMOB_USER', | ||
payload: { phoneNumber: phoneNumber, tokenPassword: tokenPassword }, | ||
}); | ||
}; | ||
var validateDatamobRequirements = function (_a) { | ||
var phoneNumber = _a.phoneNumber, tokenPassword = _a.tokenPassword; | ||
return postMessageToNativeApp({ | ||
type: 'VALIDATE_DATAMOB_REQUIREMENTS', | ||
payload: { phoneNumber: phoneNumber, tokenPassword: tokenPassword }, | ||
}).then(function (_a) { | ||
var requirements = _a.requirements; | ||
return ({ requirements: requirements }); | ||
}); | ||
}; | ||
exports.CD_EVENT_VALUE = CD_EVENT_VALUE; | ||
@@ -1163,5 +1190,7 @@ exports.CD_NOVUM_UID = CD_NOVUM_UID; | ||
exports.readTextFromClipboard = readTextFromClipboard; | ||
exports.registerDatamobUser = registerDatamobUser; | ||
exports.renewSession = renewSession; | ||
exports.reportStatus = reportStatus; | ||
exports.requestContact = requestContact; | ||
exports.requestDatamobDeviceAdmin = requestDatamobDeviceAdmin; | ||
exports.requestDeviceImei = requestDeviceImei; | ||
@@ -1188,2 +1217,3 @@ exports.requestSimIcc = requestSimIcc; | ||
exports.updatePhoneNumbers = updatePhoneNumbers; | ||
exports.validateDatamobRequirements = validateDatamobRequirements; | ||
exports.writeTextToClipboard = writeTextToClipboard; | ||
@@ -1190,0 +1220,0 @@ |
@@ -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=[],c=function(e){u.push(e)},s=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)}),s(i))};c(i),o&&setTimeout(function(){n=!0,s(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 c(n),function(){s(n)}},m=function(){return(m=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 v(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 g(e,t,n,o){return new(n||(n=Promise))(function(r,i){function a(e){try{c(o.next(e))}catch(e){i(e)}}function u(e){try{c(o.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,u)}c((o=o.apply(e,t||[])).next())})}function w(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 T=function(e){return d()?p({type:"NAVIGATION_BAR",payload:e}):(void 0!==e.title&&"undefined"!=typeof document&&(document.title=e.title),Promise.resolve())},b=null,E=function(){if(b)return Promise.resolve(m({},b));var e=new Promise(function(e){setTimeout(function(){e({result:{}})},500)}),t=p({type:"GET_REMOTE_CONFIG"}).then(function(e){return m({},b=e)});return Promise.race([e,t])},I=function(e){return Math.floor(e/1e3)},h=0,A=function(e){var t=setTimeout(function(){e(),h++},500);return function(){clearTimeout(t),h=0,e()}},N=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&&h<3?o(window.gtag):Promise.resolve()},_=function(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"")},S=function(e){return _(e).toLocaleLowerCase().replace(/[^a-zß0-9\s\-\_\/\|\:]/g,"").replace(/\s+/g," ").trim().replace(/\s/g,"_").slice(0,100)},O=function(e){var t={};return Object.entries(e).forEach(function(e){var n=e[0],o=e[1],r=o,i=n.slice(0,40);"string"==typeof o&&(r=S(o)),t[i]=r}),t},P={sanitize:!0},C="",R=!1,D=function(e){if(R)return Promise.reject({code:423,reason:"BottomSheet is locked. You can only have one bottom sheet in the screen"});R=!0;var t=setTimeout(function(){R=!1},1e3);return p({type:"SHEET",payload:e}).then(function(e){return R=!1,clearTimeout(t),e}).catch(function(e){throw R=!1,clearTimeout(t),e})};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=D,e.bottomSheetActionSelector=function(e){var t=e.title,n=e.subtitle,o=e.description,r=e.items;return D({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 D({title:t,subtitle:n,description:o,content:[{type:"LIST",id:"list-0",listType:"INFORMATIVE",autoSubmit:!1,selectedIds:[],items:r}]}).then(function(){})},e.bottomSheetSingleSelector=function(e){var t=e.title,n=e.subtitle,o=e.description,r=e.selectedId,i=e.items;return D({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:I(t),endTime:I(n),title:o}})},e.dismiss=function(e){return p({type:"DISMISS",payload:{onCompletionUrl:e}})},e.downloadBase64=function(e){return p({type:"DOWNLOAD_BASE64",payload:{content:e.contentInBase64,fileName:e.fileName}})},e.fetch=function(e){var t=e.url,n=e.method,o=e.headers,r=e.body;return p({type:"FETCH",payload:{url:t,method:n,headers:o,body:r}}).catch(function(){return{status:500,headers:{},body:"Bridge call failed"}})},e.fetchContactsByPhone=function(e){return p({type:"FETCH_CONTACTS_DATA",payload:{phoneNumbers:e}})},e.fetchPhoneNumbers=function(){return p({type:"FETCH_PHONE_NUMBERS"})},e.focusNavbar=function(){return p({type:"FOCUS_NAVBAR"})},e.getAppMetadata=function(e){return p({type:"GET_APP_METADATA",payload:{appToken:e}})},e.getAttStatus=function(){return p({type:"GET_ATT_STATUS"}).catch(function(){return null})},e.getBatteryInfo=function(){return p({type:"GET_BATTERY_INFO"})},e.getDeviceModel=function(){return p({type:"MODEL"}).catch(function(){return null})},e.getDeviceTac=function(){return p({type:"TAC"}).catch(function(){return{tac:null}})},e.getDiskSpaceInfo=function(){return p({type:"GET_DISK_SPACE_INFO"})},e.getEsimInfo=function(){return p({type:"GET_ESIM_INFO"}).catch(function(){return{supportsEsim:!1,eid:null}})},e.getInstallationId=function(){return p({type:"GET_INSTALLATION_ID"})},e.getNetworkConnectionInfo=function(){return p({type:"DATA_CONNECTION_INFO",payload:{}})},e.getPincodeInfo=function(){return p({type:"GET_PINCODE_INFO"})},e.getProfileImage=function(){return p({type:"GET_PROFILE_IMAGE"})},e.getRemoteConfig=E,e.getTopazToken=function(e){return void 0===e&&(e={}),p({type:"GET_TOPAZ_TOKEN",payload:{}},e.timeout)},e.getTopazValues=function(){return p({type:"GET_TOPAZ_VALUES",payload:{}})},e.getUnseenNotificationsBadge=function(){return g(void 0,void 0,void 0,function(){return w(this,function(e){return[2,p({type:"GET_UNSEEN_NOTIFICATIONS_BADGE"})]})})},e.hideLoadingOverlay=function(){return p({type:"HIDE_LOADING_OVERLAY"})},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){return E().then(function(){return function(e){return"true"===b.result[e]}(e)}).catch(function(){return!1})},e.isWebViewBridgeAvailable=d,e.logEcommerceEvent=function(e,t){return t=m(m({},t),{screenName:t.screenName||C}),N({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,c=m(m({},P),t).sanitize,s=e.name,l=v(e,["name"]);if(s)Object.keys(l).length>25&&console.warn("Trying to log FirebaseEvent with name ".concat(s," exceeding the limit of ").concat(25," params")),c&&(l=O(l),s=S(s));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=v(n,["category","action","label","value"]),i||(i="null_label"),a||(a=0),l=m({eventCategory:o,eventAction:r,eventLabel:_(i),eventValue:a},u),s=e.category}return l=m(m({},l),{screenName:l.screenName||C}),N({onAndroid:function(e){return e.logEvent&&e.logEvent(s,JSON.stringify(l)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:s,parameters:l}),Promise.resolve()},onWeb:function(e){return new Promise(function(t){e("event",s,m(m({},l),{event_callback:A(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 N({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,m(m({},a),{event_callback:A(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,i=e.destructive;return d()?p({type:"CONFIRM",payload:{message:t,title:n,acceptText:o,cancelText:r,destructive:i}}).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.buttonAccessibilityLabel,i=e.type,a=e.withDismiss;return d()?p({type:"MESSAGE",payload:{message:t,duration:n,buttonText:o,buttonAccessibilityLabel:r,type:i,withDismiss:a}}).then(function(e){return e&&e.action?e:{action:"DISMISS"}}):("undefined"!=typeof window&&window.alert(t),Promise.resolve({action:"DISMISS"}))},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.onNavigationBarIconClicked=function(e){return y("NAVIGATION_BAR_ICON_CLICKED",e)},e.onSessionRenewed=function(e){return y("SESSION_RENEWED",function(t){return e(t.accessToken)})},e.openOnboarding=function(){return p({type:"OPEN_ONBOARDING"})},e.readTextFromClipboard=function(){var e;return((null===(e=navigator.clipboard)||void 0===e?void 0:e.readText)?navigator.clipboard.readText():Promise.reject()).catch(function(){return p({type:"CLIPBOARD_READ_TEXT"})})},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=S,e.sanitizeAnalyticsParams=O,e.setActionBehavior=function(e){return p({type:"SET_ACTION_BEHAVIOR",payload:{actions:e}}).catch(function(){})},e.setLogger=function(e){f=e},e.setScreenName=function(e,t){if(void 0===t&&(t={}),!e)return console.warn("Missing analytics screenName"),Promise.resolve();var n=C;return C=e,N({onAndroid:function(n){return n.setScreenNameWithParams?n.setScreenNameWithParams(e,JSON.stringify(O(t))):n.setScreenName&&n.setScreenName(e),Promise.resolve()},onIos:function(n){return n.postMessage({command:"setScreenName",name:e,parameters:O(t)}),Promise.resolve()},onWeb:function(o){return new Promise(function(r){o("event","page_view",m(m({screenName:e,page_title:e,previousScreenName:n},O(t)),{event_callback:A(r)}))})}})},e.setTrackingProperty=function(e,t,n){return p({type:"SET_TRACKING_PROPERTY",payload:{system:e,name:t,value:n}}).catch(function(){})},e.setUnseenNotificationsBadge=function(e){return g(void 0,void 0,void 0,function(){return w(this,function(t){return[2,p({type:"SET_UNSEEN_NOTIFICATIONS_BADGE",payload:e})]})})},e.setUserProperty=function(e,t){return e&&t?(t=String(t),N({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]=S(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()?T({title:e}):("undefined"!=typeof document&&(document.title=e),Promise.resolve())},e.share=function(e){return p({type:"SHARE",payload:e})},e.shareBase64=function(e){return p({type:"SHARE_BASE64",payload:{content:e.contentInBase64,fileName:e.fileName}})},e.showAppRating=function(){return p({type:"SHOW_APP_RATING"})},e.showLoadingOverlay=function(e){return p({type:"SHOW_LOADING_OVERLAY",payload:e})},e.startProfileImageFlow=function(){return p({type:"START_PROFILE_IMAGE_FLOW"})},e.triggerPinOrBiometricAuthentication=function(e){return p({type:"TRIGGER_PIN_OR_BIOMETRIC_AUTHENTICATION",payload:{maxSecondsSinceLastValidation:e}})},e.updateNavigationBar=T,e.updatePhoneNumbers=function(e){return p({type:"UPDATE_PHONE_NUMBERS",payload:{phoneNumbers:e}})},e.writeTextToClipboard=function(e){var t;return((null===(t=navigator.clipboard)||void 0===t?void 0:t.writeText)?navigator.clipboard.writeText(e):Promise.reject()).catch(function(){return p({type:"CLIPBOARD_WRITE_TEXT",payload:e})})},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)),r="__tuenti_webview_bridge",o=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:o()?function(e){window.tuentiWebView.postMessage(e)}:i()?function(e){window.webkit.messageHandlers.tuentiWebView.postMessage(e)}:null},u=[],c=function(e){u.push(e)},s=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()&&(o()||i())},p=function(e,r){var o=e.type,i=e.id,u=void 0===i?"web-".concat(t++,"-").concat(n):i,l=e.payload,d=a(),p=JSON.stringify({type:o,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(r){r.id!==u||n||(r.type===o?e(r.payload):"ERROR"===r.type?t(r.payload):t({code:500,reason:"bad type: ".concat(r.type,". Expecting ").concat(o)}),s(i))};c(i),r&&setTimeout(function(){n=!0,s(i),t({code:408,reason:"request timeout"})},r)})):Promise.reject({code:500,reason:"WebView postMessage not available"})};"undefined"!=typeof window&&(window[r]=window[r]||{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 c(n),function(){s(n)}},m=function(){return(m=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function v(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}function g(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function u(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,u)}c((r=r.apply(e,t||[])).next())})}function T(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[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,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}var w=function(e){return d()?p({type:"NAVIGATION_BAR",payload:e}):(void 0!==e.title&&"undefined"!=typeof document&&(document.title=e.title),Promise.resolve())},E=null,b=function(){if(E)return Promise.resolve(m({},E));var e=new Promise(function(e){setTimeout(function(){e({result:{}})},500)}),t=p({type:"GET_REMOTE_CONFIG"}).then(function(e){return m({},E=e)});return Promise.race([e,t])},I=function(e){return Math.floor(e/1e3)},A=0,h=function(e){var t=setTimeout(function(){e(),A++},500);return function(){clearTimeout(t),A=0,e()}},N=function(e){var t=e.onAndroid,n=e.onIos,r=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&&A<3?r(window.gtag):Promise.resolve()},_=function(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"")},S=function(e){return _(e).toLocaleLowerCase().replace(/[^a-zß0-9\s\-\_\/\|\:]/g,"").replace(/\s+/g," ").trim().replace(/\s/g,"_").slice(0,100)},O=function(e){var t={};return Object.entries(e).forEach(function(e){var n=e[0],r=e[1],o=r,i=n.slice(0,40);"string"==typeof r&&(o=S(r)),t[i]=o}),t},P={sanitize:!0},R="",D=!1,C=function(e){if(D)return Promise.reject({code:423,reason:"BottomSheet is locked. You can only have one bottom sheet in the screen"});D=!0;var t=setTimeout(function(){D=!1},1e3);return p({type:"SHEET",payload:e}).then(function(e){return D=!1,clearTimeout(t),e}).catch(function(e){throw D=!1,clearTimeout(t),e})};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,r=e.fileName,o=e.recipient,i=e.body;return p({type:"ATTACH_TO_EMAIL",payload:{url:t,subject:n,fileName:r,recipient:o,body:i}})},e.bottomSheet=C,e.bottomSheetActionSelector=function(e){var t=e.title,n=e.subtitle,r=e.description,o=e.items;return C({title:t,subtitle:n,description:r,content:[{type:"LIST",id:"list-0",listType:"ACTIONS",autoSubmit:!0,selectedIds:[],items:o}]}).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,r=e.description,o=e.items;return C({title:t,subtitle:n,description:r,content:[{type:"LIST",id:"list-0",listType:"INFORMATIVE",autoSubmit:!1,selectedIds:[],items:o}]}).then(function(){})},e.bottomSheetSingleSelector=function(e){var t=e.title,n=e.subtitle,r=e.description,o=e.selectedId,i=e.items;return C({title:t,subtitle:n,description:r,content:[{type:"LIST",id:"list-0",listType:"SINGLE_SELECTION",autoSubmit:!0,selectedIds:"string"==typeof o?[o]:[],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,r=e.title;return p({type:"CREATE_CALENDAR_EVENT",payload:{beginTime:I(t),endTime:I(n),title:r}})},e.dismiss=function(e){return p({type:"DISMISS",payload:{onCompletionUrl:e}})},e.downloadBase64=function(e){return p({type:"DOWNLOAD_BASE64",payload:{content:e.contentInBase64,fileName:e.fileName}})},e.fetch=function(e){var t=e.url,n=e.method,r=e.headers,o=e.body;return p({type:"FETCH",payload:{url:t,method:n,headers:r,body:o}}).catch(function(){return{status:500,headers:{},body:"Bridge call failed"}})},e.fetchContactsByPhone=function(e){return p({type:"FETCH_CONTACTS_DATA",payload:{phoneNumbers:e}})},e.fetchPhoneNumbers=function(){return p({type:"FETCH_PHONE_NUMBERS"})},e.focusNavbar=function(){return p({type:"FOCUS_NAVBAR"})},e.getAppMetadata=function(e){return p({type:"GET_APP_METADATA",payload:{appToken:e}})},e.getAttStatus=function(){return p({type:"GET_ATT_STATUS"}).catch(function(){return null})},e.getBatteryInfo=function(){return p({type:"GET_BATTERY_INFO"})},e.getDeviceModel=function(){return p({type:"MODEL"}).catch(function(){return null})},e.getDeviceTac=function(){return p({type:"TAC"}).catch(function(){return{tac:null}})},e.getDiskSpaceInfo=function(){return p({type:"GET_DISK_SPACE_INFO"})},e.getEsimInfo=function(){return p({type:"GET_ESIM_INFO"}).catch(function(){return{supportsEsim:!1,eid:null}})},e.getInstallationId=function(){return p({type:"GET_INSTALLATION_ID"})},e.getNetworkConnectionInfo=function(){return p({type:"DATA_CONNECTION_INFO",payload:{}})},e.getPincodeInfo=function(){return p({type:"GET_PINCODE_INFO"})},e.getProfileImage=function(){return p({type:"GET_PROFILE_IMAGE"})},e.getRemoteConfig=b,e.getTopazToken=function(e){return void 0===e&&(e={}),p({type:"GET_TOPAZ_TOKEN",payload:{}},e.timeout)},e.getTopazValues=function(){return p({type:"GET_TOPAZ_VALUES",payload:{}})},e.getUnseenNotificationsBadge=function(){return g(void 0,void 0,void 0,function(){return T(this,function(e){return[2,p({type:"GET_UNSEEN_NOTIFICATIONS_BADGE"})]})})},e.hideLoadingOverlay=function(){return p({type:"HIDE_LOADING_OVERLAY"})},e.highlightNavigationTab=function(e){var t=e.tab,n=e.highlight,r=e.count;return p({type:"HIGHLIGHT_TAB",payload:{tab:t,highlight:n,count:r}})},e.internalNavigation=function(e){return p({type:"INTERNAL_NAVIGATION",payload:{feature:e}})},e.isABTestingAvailable=function(e){return b().then(function(){return function(e){return"true"===E.result[e]}(e)}).catch(function(){return!1})},e.isWebViewBridgeAvailable=d,e.logEcommerceEvent=function(e,t){return t=m(m({},t),{screenName:t.screenName||R}),N({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,r,o,i,a,u,c=m(m({},P),t).sanitize,s=e.name,l=v(e,["name"]);if(s)Object.keys(l).length>25&&console.warn("Trying to log FirebaseEvent with name ".concat(s," exceeding the limit of ").concat(25," params")),c&&(l=O(l),s=S(s));else{if(!e.category||!e.action)return console.warn('LegacyAnalyticsEvent should have "category" and "action"',{category:e.category,action:e.action}),Promise.resolve();r=(n=e).category,o=n.action,i=n.label,a=n.value,u=v(n,["category","action","label","value"]),i||(i="null_label"),a||(a=0),l=m({eventCategory:r,eventAction:o,eventLabel:_(i),eventValue:a},u),s=e.category}return l=m(m({},l),{screenName:l.screenName||R}),N({onAndroid:function(e){return e.logEvent&&e.logEvent(s,JSON.stringify(l)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:s,parameters:l}),Promise.resolve()},onWeb:function(e){return new Promise(function(t){e("event",s,m(m({},l),{event_callback:h(t)}))})}})},e.logTiming=function(e){var t=e.category,n=void 0===t?"performance_timer":t,r=e.variable,o=e.value,i=e.label;if(!n||!r||!o)return console.warn('Analytics timing should have "category", "variable" and "value"',{category:n,variable:r,value:o}),Promise.resolve();var a={timingCategory:n,timingVar:r,timingValue:o=Math.round(o),timingLabel:i},u=n;return N({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,m(m({},a),{event_callback:h(e)}))})}})},e.logout=function(){return p({type:"LOG_OUT"})},e.nativeAlert=function(e){var t=e.message,n=e.title,r=e.buttonText;return d()?p({type:"ALERT",payload:{title:n,message:t,buttonText:r}}):("undefined"!=typeof window&&window.alert(t),Promise.resolve())},e.nativeConfirm=function(e){var t=e.message,n=e.title,r=e.acceptText,o=e.cancelText,i=e.destructive;return d()?p({type:"CONFIRM",payload:{message:t,title:n,acceptText:r,cancelText:o,destructive:i}}).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,r=e.buttonText,o=e.buttonAccessibilityLabel,i=e.type,a=e.withDismiss;return d()?p({type:"MESSAGE",payload:{message:t,duration:n,buttonText:r,buttonAccessibilityLabel:o,type:i,withDismiss:a}}).then(function(e){return e&&e.action?e:{action:"DISMISS"}}):("undefined"!=typeof window&&window.alert(t),Promise.resolve({action:"DISMISS"}))},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.onNavigationBarIconClicked=function(e){return y("NAVIGATION_BAR_ICON_CLICKED",e)},e.onSessionRenewed=function(e){return y("SESSION_RENEWED",function(t){return e(t.accessToken)})},e.openOnboarding=function(){return p({type:"OPEN_ONBOARDING"})},e.readTextFromClipboard=function(){var e;return((null===(e=navigator.clipboard)||void 0===e?void 0:e.readText)?navigator.clipboard.readText():Promise.reject()).catch(function(){return p({type:"CLIPBOARD_READ_TEXT"})})},e.registerDatamobUser=function(e){var t=e.phoneNumber,n=e.tokenPassword;return p({type:"REGISTER_DATAMOB_USER",payload:{phoneNumber:t,tokenPassword: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,r=e.reason;return p({type:"STATUS_REPORT",payload:{feature:t,status:n,reason:r}})},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.requestDatamobDeviceAdmin=function(){return p({type:"REQUEST_DATAMOB_DEVICE_ADMIN",payload:{}}).then(function(e){return{isAdmin:e.isAdmin}})},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=S,e.sanitizeAnalyticsParams=O,e.setActionBehavior=function(e){return p({type:"SET_ACTION_BEHAVIOR",payload:{actions:e}}).catch(function(){})},e.setLogger=function(e){f=e},e.setScreenName=function(e,t){if(void 0===t&&(t={}),!e)return console.warn("Missing analytics screenName"),Promise.resolve();var n=R;return R=e,N({onAndroid:function(n){return n.setScreenNameWithParams?n.setScreenNameWithParams(e,JSON.stringify(O(t))):n.setScreenName&&n.setScreenName(e),Promise.resolve()},onIos:function(n){return n.postMessage({command:"setScreenName",name:e,parameters:O(t)}),Promise.resolve()},onWeb:function(r){return new Promise(function(o){r("event","page_view",m(m({screenName:e,page_title:e,previousScreenName:n},O(t)),{event_callback:h(o)}))})}})},e.setTrackingProperty=function(e,t,n){return p({type:"SET_TRACKING_PROPERTY",payload:{system:e,name:t,value:n}}).catch(function(){})},e.setUnseenNotificationsBadge=function(e){return g(void 0,void 0,void 0,function(){return T(this,function(t){return[2,p({type:"SET_UNSEEN_NOTIFICATIONS_BADGE",payload:e})]})})},e.setUserProperty=function(e,t){return e&&t?(t=String(t),N({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 r;return n("set","user_properties",((r={})[e]=S(t),r)),Promise.resolve()}})):(console.warn("Trying to set analytics user property without name or value",e,t),Promise.resolve())},e.setWebViewTitle=function(e){return d()?w({title:e}):("undefined"!=typeof document&&(document.title=e),Promise.resolve())},e.share=function(e){return p({type:"SHARE",payload:e})},e.shareBase64=function(e){return p({type:"SHARE_BASE64",payload:{content:e.contentInBase64,fileName:e.fileName}})},e.showAppRating=function(){return p({type:"SHOW_APP_RATING"})},e.showLoadingOverlay=function(e){return p({type:"SHOW_LOADING_OVERLAY",payload:e})},e.startProfileImageFlow=function(){return p({type:"START_PROFILE_IMAGE_FLOW"})},e.triggerPinOrBiometricAuthentication=function(e){return p({type:"TRIGGER_PIN_OR_BIOMETRIC_AUTHENTICATION",payload:{maxSecondsSinceLastValidation:e}})},e.updateNavigationBar=w,e.updatePhoneNumbers=function(e){return p({type:"UPDATE_PHONE_NUMBERS",payload:{phoneNumbers:e}})},e.validateDatamobRequirements=function(e){var t=e.phoneNumber,n=e.tokenPassword;return p({type:"VALIDATE_DATAMOB_REQUIREMENTS",payload:{phoneNumber:t,tokenPassword:n}}).then(function(e){return{requirements:e.requirements}})},e.writeTextToClipboard=function(e){var t;return((null===(t=navigator.clipboard)||void 0===t?void 0:t.writeText)?navigator.clipboard.writeText(e):Promise.reject()).catch(function(){return p({type:"CLIPBOARD_WRITE_TEXT",payload:e})})},Object.defineProperty(e,"__esModule",{value:!0}),e}({}); |
@@ -1115,2 +1115,29 @@ (function (global, factory) { | ||
var requestDatamobDeviceAdmin = function () { | ||
return postMessageToNativeApp({ | ||
type: 'REQUEST_DATAMOB_DEVICE_ADMIN', | ||
payload: {}, | ||
}).then(function (_a) { | ||
var isAdmin = _a.isAdmin; | ||
return ({ isAdmin: isAdmin }); | ||
}); | ||
}; | ||
var registerDatamobUser = function (_a) { | ||
var phoneNumber = _a.phoneNumber, tokenPassword = _a.tokenPassword; | ||
return postMessageToNativeApp({ | ||
type: 'REGISTER_DATAMOB_USER', | ||
payload: { phoneNumber: phoneNumber, tokenPassword: tokenPassword }, | ||
}); | ||
}; | ||
var validateDatamobRequirements = function (_a) { | ||
var phoneNumber = _a.phoneNumber, tokenPassword = _a.tokenPassword; | ||
return postMessageToNativeApp({ | ||
type: 'VALIDATE_DATAMOB_REQUIREMENTS', | ||
payload: { phoneNumber: phoneNumber, tokenPassword: tokenPassword }, | ||
}).then(function (_a) { | ||
var requirements = _a.requirements; | ||
return ({ requirements: requirements }); | ||
}); | ||
}; | ||
exports.CD_EVENT_VALUE = CD_EVENT_VALUE; | ||
@@ -1166,5 +1193,7 @@ exports.CD_NOVUM_UID = CD_NOVUM_UID; | ||
exports.readTextFromClipboard = readTextFromClipboard; | ||
exports.registerDatamobUser = registerDatamobUser; | ||
exports.renewSession = renewSession; | ||
exports.reportStatus = reportStatus; | ||
exports.requestContact = requestContact; | ||
exports.requestDatamobDeviceAdmin = requestDatamobDeviceAdmin; | ||
exports.requestDeviceImei = requestDeviceImei; | ||
@@ -1191,2 +1220,3 @@ exports.requestSimIcc = requestSimIcc; | ||
exports.updatePhoneNumbers = updatePhoneNumbers; | ||
exports.validateDatamobRequirements = validateDatamobRequirements; | ||
exports.writeTextToClipboard = writeTextToClipboard; | ||
@@ -1193,0 +1223,0 @@ |
@@ -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=[],c=function(e){u.push(e)},s=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)}),s(i))};c(i),o&&setTimeout(function(){n=!0,s(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 c(n),function(){s(n)}},m=function(){return(m=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 v(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 g(e,t,n,o){return new(n||(n=Promise))(function(r,i){function a(e){try{c(o.next(e))}catch(e){i(e)}}function u(e){try{c(o.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,u)}c((o=o.apply(e,t||[])).next())})}function T(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 w=function(e){return d()?p({type:"NAVIGATION_BAR",payload:e}):(void 0!==e.title&&"undefined"!=typeof document&&(document.title=e.title),Promise.resolve())},b=null,E=function(){if(b)return Promise.resolve(m({},b));var e=new Promise(function(e){setTimeout(function(){e({result:{}})},500)}),t=p({type:"GET_REMOTE_CONFIG"}).then(function(e){return m({},b=e)});return Promise.race([e,t])},I=function(e){return Math.floor(e/1e3)},h=0,A=function(e){var t=setTimeout(function(){e(),h++},500);return function(){clearTimeout(t),h=0,e()}},N=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&&h<3?o(window.gtag):Promise.resolve()},_=function(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"")},S=function(e){return _(e).toLocaleLowerCase().replace(/[^a-zß0-9\s\-\_\/\|\:]/g,"").replace(/\s+/g," ").trim().replace(/\s/g,"_").slice(0,100)},O=function(e){var t={};return Object.entries(e).forEach(function(e){var n=e[0],o=e[1],r=o,i=n.slice(0,40);"string"==typeof o&&(r=S(o)),t[i]=r}),t},P={sanitize:!0},C="",R=!1,D=function(e){if(R)return Promise.reject({code:423,reason:"BottomSheet is locked. You can only have one bottom sheet in the screen"});R=!0;var t=setTimeout(function(){R=!1},1e3);return p({type:"SHEET",payload:e}).then(function(e){return R=!1,clearTimeout(t),e}).catch(function(e){throw R=!1,clearTimeout(t),e})};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=D,e.bottomSheetActionSelector=function(e){var t=e.title,n=e.subtitle,o=e.description,r=e.items;return D({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 D({title:t,subtitle:n,description:o,content:[{type:"LIST",id:"list-0",listType:"INFORMATIVE",autoSubmit:!1,selectedIds:[],items:r}]}).then(function(){})},e.bottomSheetSingleSelector=function(e){var t=e.title,n=e.subtitle,o=e.description,r=e.selectedId,i=e.items;return D({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:I(t),endTime:I(n),title:o}})},e.dismiss=function(e){return p({type:"DISMISS",payload:{onCompletionUrl:e}})},e.downloadBase64=function(e){return p({type:"DOWNLOAD_BASE64",payload:{content:e.contentInBase64,fileName:e.fileName}})},e.fetch=function(e){var t=e.url,n=e.method,o=e.headers,r=e.body;return p({type:"FETCH",payload:{url:t,method:n,headers:o,body:r}}).catch(function(){return{status:500,headers:{},body:"Bridge call failed"}})},e.fetchContactsByPhone=function(e){return p({type:"FETCH_CONTACTS_DATA",payload:{phoneNumbers:e}})},e.fetchPhoneNumbers=function(){return p({type:"FETCH_PHONE_NUMBERS"})},e.focusNavbar=function(){return p({type:"FOCUS_NAVBAR"})},e.getAppMetadata=function(e){return p({type:"GET_APP_METADATA",payload:{appToken:e}})},e.getAttStatus=function(){return p({type:"GET_ATT_STATUS"}).catch(function(){return null})},e.getBatteryInfo=function(){return p({type:"GET_BATTERY_INFO"})},e.getDeviceModel=function(){return p({type:"MODEL"}).catch(function(){return null})},e.getDeviceTac=function(){return p({type:"TAC"}).catch(function(){return{tac:null}})},e.getDiskSpaceInfo=function(){return p({type:"GET_DISK_SPACE_INFO"})},e.getEsimInfo=function(){return p({type:"GET_ESIM_INFO"}).catch(function(){return{supportsEsim:!1,eid:null}})},e.getInstallationId=function(){return p({type:"GET_INSTALLATION_ID"})},e.getNetworkConnectionInfo=function(){return p({type:"DATA_CONNECTION_INFO",payload:{}})},e.getPincodeInfo=function(){return p({type:"GET_PINCODE_INFO"})},e.getProfileImage=function(){return p({type:"GET_PROFILE_IMAGE"})},e.getRemoteConfig=E,e.getTopazToken=function(e){return void 0===e&&(e={}),p({type:"GET_TOPAZ_TOKEN",payload:{}},e.timeout)},e.getTopazValues=function(){return p({type:"GET_TOPAZ_VALUES",payload:{}})},e.getUnseenNotificationsBadge=function(){return g(void 0,void 0,void 0,function(){return T(this,function(e){return[2,p({type:"GET_UNSEEN_NOTIFICATIONS_BADGE"})]})})},e.hideLoadingOverlay=function(){return p({type:"HIDE_LOADING_OVERLAY"})},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){return E().then(function(){return function(e){return"true"===b.result[e]}(e)}).catch(function(){return!1})},e.isWebViewBridgeAvailable=d,e.logEcommerceEvent=function(e,t){return t=m(m({},t),{screenName:t.screenName||C}),N({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,c=m(m({},P),t).sanitize,s=e.name,l=v(e,["name"]);if(s)Object.keys(l).length>25&&console.warn("Trying to log FirebaseEvent with name ".concat(s," exceeding the limit of ").concat(25," params")),c&&(l=O(l),s=S(s));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=v(n,["category","action","label","value"]),i||(i="null_label"),a||(a=0),l=m({eventCategory:o,eventAction:r,eventLabel:_(i),eventValue:a},u),s=e.category}return l=m(m({},l),{screenName:l.screenName||C}),N({onAndroid:function(e){return e.logEvent&&e.logEvent(s,JSON.stringify(l)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:s,parameters:l}),Promise.resolve()},onWeb:function(e){return new Promise(function(t){e("event",s,m(m({},l),{event_callback:A(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 N({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,m(m({},a),{event_callback:A(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,i=e.destructive;return d()?p({type:"CONFIRM",payload:{message:t,title:n,acceptText:o,cancelText:r,destructive:i}}).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.buttonAccessibilityLabel,i=e.type,a=e.withDismiss;return d()?p({type:"MESSAGE",payload:{message:t,duration:n,buttonText:o,buttonAccessibilityLabel:r,type:i,withDismiss:a}}).then(function(e){return e&&e.action?e:{action:"DISMISS"}}):("undefined"!=typeof window&&window.alert(t),Promise.resolve({action:"DISMISS"}))},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.onNavigationBarIconClicked=function(e){return y("NAVIGATION_BAR_ICON_CLICKED",e)},e.onSessionRenewed=function(e){return y("SESSION_RENEWED",function(t){return e(t.accessToken)})},e.openOnboarding=function(){return p({type:"OPEN_ONBOARDING"})},e.readTextFromClipboard=function(){var e;return((null===(e=navigator.clipboard)||void 0===e?void 0:e.readText)?navigator.clipboard.readText():Promise.reject()).catch(function(){return p({type:"CLIPBOARD_READ_TEXT"})})},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=S,e.sanitizeAnalyticsParams=O,e.setActionBehavior=function(e){return p({type:"SET_ACTION_BEHAVIOR",payload:{actions:e}}).catch(function(){})},e.setLogger=function(e){f=e},e.setScreenName=function(e,t){if(void 0===t&&(t={}),!e)return console.warn("Missing analytics screenName"),Promise.resolve();var n=C;return C=e,N({onAndroid:function(n){return n.setScreenNameWithParams?n.setScreenNameWithParams(e,JSON.stringify(O(t))):n.setScreenName&&n.setScreenName(e),Promise.resolve()},onIos:function(n){return n.postMessage({command:"setScreenName",name:e,parameters:O(t)}),Promise.resolve()},onWeb:function(o){return new Promise(function(r){o("event","page_view",m(m({screenName:e,page_title:e,previousScreenName:n},O(t)),{event_callback:A(r)}))})}})},e.setTrackingProperty=function(e,t,n){return p({type:"SET_TRACKING_PROPERTY",payload:{system:e,name:t,value:n}}).catch(function(){})},e.setUnseenNotificationsBadge=function(e){return g(void 0,void 0,void 0,function(){return T(this,function(t){return[2,p({type:"SET_UNSEEN_NOTIFICATIONS_BADGE",payload:e})]})})},e.setUserProperty=function(e,t){return e&&t?(t=String(t),N({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]=S(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()?w({title:e}):("undefined"!=typeof document&&(document.title=e),Promise.resolve())},e.share=function(e){return p({type:"SHARE",payload:e})},e.shareBase64=function(e){return p({type:"SHARE_BASE64",payload:{content:e.contentInBase64,fileName:e.fileName}})},e.showAppRating=function(){return p({type:"SHOW_APP_RATING"})},e.showLoadingOverlay=function(e){return p({type:"SHOW_LOADING_OVERLAY",payload:e})},e.startProfileImageFlow=function(){return p({type:"START_PROFILE_IMAGE_FLOW"})},e.triggerPinOrBiometricAuthentication=function(e){return p({type:"TRIGGER_PIN_OR_BIOMETRIC_AUTHENTICATION",payload:{maxSecondsSinceLastValidation:e}})},e.updateNavigationBar=w,e.updatePhoneNumbers=function(e){return p({type:"UPDATE_PHONE_NUMBERS",payload:{phoneNumbers:e}})},e.writeTextToClipboard=function(e){var t;return((null===(t=navigator.clipboard)||void 0===t?void 0:t.writeText)?navigator.clipboard.writeText(e):Promise.reject()).catch(function(){return p({type:"CLIPBOARD_WRITE_TEXT",payload:e})})},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=[],c=function(e){u.push(e)},s=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)}),s(i))};c(i),o&&setTimeout(function(){n=!0,s(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 c(n),function(){s(n)}},m=function(){return(m=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 v(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 g(e,t,n,o){return new(n||(n=Promise))(function(r,i){function a(e){try{c(o.next(e))}catch(e){i(e)}}function u(e){try{c(o.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,u)}c((o=o.apply(e,t||[])).next())})}function T(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 w=function(e){return d()?p({type:"NAVIGATION_BAR",payload:e}):(void 0!==e.title&&"undefined"!=typeof document&&(document.title=e.title),Promise.resolve())},b=null,E=function(){if(b)return Promise.resolve(m({},b));var e=new Promise(function(e){setTimeout(function(){e({result:{}})},500)}),t=p({type:"GET_REMOTE_CONFIG"}).then(function(e){return m({},b=e)});return Promise.race([e,t])},I=function(e){return Math.floor(e/1e3)},h=0,A=function(e){var t=setTimeout(function(){e(),h++},500);return function(){clearTimeout(t),h=0,e()}},N=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&&h<3?o(window.gtag):Promise.resolve()},_=function(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"")},S=function(e){return _(e).toLocaleLowerCase().replace(/[^a-zß0-9\s\-\_\/\|\:]/g,"").replace(/\s+/g," ").trim().replace(/\s/g,"_").slice(0,100)},O=function(e){var t={};return Object.entries(e).forEach(function(e){var n=e[0],o=e[1],r=o,i=n.slice(0,40);"string"==typeof o&&(r=S(o)),t[i]=r}),t},P={sanitize:!0},R="",D=!1,C=function(e){if(D)return Promise.reject({code:423,reason:"BottomSheet is locked. You can only have one bottom sheet in the screen"});D=!0;var t=setTimeout(function(){D=!1},1e3);return p({type:"SHEET",payload:e}).then(function(e){return D=!1,clearTimeout(t),e}).catch(function(e){throw D=!1,clearTimeout(t),e})};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=C,e.bottomSheetActionSelector=function(e){var t=e.title,n=e.subtitle,o=e.description,r=e.items;return C({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 C({title:t,subtitle:n,description:o,content:[{type:"LIST",id:"list-0",listType:"INFORMATIVE",autoSubmit:!1,selectedIds:[],items:r}]}).then(function(){})},e.bottomSheetSingleSelector=function(e){var t=e.title,n=e.subtitle,o=e.description,r=e.selectedId,i=e.items;return C({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:I(t),endTime:I(n),title:o}})},e.dismiss=function(e){return p({type:"DISMISS",payload:{onCompletionUrl:e}})},e.downloadBase64=function(e){return p({type:"DOWNLOAD_BASE64",payload:{content:e.contentInBase64,fileName:e.fileName}})},e.fetch=function(e){var t=e.url,n=e.method,o=e.headers,r=e.body;return p({type:"FETCH",payload:{url:t,method:n,headers:o,body:r}}).catch(function(){return{status:500,headers:{},body:"Bridge call failed"}})},e.fetchContactsByPhone=function(e){return p({type:"FETCH_CONTACTS_DATA",payload:{phoneNumbers:e}})},e.fetchPhoneNumbers=function(){return p({type:"FETCH_PHONE_NUMBERS"})},e.focusNavbar=function(){return p({type:"FOCUS_NAVBAR"})},e.getAppMetadata=function(e){return p({type:"GET_APP_METADATA",payload:{appToken:e}})},e.getAttStatus=function(){return p({type:"GET_ATT_STATUS"}).catch(function(){return null})},e.getBatteryInfo=function(){return p({type:"GET_BATTERY_INFO"})},e.getDeviceModel=function(){return p({type:"MODEL"}).catch(function(){return null})},e.getDeviceTac=function(){return p({type:"TAC"}).catch(function(){return{tac:null}})},e.getDiskSpaceInfo=function(){return p({type:"GET_DISK_SPACE_INFO"})},e.getEsimInfo=function(){return p({type:"GET_ESIM_INFO"}).catch(function(){return{supportsEsim:!1,eid:null}})},e.getInstallationId=function(){return p({type:"GET_INSTALLATION_ID"})},e.getNetworkConnectionInfo=function(){return p({type:"DATA_CONNECTION_INFO",payload:{}})},e.getPincodeInfo=function(){return p({type:"GET_PINCODE_INFO"})},e.getProfileImage=function(){return p({type:"GET_PROFILE_IMAGE"})},e.getRemoteConfig=E,e.getTopazToken=function(e){return void 0===e&&(e={}),p({type:"GET_TOPAZ_TOKEN",payload:{}},e.timeout)},e.getTopazValues=function(){return p({type:"GET_TOPAZ_VALUES",payload:{}})},e.getUnseenNotificationsBadge=function(){return g(void 0,void 0,void 0,function(){return T(this,function(e){return[2,p({type:"GET_UNSEEN_NOTIFICATIONS_BADGE"})]})})},e.hideLoadingOverlay=function(){return p({type:"HIDE_LOADING_OVERLAY"})},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){return E().then(function(){return function(e){return"true"===b.result[e]}(e)}).catch(function(){return!1})},e.isWebViewBridgeAvailable=d,e.logEcommerceEvent=function(e,t){return t=m(m({},t),{screenName:t.screenName||R}),N({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,c=m(m({},P),t).sanitize,s=e.name,l=v(e,["name"]);if(s)Object.keys(l).length>25&&console.warn("Trying to log FirebaseEvent with name ".concat(s," exceeding the limit of ").concat(25," params")),c&&(l=O(l),s=S(s));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=v(n,["category","action","label","value"]),i||(i="null_label"),a||(a=0),l=m({eventCategory:o,eventAction:r,eventLabel:_(i),eventValue:a},u),s=e.category}return l=m(m({},l),{screenName:l.screenName||R}),N({onAndroid:function(e){return e.logEvent&&e.logEvent(s,JSON.stringify(l)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:s,parameters:l}),Promise.resolve()},onWeb:function(e){return new Promise(function(t){e("event",s,m(m({},l),{event_callback:A(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 N({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,m(m({},a),{event_callback:A(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,i=e.destructive;return d()?p({type:"CONFIRM",payload:{message:t,title:n,acceptText:o,cancelText:r,destructive:i}}).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.buttonAccessibilityLabel,i=e.type,a=e.withDismiss;return d()?p({type:"MESSAGE",payload:{message:t,duration:n,buttonText:o,buttonAccessibilityLabel:r,type:i,withDismiss:a}}).then(function(e){return e&&e.action?e:{action:"DISMISS"}}):("undefined"!=typeof window&&window.alert(t),Promise.resolve({action:"DISMISS"}))},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.onNavigationBarIconClicked=function(e){return y("NAVIGATION_BAR_ICON_CLICKED",e)},e.onSessionRenewed=function(e){return y("SESSION_RENEWED",function(t){return e(t.accessToken)})},e.openOnboarding=function(){return p({type:"OPEN_ONBOARDING"})},e.readTextFromClipboard=function(){var e;return((null===(e=navigator.clipboard)||void 0===e?void 0:e.readText)?navigator.clipboard.readText():Promise.reject()).catch(function(){return p({type:"CLIPBOARD_READ_TEXT"})})},e.registerDatamobUser=function(e){var t=e.phoneNumber,n=e.tokenPassword;return p({type:"REGISTER_DATAMOB_USER",payload:{phoneNumber:t,tokenPassword: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.requestDatamobDeviceAdmin=function(){return p({type:"REQUEST_DATAMOB_DEVICE_ADMIN",payload:{}}).then(function(e){return{isAdmin:e.isAdmin}})},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=S,e.sanitizeAnalyticsParams=O,e.setActionBehavior=function(e){return p({type:"SET_ACTION_BEHAVIOR",payload:{actions:e}}).catch(function(){})},e.setLogger=function(e){f=e},e.setScreenName=function(e,t){if(void 0===t&&(t={}),!e)return console.warn("Missing analytics screenName"),Promise.resolve();var n=R;return R=e,N({onAndroid:function(n){return n.setScreenNameWithParams?n.setScreenNameWithParams(e,JSON.stringify(O(t))):n.setScreenName&&n.setScreenName(e),Promise.resolve()},onIos:function(n){return n.postMessage({command:"setScreenName",name:e,parameters:O(t)}),Promise.resolve()},onWeb:function(o){return new Promise(function(r){o("event","page_view",m(m({screenName:e,page_title:e,previousScreenName:n},O(t)),{event_callback:A(r)}))})}})},e.setTrackingProperty=function(e,t,n){return p({type:"SET_TRACKING_PROPERTY",payload:{system:e,name:t,value:n}}).catch(function(){})},e.setUnseenNotificationsBadge=function(e){return g(void 0,void 0,void 0,function(){return T(this,function(t){return[2,p({type:"SET_UNSEEN_NOTIFICATIONS_BADGE",payload:e})]})})},e.setUserProperty=function(e,t){return e&&t?(t=String(t),N({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]=S(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()?w({title:e}):("undefined"!=typeof document&&(document.title=e),Promise.resolve())},e.share=function(e){return p({type:"SHARE",payload:e})},e.shareBase64=function(e){return p({type:"SHARE_BASE64",payload:{content:e.contentInBase64,fileName:e.fileName}})},e.showAppRating=function(){return p({type:"SHOW_APP_RATING"})},e.showLoadingOverlay=function(e){return p({type:"SHOW_LOADING_OVERLAY",payload:e})},e.startProfileImageFlow=function(){return p({type:"START_PROFILE_IMAGE_FLOW"})},e.triggerPinOrBiometricAuthentication=function(e){return p({type:"TRIGGER_PIN_OR_BIOMETRIC_AUTHENTICATION",payload:{maxSecondsSinceLastValidation:e}})},e.updateNavigationBar=w,e.updatePhoneNumbers=function(e){return p({type:"UPDATE_PHONE_NUMBERS",payload:{phoneNumbers:e}})},e.validateDatamobRequirements=function(e){var t=e.phoneNumber,n=e.tokenPassword;return p({type:"VALIDATE_DATAMOB_REQUIREMENTS",payload:{phoneNumber:t,tokenPassword:n}}).then(function(e){return{requirements:e.requirements}})},e.writeTextToClipboard=function(e){var t;return((null===(t=navigator.clipboard)||void 0===t?void 0:t.writeText)?navigator.clipboard.writeText(e):Promise.reject()).catch(function(){return p({type:"CLIPBOARD_WRITE_TEXT",payload:e})})},Object.defineProperty(e,"__esModule",{value:!0})}); |
{ | ||
"name": "@tef-novum/webview-bridge", | ||
"version": "3.45.0", | ||
"version": "3.46.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", |
107
README.md
@@ -1285,2 +1285,11 @@ <p align="center"> | ||
Note: Depending on the configuration used to show the overlay, | ||
`hideLoadingOverlay` won't immediately hide it, in all cases you should wait for | ||
its promise to be resolved in order to know when the native overlay is | ||
effectively closed. | ||
| Overlay Success Example | Overlay Failure Example | | ||
| --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | | ||
| <video src="https://github.com/user-attachments/assets/d46bb10c-e868-42d7-bed3-a171f34192e7"> | <video src="https://github.com/user-attachments/assets/8f2f6a8e-0570-437b-8f98-c905bcb224fd"> | | ||
```ts | ||
@@ -1339,2 +1348,15 @@ showLoadingOverlay: ({ | ||
#### Error cases | ||
If `showLoadingOverlay` is called while the loading overlay is already being | ||
shown, the promise will be rejected with an error object with the following | ||
type: | ||
```ts | ||
{ | ||
code: 503; | ||
description: 'Loading screen already showing'; | ||
} | ||
``` | ||
### getInstallationId | ||
@@ -1377,2 +1399,87 @@ | ||
### requestDatamobDeviceAdmin | ||
<kbd>App version >=25.x</kbd> | ||
Datamob is a native library that offer developers a way to integrate security | ||
and remote device control features into their applications. | ||
The application that implements the Datamob library must be registered as a | ||
system management application (Device Admin). This configuration is essential to | ||
allow the application to have sufficient permissions to execute security | ||
commands, such as screen lock and factory reset. | ||
This method opens a setting screen asking the user to accept system management | ||
permissions for the application. | ||
```ts | ||
requestDatamobDeviceAdmin: () => Promise<{isAdmin: boolean}>; | ||
``` | ||
`isAdmin` is true if the permission was granted. | ||
#### Demo | ||
https://github.com/user-attachments/assets/28095f42-76db-4ac2-9586-e350acef7e1d | ||
### registerDatamobUser | ||
<kbd>App version >=25.x</kbd> | ||
The application that implements the Datamob should have an user registered. This | ||
method is used to register one. | ||
```ts | ||
registerDatamobUser: ({phoneNumber: string, tokenPassword: string}) => Promise<void>; | ||
``` | ||
- `phoneNumber`: The phone number of the user. | ||
- `tokenPassword`: When registering the device, datamob generate an accessKey | ||
that is recorded in the Datamob device registry. By combining this attribute | ||
with a hash that we keep in a password vault, generate this token. | ||
#### Error cases | ||
If the registration fails, the promise will be rejected with an error object | ||
with the following type: | ||
```ts | ||
{ | ||
code: 500; | ||
reason: `Registration error: ${errorDescription}`; | ||
} | ||
``` | ||
### validateDatamobRequirements | ||
<kbd>App version >=25.x</kbd> | ||
Datamob sdk allows to send remote commands to the user device. These remote | ||
commands include actions such as locking the device screen (lock screen) or even | ||
forcing a wipe (factory reset) of the device, providing additional security | ||
control for the end user. | ||
This method returns a map with the requirements. Each requirement is a boolean | ||
value where true is valid, false is not valid. | ||
```ts | ||
validateDatamobRequirements: ({phoneNumber: string, tokenPassword: string}) => Promise<{ | ||
requirements: { | ||
deviceAdmin: boolean; | ||
googleAccount: boolean; | ||
lockPassword: boolean; | ||
accessibilityOption: boolean; | ||
invalidPassword: boolean; | ||
invalidToken: boolean; | ||
} | ||
}> | ||
``` | ||
- `phoneNumber`: The phone number of the user. | ||
- `tokenPassword`: When registering the device, datamob generate an accessKey | ||
that is recorded in the Datamob device registry. By combining this attribute | ||
with a hash that we keep in a password vault, generate this token. | ||
- `requirements`: A map with the requirements. | ||
## Error handling | ||
@@ -1379,0 +1486,0 @@ |
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
348313
28
6949
1502