@tef-novum/webview-bridge
Advanced tools
Comparing version 3.33.0 to 3.34.0
@@ -8,3 +8,3 @@ export { isWebViewBridgeAvailable, onNativeEvent, NativeEventHandler, setLogger, } from './src/post-message'; | ||
requestSimImsi, requestDeviceImei, internalNavigation, dismiss, requestVibration, getDiskSpaceInfo, getEsimInfo, getAttStatus, getDeviceModel, getDeviceTac, } from './src/device'; | ||
export { attachToEmail, share, setWebViewTitle, updateNavigationBar, notifyPageLoaded, notifyBridgeReady, getRemoteConfig, isABTestingAvailable, reportStatus, fetch, checkPermissionStatus, getAppMetadata, getNetworkConnectionInfo, setActionBehavior, getTopazToken, getPincodeInfo, onNavigationBarIconClicked, } from './src/utils'; | ||
export { attachToEmail, share, setWebViewTitle, updateNavigationBar, notifyPageLoaded, notifyBridgeReady, getRemoteConfig, isABTestingAvailable, reportStatus, fetch, checkPermissionStatus, getAppMetadata, getNetworkConnectionInfo, setActionBehavior, getTopazToken, getPincodeInfo, onNavigationBarIconClicked, triggerPinOrBiometricAuthentication, } from './src/utils'; | ||
export type { ShareOptions, NavigationBarIcon } from './src/utils'; | ||
@@ -11,0 +11,0 @@ export { createCalendarEvent } from './src/calendar'; |
@@ -350,2 +350,9 @@ /** | ||
}; | ||
TRIGGER_PIN_OR_BIOMETRIC_AUTHENTICATION: { | ||
type: 'TRIGGER_PIN_OR_BIOMETRIC_AUTHENTICATION'; | ||
id: string; | ||
payload: { | ||
result: 'USER_AUTHENTICATED' | 'USER_ENABLED_AUTHENTICATION' | 'LAST_AUTHENTICATION_STILL_VALID'; | ||
}; | ||
}; | ||
}; | ||
@@ -352,0 +359,0 @@ export declare type NativeAppResponsePayload<Type extends keyof ResponsesFromNativeApp> = ResponsesFromNativeApp[Type]['payload']; |
@@ -154,2 +154,3 @@ import { NativeAppResponsePayload } from './post-message'; | ||
}>; | ||
export declare const triggerPinOrBiometricAuthentication: (maxSecondsSinceLastValidation: number) => Promise<NativeAppResponsePayload<'TRIGGER_PIN_OR_BIOMETRIC_AUTHENTICATION'>>; | ||
export {}; |
@@ -569,2 +569,8 @@ define(['exports'], (function (exports) { 'use strict'; | ||
}; | ||
var triggerPinOrBiometricAuthentication = function (maxSecondsSinceLastValidation) { | ||
return postMessageToNativeApp({ | ||
type: 'TRIGGER_PIN_OR_BIOMETRIC_AUTHENTICATION', | ||
payload: { maxSecondsSinceLastValidation: maxSecondsSinceLastValidation }, | ||
}); | ||
}; | ||
@@ -1157,2 +1163,3 @@ var msToS = function (ms) { return Math.floor(ms / 1000); }; | ||
exports.startProfileImageFlow = startProfileImageFlow; | ||
exports.triggerPinOrBiometricAuthentication = triggerPinOrBiometricAuthentication; | ||
exports.updateNavigationBar = updateNavigationBar; | ||
@@ -1159,0 +1166,0 @@ exports.updatePhoneNumbers = updatePhoneNumbers; |
@@ -571,2 +571,8 @@ 'use strict'; | ||
}; | ||
var triggerPinOrBiometricAuthentication = function (maxSecondsSinceLastValidation) { | ||
return postMessageToNativeApp({ | ||
type: 'TRIGGER_PIN_OR_BIOMETRIC_AUTHENTICATION', | ||
payload: { maxSecondsSinceLastValidation: maxSecondsSinceLastValidation }, | ||
}); | ||
}; | ||
@@ -1159,3 +1165,4 @@ var msToS = function (ms) { return Math.floor(ms / 1000); }; | ||
exports.startProfileImageFlow = startProfileImageFlow; | ||
exports.triggerPinOrBiometricAuthentication = triggerPinOrBiometricAuthentication; | ||
exports.updateNavigationBar = updateNavigationBar; | ||
exports.updatePhoneNumbers = updatePhoneNumbers; |
@@ -570,2 +570,8 @@ var webviewBridge = (function (exports) { | ||
}; | ||
var triggerPinOrBiometricAuthentication = function (maxSecondsSinceLastValidation) { | ||
return postMessageToNativeApp({ | ||
type: 'TRIGGER_PIN_OR_BIOMETRIC_AUTHENTICATION', | ||
payload: { maxSecondsSinceLastValidation: maxSecondsSinceLastValidation }, | ||
}); | ||
}; | ||
@@ -1158,2 +1164,3 @@ var msToS = function (ms) { return Math.floor(ms / 1000); }; | ||
exports.startProfileImageFlow = startProfileImageFlow; | ||
exports.triggerPinOrBiometricAuthentication = triggerPinOrBiometricAuthentication; | ||
exports.updateNavigationBar = updateNavigationBar; | ||
@@ -1160,0 +1167,0 @@ exports.updatePhoneNumbers = updatePhoneNumbers; |
@@ -1,1 +0,1 @@ | ||
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 w(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 b=function(e){return d()?p({type:"NAVIGATION_BAR",payload:e}):(void 0!==e.title&&"undefined"!=typeof document&&(document.title=e.title),Promise.resolve())},h=null,T=function(){if(h)return Promise.resolve(m({},h));var e=new Promise(function(e){setTimeout(function(){e({result:{}})},500)}),t=p({type:"GET_REMOTE_CONFIG"}).then(function(e){return m({},h=e)});return Promise.race([e,t])},E=function(e){return Math.floor(e/1e3)},S=0,I=function(e){var t=setTimeout(function(){e(),S++},500);return function(){clearTimeout(t),S=0,e()}},_=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&&S<3?r(window.gtag):Promise.resolve()},A=function(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"")},N=function(e){return A(e).toLocaleLowerCase().replace(/[^a-zß0-9\s\-\_\/\|\:]/g,"").replace(/\s+/g," ").trim().replace(/\s/g,"_").slice(0,100)},P=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 r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}(e,2),r=n[0],o=n[1],i=o,a=r.slice(0,40);"string"==typeof o&&(i=N(o)),t[a]=i}),t},O={sanitize:!0},C="",M=!1,R=function(e){return g(void 0,void 0,void 0,function(){var t,n,r;return w(this,function(o){switch(o.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),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,p({type:"SHEET",payload:e})];case 2:return n=o.sent(),M=!1,clearTimeout(t),[2,n];case 3:throw r=o.sent(),M=!1,clearTimeout(t),r;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,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=R,e.bottomSheetActionSelector=function(e){var t=e.title,n=e.subtitle,r=e.description,o=e.items;return R({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 g(void 0,void 0,void 0,function(){return w(this,function(e){switch(e.label){case 0:return[4,R({title:t,subtitle:n,description:r,content:[{type:"LIST",id:"list-0",listType:"INFORMATIVE",autoSubmit:!1,selectedIds:[],items:o}]})];case 1:return e.sent(),[2]}})})},e.bottomSheetSingleSelector=function(e){var t=e.title,n=e.subtitle,r=e.description,o=e.selectedId,i=e.items;return R({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:E(t),endTime:E(n),title:r}})},e.dismiss=function(e){return p({type:"DISMISS",payload:{onCompletionUrl:e}})},e.fetch=function(e){var t=e.url,n=e.method,r=e.headers,o=e.body;return d()?p({type:"FETCH",payload:{url:t,method:n,headers:r,body:o}}).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.getAttStatus=function(){return p({type:"GET_ATT_STATUS"}).catch(function(){return null})},e.getCustomerHash=function(){return p({type:"GET_CUSTOMER_HASH"})},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.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=T,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,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 T().then(function(){return function(e){return"true"===h.result[e]}(e)}).catch(function(){return!1})},e.isWebViewBridgeAvailable=d,e.logEcommerceEvent=function(e,t){return t=m(m({},t),{screenName:t.screenName||C}),_({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({},O),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=P(l),s=N(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:A(i),eventValue:a},u),s=e.category}return l=m(m({},l),{screenName:l.screenName||C}),_({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:I(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 _({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:I(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;return d()?p({type:"CONFIRM",payload:{message:t,title:n,acceptText:r,cancelText:o}}).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.type,i=e.withDismiss;return d()?p({type:"MESSAGE",payload:{message:t,duration:n,buttonText:r,type:o,withDismiss:i}}).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){var n=t.accessToken;return e(n)})},e.openOnboarding=function(){return p({type:"OPEN_ONBOARDING"})},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.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=P,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(void 0===t&&(t={}),!e)return console.warn("Missing analytics screenName"),Promise.resolve();var n=C;return C=e,_({onAndroid:function(n){return n.setScreenNameWithParams?n.setScreenNameWithParams(e,JSON.stringify(P(t))):n.setScreenName&&n.setScreenName(e),Promise.resolve()},onIos:function(n){return n.postMessage({command:"setScreenName",name:e,parameters:P(t)}),Promise.resolve()},onWeb:function(r){return new Promise(function(o){r("event","page_view",m(m({screenName:e,page_title:e,previousScreenName:n},P(t)),{event_callback:I(o)}))})}})},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),_({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]=N(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()?b({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.startProfileImageFlow=function(){return p({type:"START_PROFILE_IMAGE_FLOW"})},e.updateNavigationBar=b,e.updatePhoneNumbers=function(e){return p({type:"UPDATE_PHONE_NUMBERS",payload:{phoneNumbers: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 w(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 b=function(e){return d()?p({type:"NAVIGATION_BAR",payload:e}):(void 0!==e.title&&"undefined"!=typeof document&&(document.title=e.title),Promise.resolve())},T=null,h=function(){if(T)return Promise.resolve(m({},T));var e=new Promise(function(e){setTimeout(function(){e({result:{}})},500)}),t=p({type:"GET_REMOTE_CONFIG"}).then(function(e){return m({},T=e)});return Promise.race([e,t])},E=function(e){return Math.floor(e/1e3)},I=0,S=function(e){var t=setTimeout(function(){e(),I++},500);return function(){clearTimeout(t),I=0,e()}},_=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&&I<3?r(window.gtag):Promise.resolve()},A=function(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"")},N=function(e){return A(e).toLocaleLowerCase().replace(/[^a-zß0-9\s\-\_\/\|\:]/g,"").replace(/\s+/g," ").trim().replace(/\s/g,"_").slice(0,100)},P=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 r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}(e,2),r=n[0],o=n[1],i=o,a=r.slice(0,40);"string"==typeof o&&(i=N(o)),t[a]=i}),t},O={sanitize:!0},C="",M=!1,R=function(e){return g(void 0,void 0,void 0,function(){var t,n,r;return w(this,function(o){switch(o.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),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,p({type:"SHEET",payload:e})];case 2:return n=o.sent(),M=!1,clearTimeout(t),[2,n];case 3:throw r=o.sent(),M=!1,clearTimeout(t),r;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,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=R,e.bottomSheetActionSelector=function(e){var t=e.title,n=e.subtitle,r=e.description,o=e.items;return R({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 g(void 0,void 0,void 0,function(){return w(this,function(e){switch(e.label){case 0:return[4,R({title:t,subtitle:n,description:r,content:[{type:"LIST",id:"list-0",listType:"INFORMATIVE",autoSubmit:!1,selectedIds:[],items:o}]})];case 1:return e.sent(),[2]}})})},e.bottomSheetSingleSelector=function(e){var t=e.title,n=e.subtitle,r=e.description,o=e.selectedId,i=e.items;return R({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:E(t),endTime:E(n),title:r}})},e.dismiss=function(e){return p({type:"DISMISS",payload:{onCompletionUrl:e}})},e.fetch=function(e){var t=e.url,n=e.method,r=e.headers,o=e.body;return d()?p({type:"FETCH",payload:{url:t,method:n,headers:r,body:o}}).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.getAttStatus=function(){return p({type:"GET_ATT_STATUS"}).catch(function(){return null})},e.getCustomerHash=function(){return p({type:"GET_CUSTOMER_HASH"})},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.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=h,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,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 h().then(function(){return function(e){return"true"===T.result[e]}(e)}).catch(function(){return!1})},e.isWebViewBridgeAvailable=d,e.logEcommerceEvent=function(e,t){return t=m(m({},t),{screenName:t.screenName||C}),_({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({},O),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=P(l),s=N(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:A(i),eventValue:a},u),s=e.category}return l=m(m({},l),{screenName:l.screenName||C}),_({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:S(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 _({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:S(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;return d()?p({type:"CONFIRM",payload:{message:t,title:n,acceptText:r,cancelText:o}}).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.type,i=e.withDismiss;return d()?p({type:"MESSAGE",payload:{message:t,duration:n,buttonText:r,type:o,withDismiss:i}}).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){var n=t.accessToken;return e(n)})},e.openOnboarding=function(){return p({type:"OPEN_ONBOARDING"})},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.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=P,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(void 0===t&&(t={}),!e)return console.warn("Missing analytics screenName"),Promise.resolve();var n=C;return C=e,_({onAndroid:function(n){return n.setScreenNameWithParams?n.setScreenNameWithParams(e,JSON.stringify(P(t))):n.setScreenName&&n.setScreenName(e),Promise.resolve()},onIos:function(n){return n.postMessage({command:"setScreenName",name:e,parameters:P(t)}),Promise.resolve()},onWeb:function(r){return new Promise(function(o){r("event","page_view",m(m({screenName:e,page_title:e,previousScreenName:n},P(t)),{event_callback:S(o)}))})}})},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),_({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]=N(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()?b({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.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=b,e.updatePhoneNumbers=function(e){return p({type:"UPDATE_PHONE_NUMBERS",payload:{phoneNumbers:e}})},Object.defineProperty(e,"__esModule",{value:!0}),e}({}); |
@@ -573,2 +573,8 @@ (function (global, factory) { | ||
}; | ||
var triggerPinOrBiometricAuthentication = function (maxSecondsSinceLastValidation) { | ||
return postMessageToNativeApp({ | ||
type: 'TRIGGER_PIN_OR_BIOMETRIC_AUTHENTICATION', | ||
payload: { maxSecondsSinceLastValidation: maxSecondsSinceLastValidation }, | ||
}); | ||
}; | ||
@@ -1161,2 +1167,3 @@ var msToS = function (ms) { return Math.floor(ms / 1000); }; | ||
exports.startProfileImageFlow = startProfileImageFlow; | ||
exports.triggerPinOrBiometricAuthentication = triggerPinOrBiometricAuthentication; | ||
exports.updateNavigationBar = updateNavigationBar; | ||
@@ -1163,0 +1170,0 @@ exports.updatePhoneNumbers = updatePhoneNumbers; |
@@ -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 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 b=function(e){return d()?p({type:"NAVIGATION_BAR",payload:e}):(void 0!==e.title&&"undefined"!=typeof document&&(document.title=e.title),Promise.resolve())},h=null,T=function(){if(h)return Promise.resolve(m({},h));var e=new Promise(function(e){setTimeout(function(){e({result:{}})},500)}),t=p({type:"GET_REMOTE_CONFIG"}).then(function(e){return m({},h=e)});return Promise.race([e,t])},E=function(e){return Math.floor(e/1e3)},S=0,I=function(e){var t=setTimeout(function(){e(),S++},500);return function(){clearTimeout(t),S=0,e()}},_=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-zß0-9\s\-\_\/\|\:]/g,"").replace(/\s+/g," ").trim().replace(/\s/g,"_").slice(0,100)},P=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 g(void 0,void 0,void 0,function(){var t,n,o;return w(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 g(void 0,void 0,void 0,function(){return w(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:E(t),endTime:E(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.getAttStatus=function(){return p({type:"GET_ATT_STATUS"}).catch(function(){return null})},e.getCustomerHash=function(){return p({type:"GET_CUSTOMER_HASH"})},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.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=T,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){return T().then(function(){return function(e){return"true"===h.result[e]}(e)}).catch(function(){return!1})},e.isWebViewBridgeAvailable=d,e.logEcommerceEvent=function(e,t){return t=m(m({},t),{screenName:t.screenName||C}),_({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({},O),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=P(l),s=N(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:A(i),eventValue:a},u),s=e.category}return l=m(m({},l),{screenName:l.screenName||C}),_({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: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 _({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: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,i=e.withDismiss;return d()?p({type:"MESSAGE",payload:{message:t,duration:n,buttonText:o,type:r,withDismiss:i}}).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){var n=t.accessToken;return e(n)})},e.openOnboarding=function(){return p({type:"OPEN_ONBOARDING"})},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=P,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(void 0===t&&(t={}),!e)return console.warn("Missing analytics screenName"),Promise.resolve();var n=C;return C=e,_({onAndroid:function(n){return n.setScreenNameWithParams?n.setScreenNameWithParams(e,JSON.stringify(P(t))):n.setScreenName&&n.setScreenName(e),Promise.resolve()},onIos:function(n){return n.postMessage({command:"setScreenName",name:e,parameters:P(t)}),Promise.resolve()},onWeb:function(o){return new Promise(function(r){o("event","page_view",m(m({screenName:e,page_title:e,previousScreenName:n},P(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),_({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()?b({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.startProfileImageFlow=function(){return p({type:"START_PROFILE_IMAGE_FLOW"})},e.updateNavigationBar=b,e.updatePhoneNumbers=function(e){return p({type:"UPDATE_PHONE_NUMBERS",payload:{phoneNumbers: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 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 b=function(e){return d()?p({type:"NAVIGATION_BAR",payload:e}):(void 0!==e.title&&"undefined"!=typeof document&&(document.title=e.title),Promise.resolve())},T=null,h=function(){if(T)return Promise.resolve(m({},T));var e=new Promise(function(e){setTimeout(function(){e({result:{}})},500)}),t=p({type:"GET_REMOTE_CONFIG"}).then(function(e){return m({},T=e)});return Promise.race([e,t])},E=function(e){return Math.floor(e/1e3)},I=0,S=function(e){var t=setTimeout(function(){e(),I++},500);return function(){clearTimeout(t),I=0,e()}},_=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&&I<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-zß0-9\s\-\_\/\|\:]/g,"").replace(/\s+/g," ").trim().replace(/\s/g,"_").slice(0,100)},P=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 g(void 0,void 0,void 0,function(){var t,n,o;return w(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 g(void 0,void 0,void 0,function(){return w(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:E(t),endTime:E(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.getAttStatus=function(){return p({type:"GET_ATT_STATUS"}).catch(function(){return null})},e.getCustomerHash=function(){return p({type:"GET_CUSTOMER_HASH"})},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.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=h,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){return h().then(function(){return function(e){return"true"===T.result[e]}(e)}).catch(function(){return!1})},e.isWebViewBridgeAvailable=d,e.logEcommerceEvent=function(e,t){return t=m(m({},t),{screenName:t.screenName||C}),_({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({},O),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=P(l),s=N(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:A(i),eventValue:a},u),s=e.category}return l=m(m({},l),{screenName:l.screenName||C}),_({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:S(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 _({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:S(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,i=e.withDismiss;return d()?p({type:"MESSAGE",payload:{message:t,duration:n,buttonText:o,type:r,withDismiss:i}}).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){var n=t.accessToken;return e(n)})},e.openOnboarding=function(){return p({type:"OPEN_ONBOARDING"})},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=P,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(void 0===t&&(t={}),!e)return console.warn("Missing analytics screenName"),Promise.resolve();var n=C;return C=e,_({onAndroid:function(n){return n.setScreenNameWithParams?n.setScreenNameWithParams(e,JSON.stringify(P(t))):n.setScreenName&&n.setScreenName(e),Promise.resolve()},onIos:function(n){return n.postMessage({command:"setScreenName",name:e,parameters:P(t)}),Promise.resolve()},onWeb:function(o){return new Promise(function(r){o("event","page_view",m(m({screenName:e,page_title:e,previousScreenName:n},P(t)),{event_callback:S(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),_({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()?b({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.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=b,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.33.0", | ||
"version": "3.34.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", |
@@ -1088,2 +1088,31 @@ <p align="center"> | ||
### triggerPinOrBiometricAuthentication | ||
<kbd>App version >=24.4</kbd> | ||
Triggers pin/biometric authentication if necessary, taking into account 3 | ||
possible scenarios: | ||
- If user has pin/biometric already configured in the app: | ||
- If last previous authentication (or last pin/biometric setup) is still | ||
valid, nothing will be presented to user and bridge method will succeed. | ||
- Otherwise, authentication will be required, blocking the user until it | ||
is performed. | ||
- In any other case, user will be taken to the pin/biometric screen to enable | ||
any authentication method. In case user leaves the configuration screen | ||
without providing an authentication method, bridge method will fail with 401 | ||
code. | ||
```ts | ||
triggerPinOrBiometricAuthentication: ({ | ||
maxSecondsSinceLastValidation: number | ||
}) => Promise<{ | ||
result: 'USER_AUTHENTICATED' | 'USER_ENABLED_AUTHENTICATION' | 'LAST_AUTHENTICATION_STILL_VALID', | ||
}>; | ||
``` | ||
- `maxSecondsSinceLastValidation`: if time elapsed since last authentication | ||
is less than the number of seconds specified here authentication will | ||
succeed without requesting it again. | ||
## Error handling | ||
@@ -1090,0 +1119,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
314623
6528
1145