Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tef-novum/webview-bridge

Package Overview
Dependencies
Maintainers
2
Versions
123
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tef-novum/webview-bridge - npm Package Compare versions

Comparing version 1.2.1 to 1.3.0

4

CHANGELOG.md
# CHANGELOG
## v.1.2.1 - 2019-02-21
## v.1.3.0 - 2019-02-27
- Fix flow type definition
- Add new Google Analytics custom dimensions

@@ -7,0 +7,0 @@ ## v.1.2.0 - 2019-02-19

@@ -1,2 +0,2 @@

declare type CustomDimensionIdx = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13;
declare type CustomDimensionIdx = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15;
export declare const CD_WEBAPP_INSTALLED: CustomDimensionIdx;

@@ -20,3 +20,3 @@ export declare const CD_NOVUM_UID: CustomDimensionIdx;

export declare const setScreenName: (screenName: string, fieldsObject?: {} | undefined) => Promise<void>;
export declare const setUserProperty: (name: "obIds" | "paymentModels" | "serviceWorkerStatus" | "isAdmin" | "hasIpComms" | "af_source" | "af_campaign" | "novum_uid_session" | "user_logged" | "convergente_uid", value: string) => Promise<void>;
export declare const setUserProperty: (name: "obIds" | "paymentModels" | "serviceWorkerStatus" | "isAdmin" | "hasIpComms" | "af_source" | "af_campaign" | "novum_uid_session" | "user_logged" | "currentSubscriptionId" | "currentSubscriptionType" | "currentPaymentModel", value: string) => Promise<void>;
export {};

@@ -288,3 +288,5 @@ define(['exports'], function (exports) { 'use strict';

var CD_USER_LOGGED = 12;
var CD_CONVERGENTE_UID = 13;
var CD_CURRENT_SUBSCRIPTION_ID = 13;
var CD_CURRENT_SUBSCRIPTION_TYPE = 14;
var CD_CURRENT_PAYMENT_MODEL = 15;
var DEFAULT_EVENT_LABEL = 'null_label';

@@ -442,3 +444,5 @@ var DEFAULT_EVENT_VALUE = 0;

user_logged: CD_USER_LOGGED,
convergente_uid: CD_CONVERGENTE_UID,
currentSubscriptionId: CD_CURRENT_SUBSCRIPTION_ID,
currentSubscriptionType: CD_CURRENT_SUBSCRIPTION_TYPE,
currentPaymentModel: CD_CURRENT_PAYMENT_MODEL,
};

@@ -445,0 +449,0 @@ var setUserProperty = function (name, value) {

@@ -290,3 +290,5 @@ 'use strict';

var CD_USER_LOGGED = 12;
var CD_CONVERGENTE_UID = 13;
var CD_CURRENT_SUBSCRIPTION_ID = 13;
var CD_CURRENT_SUBSCRIPTION_TYPE = 14;
var CD_CURRENT_PAYMENT_MODEL = 15;
var DEFAULT_EVENT_LABEL = 'null_label';

@@ -444,3 +446,5 @@ var DEFAULT_EVENT_VALUE = 0;

user_logged: CD_USER_LOGGED,
convergente_uid: CD_CONVERGENTE_UID,
currentSubscriptionId: CD_CURRENT_SUBSCRIPTION_ID,
currentSubscriptionType: CD_CURRENT_SUBSCRIPTION_TYPE,
currentPaymentModel: CD_CURRENT_PAYMENT_MODEL,
};

@@ -447,0 +451,0 @@ var setUserProperty = function (name, value) {

@@ -289,3 +289,5 @@ var webviewBridge = (function (exports) {

var CD_USER_LOGGED = 12;
var CD_CONVERGENTE_UID = 13;
var CD_CURRENT_SUBSCRIPTION_ID = 13;
var CD_CURRENT_SUBSCRIPTION_TYPE = 14;
var CD_CURRENT_PAYMENT_MODEL = 15;
var DEFAULT_EVENT_LABEL = 'null_label';

@@ -443,3 +445,5 @@ var DEFAULT_EVENT_VALUE = 0;

user_logged: CD_USER_LOGGED,
convergente_uid: CD_CONVERGENTE_UID,
currentSubscriptionId: CD_CURRENT_SUBSCRIPTION_ID,
currentSubscriptionType: CD_CURRENT_SUBSCRIPTION_TYPE,
currentPaymentModel: CD_CURRENT_PAYMENT_MODEL,
};

@@ -446,0 +450,0 @@ var setUserProperty = function (name, value) {

@@ -1,1 +0,1 @@

var webviewBridge=function(e){"use strict";var n=1,t=function(){return""+n++},r="__tuenti_webview_bridge",o=function(){return!(!window.tuentiWebView||!window.tuentiWebView.postMessage)},i=function(){return!!(window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.tuentiWebView&&window.webkit.messageHandlers.tuentiWebView.postMessage)},a=[],s=function(e){a=a.filter(function(n){return n!==e})},u=function(){return o()||i()},c=function(e,n){var r=e.type,u=e.id,c=void 0===u?t():u,l=e.payload,d=o()?function(e){window.tuentiWebView.postMessage(e)}:i()?function(e){window.webkit.messageHandlers.tuentiWebView.postMessage(e)}:null;if(!d)return Promise.reject({code:500,reason:"WebView postMessage not available"});var m=JSON.stringify({type:r,id:c,payload:l});return setTimeout(function(){d(m)}),new Promise(function(e,t){var o=!1,i=function(n){n.id!==c||o||(n.type===r?e(n.payload):"ERROR"===n.type?t(n.payload):t({code:500,reason:"bad type: "+n.type+". Expecting "+r}),s(i))};!function(e){a.push(e)}(i),n&&setTimeout(function(){o=!0,s(i),t({code:408,reason:"request timeout"})},n)})};window[r]=window[r]||{postMessage:function(e){var n;try{n=JSON.parse(e)}catch(n){throw Error("Problem parsing webview message: "+e)}a.forEach(function(e){return e(n)})}};var l=function(e){return Math.floor(e/1e3)},d=function(){return(d=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var o in n=arguments[t])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e}).apply(this,arguments)};var m,f=function(e){var n=e.onAndroid,t=e.onIos,r=e.onWeb;return window.AnalyticsWebInterface?n(window.AnalyticsWebInterface):window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.firebase?t(window.webkit.messageHandlers.firebase):window.ga&&window.ga.loaded?r(window.ga):Promise.resolve()},v={obIds:1,paymentModels:2,serviceWorkerStatus:3,isAdmin:5,hasIpComms:6,af_source:9,af_campaign:10,novum_uid_session:11,user_logged:12,convergente_uid:13};return e.isWebViewBridgeAvailable=u,e.nativeConfirm=function(e){var n=e.message,t=e.title,r=e.acceptText,o=e.cancelText;return u()?c({type:"CONFIRM",payload:{message:n,title:t,acceptText:r,cancelText:o}}).then(function(e){return e.result}):Promise.resolve(window.confirm(n))},e.nativeAlert=function(e){var n=e.message,t=e.title,r=e.buttonText;return u()?c({type:"ALERT",payload:{title:t,message:n,buttonText:r}}):(window.alert(n),Promise.resolve())},e.nativeMessage=function(e){var n=e.message,t=e.duration,r=e.buttonText,o=e.type;return u()?c({type:"MESSAGE",payload:{message:n,duration:t,buttonText:r,type:o}}):(window.alert(n),Promise.resolve())},e.requestSimIcc=function(){return c({type:"SIM_ICC"},200).then(function(e){return e.icc}).catch(function(){return null})},e.requestSimImsi=function(){return c({type:"IMSI"},200).then(function(e){return e.imsi}).catch(function(){return null})},e.requestDeviceImei=function(){return c({type:"IMEI"},200).then(function(e){return e.imei}).catch(function(){return null})},e.attachToEmail=function(e){var n=e.url,t=e.subject,r=e.fileName,o=e.recipient,i=e.body;return c({type:"ATTACH_TO_EMAIL",payload:{url:n,subject:t,fileName:r,recipient:o,body:i}})},e.setWebViewTitle=function(e){return u()?c({type:"SET_TITLE",payload:{title:e}}):(document.title=e,Promise.resolve())},e.updateNavigationBar=function(e){var n=e.visible,t=e.title,r=e.showBackButton,o=e.showReloadButton,i=e.backgroundColor;return u()?c({type:"NAVIGATION_BAR",payload:{visible:n,title:t,showBackButton:r,showReloadButton:o,backgroundColor:i}}):(void 0!==t&&(document.title=t),Promise.resolve())},e.notifyPageLoaded=function(){return c({type:"PAGE_LOADED"})},e.createCalendarEvent=function(e){var n=e.beginTime,t=e.endTime,r=e.title;return c({type:"CREATE_CALENDAR_EVENT",payload:{beginTime:l(n),endTime:l(t),title:r}})},e.requestContact=function(e){var n=(void 0===e?{}:e).filter;return c({type:"GET_CONTACT_DATA",payload:{filter:void 0===n?"phone":n}})},e.logEvent=function(e){var n=e.category,t=e.action,r=e.label,o=e.value,i=function(e,n){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.indexOf(r)<0&&(t[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)n.indexOf(r[o])<0&&(t[r[o]]=e[r[o]])}return t}(e,["category","action","label","value"]);if(!n||!t)return console.warn('Analytics event should have "category" and "action"',{category:n,action:t}),Promise.resolve();var a=n;r||(r="null_label"),o||(o=0);var s=d({eventCategory:n,eventAction:t,eventLabel:r,eventValue:o},i);return f({onAndroid:function(e){return e.logEvent&&e.logEvent(a,JSON.stringify(s)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:a,parameters:s}),Promise.resolve()},onWeb:function(e){return new Promise(function(n){e("send","event",d({},s,{hitCallback:n}))})}})},e.logTiming=function(e){var n=e.category,t=void 0===n?"performance_timer":n,r=e.variable,o=e.value,i=e.label;if(!t||!r||!o)return console.warn('Analytics timing should have "category", "variable" and "value"',{category:t,variable:r,value:o}),Promise.resolve();var a={timingCategory:t,timingVar:r,timingValue:o,timingLabel:i},s=t;return f({onAndroid:function(e){return e.logEvent&&e.logEvent(s,JSON.stringify(a)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:s,parameters:a}),Promise.resolve()},onWeb:function(e){return new Promise(function(n){var t;e("send",d(((t={hitType:"timing",hitCallback:n}).dimension8=String(o),t),a))})}})},e.setScreenName=function(e,n){return e?f({onAndroid:function(n){return n.setScreenName&&n.setScreenName(e),Promise.resolve()},onIos:function(n){return n.postMessage({command:"setScreenName",name:e}),Promise.resolve()},onWeb:function(t){return new Promise(function(r){var o=e.startsWith("/")?e:"/"+e;o!==m?(m=o,t(function(){t.getAll().forEach(function(e){e.set("page",o),e.send("pageView",d({},n,{hitCallback:r}))})})):r()})}}):(console.warn("Missing analytics screenName"),Promise.resolve())},e.setUserProperty=function(e,n){return e&&n?(n=String(n),f({onAndroid:function(t){return t.setUserProperty&&t.setUserProperty(e,n),Promise.resolve()},onIos:function(t){return t.postMessage({command:"setUserProperty",name:e,value:n}),Promise.resolve()},onWeb:function(t){var r,o=v[e];return o?(t("set",((r={})["dimension"+o]=String(n),r)),Promise.resolve()):(console.warn("No custom dimension defined for user property",e),Promise.resolve())}})):(console.warn("Trying to set analytics user property without name or value",e,n),Promise.resolve())},e.CD_WEBAPP_INSTALLED=4,e.CD_NOVUM_UID=7,e.CD_EVENT_VALUE=8,e}({});
var webviewBridge=function(e){"use strict";var n=1,t=function(){return""+n++},r="__tuenti_webview_bridge",o=function(){return!(!window.tuentiWebView||!window.tuentiWebView.postMessage)},i=function(){return!!(window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.tuentiWebView&&window.webkit.messageHandlers.tuentiWebView.postMessage)},a=[],s=function(e){a=a.filter(function(n){return n!==e})},u=function(){return o()||i()},c=function(e,n){var r=e.type,u=e.id,c=void 0===u?t():u,l=e.payload,d=o()?function(e){window.tuentiWebView.postMessage(e)}:i()?function(e){window.webkit.messageHandlers.tuentiWebView.postMessage(e)}:null;if(!d)return Promise.reject({code:500,reason:"WebView postMessage not available"});var m=JSON.stringify({type:r,id:c,payload:l});return setTimeout(function(){d(m)}),new Promise(function(e,t){var o=!1,i=function(n){n.id!==c||o||(n.type===r?e(n.payload):"ERROR"===n.type?t(n.payload):t({code:500,reason:"bad type: "+n.type+". Expecting "+r}),s(i))};!function(e){a.push(e)}(i),n&&setTimeout(function(){o=!0,s(i),t({code:408,reason:"request timeout"})},n)})};window[r]=window[r]||{postMessage:function(e){var n;try{n=JSON.parse(e)}catch(n){throw Error("Problem parsing webview message: "+e)}a.forEach(function(e){return e(n)})}};var l=function(e){return Math.floor(e/1e3)},d=function(){return(d=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var o in n=arguments[t])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e}).apply(this,arguments)};var m,f=function(e){var n=e.onAndroid,t=e.onIos,r=e.onWeb;return window.AnalyticsWebInterface?n(window.AnalyticsWebInterface):window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.firebase?t(window.webkit.messageHandlers.firebase):window.ga&&window.ga.loaded?r(window.ga):Promise.resolve()},v={obIds:1,paymentModels:2,serviceWorkerStatus:3,isAdmin:5,hasIpComms:6,af_source:9,af_campaign:10,novum_uid_session:11,user_logged:12,currentSubscriptionId:13,currentSubscriptionType:14,currentPaymentModel:15};return e.isWebViewBridgeAvailable=u,e.nativeConfirm=function(e){var n=e.message,t=e.title,r=e.acceptText,o=e.cancelText;return u()?c({type:"CONFIRM",payload:{message:n,title:t,acceptText:r,cancelText:o}}).then(function(e){return e.result}):Promise.resolve(window.confirm(n))},e.nativeAlert=function(e){var n=e.message,t=e.title,r=e.buttonText;return u()?c({type:"ALERT",payload:{title:t,message:n,buttonText:r}}):(window.alert(n),Promise.resolve())},e.nativeMessage=function(e){var n=e.message,t=e.duration,r=e.buttonText,o=e.type;return u()?c({type:"MESSAGE",payload:{message:n,duration:t,buttonText:r,type:o}}):(window.alert(n),Promise.resolve())},e.requestSimIcc=function(){return c({type:"SIM_ICC"},200).then(function(e){return e.icc}).catch(function(){return null})},e.requestSimImsi=function(){return c({type:"IMSI"},200).then(function(e){return e.imsi}).catch(function(){return null})},e.requestDeviceImei=function(){return c({type:"IMEI"},200).then(function(e){return e.imei}).catch(function(){return null})},e.attachToEmail=function(e){var n=e.url,t=e.subject,r=e.fileName,o=e.recipient,i=e.body;return c({type:"ATTACH_TO_EMAIL",payload:{url:n,subject:t,fileName:r,recipient:o,body:i}})},e.setWebViewTitle=function(e){return u()?c({type:"SET_TITLE",payload:{title:e}}):(document.title=e,Promise.resolve())},e.updateNavigationBar=function(e){var n=e.visible,t=e.title,r=e.showBackButton,o=e.showReloadButton,i=e.backgroundColor;return u()?c({type:"NAVIGATION_BAR",payload:{visible:n,title:t,showBackButton:r,showReloadButton:o,backgroundColor:i}}):(void 0!==t&&(document.title=t),Promise.resolve())},e.notifyPageLoaded=function(){return c({type:"PAGE_LOADED"})},e.createCalendarEvent=function(e){var n=e.beginTime,t=e.endTime,r=e.title;return c({type:"CREATE_CALENDAR_EVENT",payload:{beginTime:l(n),endTime:l(t),title:r}})},e.requestContact=function(e){var n=(void 0===e?{}:e).filter;return c({type:"GET_CONTACT_DATA",payload:{filter:void 0===n?"phone":n}})},e.logEvent=function(e){var n=e.category,t=e.action,r=e.label,o=e.value,i=function(e,n){var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.indexOf(r)<0&&(t[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)n.indexOf(r[o])<0&&(t[r[o]]=e[r[o]])}return t}(e,["category","action","label","value"]);if(!n||!t)return console.warn('Analytics event should have "category" and "action"',{category:n,action:t}),Promise.resolve();var a=n;r||(r="null_label"),o||(o=0);var s=d({eventCategory:n,eventAction:t,eventLabel:r,eventValue:o},i);return f({onAndroid:function(e){return e.logEvent&&e.logEvent(a,JSON.stringify(s)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:a,parameters:s}),Promise.resolve()},onWeb:function(e){return new Promise(function(n){e("send","event",d({},s,{hitCallback:n}))})}})},e.logTiming=function(e){var n=e.category,t=void 0===n?"performance_timer":n,r=e.variable,o=e.value,i=e.label;if(!t||!r||!o)return console.warn('Analytics timing should have "category", "variable" and "value"',{category:t,variable:r,value:o}),Promise.resolve();var a={timingCategory:t,timingVar:r,timingValue:o,timingLabel:i},s=t;return f({onAndroid:function(e){return e.logEvent&&e.logEvent(s,JSON.stringify(a)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:s,parameters:a}),Promise.resolve()},onWeb:function(e){return new Promise(function(n){var t;e("send",d(((t={hitType:"timing",hitCallback:n}).dimension8=String(o),t),a))})}})},e.setScreenName=function(e,n){return e?f({onAndroid:function(n){return n.setScreenName&&n.setScreenName(e),Promise.resolve()},onIos:function(n){return n.postMessage({command:"setScreenName",name:e}),Promise.resolve()},onWeb:function(t){return new Promise(function(r){var o=e.startsWith("/")?e:"/"+e;o!==m?(m=o,t(function(){t.getAll().forEach(function(e){e.set("page",o),e.send("pageView",d({},n,{hitCallback:r}))})})):r()})}}):(console.warn("Missing analytics screenName"),Promise.resolve())},e.setUserProperty=function(e,n){return e&&n?(n=String(n),f({onAndroid:function(t){return t.setUserProperty&&t.setUserProperty(e,n),Promise.resolve()},onIos:function(t){return t.postMessage({command:"setUserProperty",name:e,value:n}),Promise.resolve()},onWeb:function(t){var r,o=v[e];return o?(t("set",((r={})["dimension"+o]=String(n),r)),Promise.resolve()):(console.warn("No custom dimension defined for user property",e),Promise.resolve())}})):(console.warn("Trying to set analytics user property without name or value",e,n),Promise.resolve())},e.CD_WEBAPP_INSTALLED=4,e.CD_NOVUM_UID=7,e.CD_EVENT_VALUE=8,e}({});

@@ -292,3 +292,5 @@ (function (global, factory) {

var CD_USER_LOGGED = 12;
var CD_CONVERGENTE_UID = 13;
var CD_CURRENT_SUBSCRIPTION_ID = 13;
var CD_CURRENT_SUBSCRIPTION_TYPE = 14;
var CD_CURRENT_PAYMENT_MODEL = 15;
var DEFAULT_EVENT_LABEL = 'null_label';

@@ -446,3 +448,5 @@ var DEFAULT_EVENT_VALUE = 0;

user_logged: CD_USER_LOGGED,
convergente_uid: CD_CONVERGENTE_UID,
currentSubscriptionId: CD_CURRENT_SUBSCRIPTION_ID,
currentSubscriptionType: CD_CURRENT_SUBSCRIPTION_TYPE,
currentPaymentModel: CD_CURRENT_PAYMENT_MODEL,
};

@@ -449,0 +453,0 @@ var setUserProperty = function (name, value) {

@@ -1,1 +0,1 @@

!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e=e||self).webviewBridge={})}(this,function(e){"use strict";var n=1,t=function(){return""+n++},o="__tuenti_webview_bridge",r=function(){return!(!window.tuentiWebView||!window.tuentiWebView.postMessage)},i=function(){return!!(window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.tuentiWebView&&window.webkit.messageHandlers.tuentiWebView.postMessage)},a=[],s=function(e){a=a.filter(function(n){return n!==e})},u=function(){return r()||i()},c=function(e,n){var o=e.type,u=e.id,c=void 0===u?t():u,l=e.payload,d=r()?function(e){window.tuentiWebView.postMessage(e)}:i()?function(e){window.webkit.messageHandlers.tuentiWebView.postMessage(e)}:null;if(!d)return Promise.reject({code:500,reason:"WebView postMessage not available"});var f=JSON.stringify({type:o,id:c,payload:l});return setTimeout(function(){d(f)}),new Promise(function(e,t){var r=!1,i=function(n){n.id!==c||r||(n.type===o?e(n.payload):"ERROR"===n.type?t(n.payload):t({code:500,reason:"bad type: "+n.type+". Expecting "+o}),s(i))};!function(e){a.push(e)}(i),n&&setTimeout(function(){r=!0,s(i),t({code:408,reason:"request timeout"})},n)})};window[o]=window[o]||{postMessage:function(e){var n;try{n=JSON.parse(e)}catch(n){throw Error("Problem parsing webview message: "+e)}a.forEach(function(e){return e(n)})}};var l=function(e){return Math.floor(e/1e3)},d=function(){return(d=Object.assign||function(e){for(var n,t=1,o=arguments.length;t<o;t++)for(var r in n=arguments[t])Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e}).apply(this,arguments)};var f,m=function(e){var n=e.onAndroid,t=e.onIos,o=e.onWeb;return window.AnalyticsWebInterface?n(window.AnalyticsWebInterface):window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.firebase?t(window.webkit.messageHandlers.firebase):window.ga&&window.ga.loaded?o(window.ga):Promise.resolve()},v={obIds:1,paymentModels:2,serviceWorkerStatus:3,isAdmin:5,hasIpComms:6,af_source:9,af_campaign:10,novum_uid_session:11,user_logged:12,convergente_uid:13};e.isWebViewBridgeAvailable=u,e.nativeConfirm=function(e){var n=e.message,t=e.title,o=e.acceptText,r=e.cancelText;return u()?c({type:"CONFIRM",payload:{message:n,title:t,acceptText:o,cancelText:r}}).then(function(e){return e.result}):Promise.resolve(window.confirm(n))},e.nativeAlert=function(e){var n=e.message,t=e.title,o=e.buttonText;return u()?c({type:"ALERT",payload:{title:t,message:n,buttonText:o}}):(window.alert(n),Promise.resolve())},e.nativeMessage=function(e){var n=e.message,t=e.duration,o=e.buttonText,r=e.type;return u()?c({type:"MESSAGE",payload:{message:n,duration:t,buttonText:o,type:r}}):(window.alert(n),Promise.resolve())},e.requestSimIcc=function(){return c({type:"SIM_ICC"},200).then(function(e){return e.icc}).catch(function(){return null})},e.requestSimImsi=function(){return c({type:"IMSI"},200).then(function(e){return e.imsi}).catch(function(){return null})},e.requestDeviceImei=function(){return c({type:"IMEI"},200).then(function(e){return e.imei}).catch(function(){return null})},e.attachToEmail=function(e){var n=e.url,t=e.subject,o=e.fileName,r=e.recipient,i=e.body;return c({type:"ATTACH_TO_EMAIL",payload:{url:n,subject:t,fileName:o,recipient:r,body:i}})},e.setWebViewTitle=function(e){return u()?c({type:"SET_TITLE",payload:{title:e}}):(document.title=e,Promise.resolve())},e.updateNavigationBar=function(e){var n=e.visible,t=e.title,o=e.showBackButton,r=e.showReloadButton,i=e.backgroundColor;return u()?c({type:"NAVIGATION_BAR",payload:{visible:n,title:t,showBackButton:o,showReloadButton:r,backgroundColor:i}}):(void 0!==t&&(document.title=t),Promise.resolve())},e.notifyPageLoaded=function(){return c({type:"PAGE_LOADED"})},e.createCalendarEvent=function(e){var n=e.beginTime,t=e.endTime,o=e.title;return c({type:"CREATE_CALENDAR_EVENT",payload:{beginTime:l(n),endTime:l(t),title:o}})},e.requestContact=function(e){var n=(void 0===e?{}:e).filter;return c({type:"GET_CONTACT_DATA",payload:{filter:void 0===n?"phone":n}})},e.logEvent=function(e){var n=e.category,t=e.action,o=e.label,r=e.value,i=function(e,n){var t={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&n.indexOf(o)<0&&(t[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)n.indexOf(o[r])<0&&(t[o[r]]=e[o[r]])}return t}(e,["category","action","label","value"]);if(!n||!t)return console.warn('Analytics event should have "category" and "action"',{category:n,action:t}),Promise.resolve();var a=n;o||(o="null_label"),r||(r=0);var s=d({eventCategory:n,eventAction:t,eventLabel:o,eventValue:r},i);return m({onAndroid:function(e){return e.logEvent&&e.logEvent(a,JSON.stringify(s)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:a,parameters:s}),Promise.resolve()},onWeb:function(e){return new Promise(function(n){e("send","event",d({},s,{hitCallback:n}))})}})},e.logTiming=function(e){var n=e.category,t=void 0===n?"performance_timer":n,o=e.variable,r=e.value,i=e.label;if(!t||!o||!r)return console.warn('Analytics timing should have "category", "variable" and "value"',{category:t,variable:o,value:r}),Promise.resolve();var a={timingCategory:t,timingVar:o,timingValue:r,timingLabel:i},s=t;return m({onAndroid:function(e){return e.logEvent&&e.logEvent(s,JSON.stringify(a)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:s,parameters:a}),Promise.resolve()},onWeb:function(e){return new Promise(function(n){var t;e("send",d(((t={hitType:"timing",hitCallback:n}).dimension8=String(r),t),a))})}})},e.setScreenName=function(e,n){return e?m({onAndroid:function(n){return n.setScreenName&&n.setScreenName(e),Promise.resolve()},onIos:function(n){return n.postMessage({command:"setScreenName",name:e}),Promise.resolve()},onWeb:function(t){return new Promise(function(o){var r=e.startsWith("/")?e:"/"+e;r!==f?(f=r,t(function(){t.getAll().forEach(function(e){e.set("page",r),e.send("pageView",d({},n,{hitCallback:o}))})})):o()})}}):(console.warn("Missing analytics screenName"),Promise.resolve())},e.setUserProperty=function(e,n){return e&&n?(n=String(n),m({onAndroid:function(t){return t.setUserProperty&&t.setUserProperty(e,n),Promise.resolve()},onIos:function(t){return t.postMessage({command:"setUserProperty",name:e,value:n}),Promise.resolve()},onWeb:function(t){var o,r=v[e];return r?(t("set",((o={})["dimension"+r]=String(n),o)),Promise.resolve()):(console.warn("No custom dimension defined for user property",e),Promise.resolve())}})):(console.warn("Trying to set analytics user property without name or value",e,n),Promise.resolve())},e.CD_WEBAPP_INSTALLED=4,e.CD_NOVUM_UID=7,e.CD_EVENT_VALUE=8,Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e=e||self).webviewBridge={})}(this,function(e){"use strict";var n=1,t=function(){return""+n++},o="__tuenti_webview_bridge",r=function(){return!(!window.tuentiWebView||!window.tuentiWebView.postMessage)},i=function(){return!!(window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.tuentiWebView&&window.webkit.messageHandlers.tuentiWebView.postMessage)},a=[],s=function(e){a=a.filter(function(n){return n!==e})},u=function(){return r()||i()},c=function(e,n){var o=e.type,u=e.id,c=void 0===u?t():u,l=e.payload,d=r()?function(e){window.tuentiWebView.postMessage(e)}:i()?function(e){window.webkit.messageHandlers.tuentiWebView.postMessage(e)}:null;if(!d)return Promise.reject({code:500,reason:"WebView postMessage not available"});var f=JSON.stringify({type:o,id:c,payload:l});return setTimeout(function(){d(f)}),new Promise(function(e,t){var r=!1,i=function(n){n.id!==c||r||(n.type===o?e(n.payload):"ERROR"===n.type?t(n.payload):t({code:500,reason:"bad type: "+n.type+". Expecting "+o}),s(i))};!function(e){a.push(e)}(i),n&&setTimeout(function(){r=!0,s(i),t({code:408,reason:"request timeout"})},n)})};window[o]=window[o]||{postMessage:function(e){var n;try{n=JSON.parse(e)}catch(n){throw Error("Problem parsing webview message: "+e)}a.forEach(function(e){return e(n)})}};var l=function(e){return Math.floor(e/1e3)},d=function(){return(d=Object.assign||function(e){for(var n,t=1,o=arguments.length;t<o;t++)for(var r in n=arguments[t])Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e}).apply(this,arguments)};var f,m=function(e){var n=e.onAndroid,t=e.onIos,o=e.onWeb;return window.AnalyticsWebInterface?n(window.AnalyticsWebInterface):window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.firebase?t(window.webkit.messageHandlers.firebase):window.ga&&window.ga.loaded?o(window.ga):Promise.resolve()},v={obIds:1,paymentModels:2,serviceWorkerStatus:3,isAdmin:5,hasIpComms:6,af_source:9,af_campaign:10,novum_uid_session:11,user_logged:12,currentSubscriptionId:13,currentSubscriptionType:14,currentPaymentModel:15};e.isWebViewBridgeAvailable=u,e.nativeConfirm=function(e){var n=e.message,t=e.title,o=e.acceptText,r=e.cancelText;return u()?c({type:"CONFIRM",payload:{message:n,title:t,acceptText:o,cancelText:r}}).then(function(e){return e.result}):Promise.resolve(window.confirm(n))},e.nativeAlert=function(e){var n=e.message,t=e.title,o=e.buttonText;return u()?c({type:"ALERT",payload:{title:t,message:n,buttonText:o}}):(window.alert(n),Promise.resolve())},e.nativeMessage=function(e){var n=e.message,t=e.duration,o=e.buttonText,r=e.type;return u()?c({type:"MESSAGE",payload:{message:n,duration:t,buttonText:o,type:r}}):(window.alert(n),Promise.resolve())},e.requestSimIcc=function(){return c({type:"SIM_ICC"},200).then(function(e){return e.icc}).catch(function(){return null})},e.requestSimImsi=function(){return c({type:"IMSI"},200).then(function(e){return e.imsi}).catch(function(){return null})},e.requestDeviceImei=function(){return c({type:"IMEI"},200).then(function(e){return e.imei}).catch(function(){return null})},e.attachToEmail=function(e){var n=e.url,t=e.subject,o=e.fileName,r=e.recipient,i=e.body;return c({type:"ATTACH_TO_EMAIL",payload:{url:n,subject:t,fileName:o,recipient:r,body:i}})},e.setWebViewTitle=function(e){return u()?c({type:"SET_TITLE",payload:{title:e}}):(document.title=e,Promise.resolve())},e.updateNavigationBar=function(e){var n=e.visible,t=e.title,o=e.showBackButton,r=e.showReloadButton,i=e.backgroundColor;return u()?c({type:"NAVIGATION_BAR",payload:{visible:n,title:t,showBackButton:o,showReloadButton:r,backgroundColor:i}}):(void 0!==t&&(document.title=t),Promise.resolve())},e.notifyPageLoaded=function(){return c({type:"PAGE_LOADED"})},e.createCalendarEvent=function(e){var n=e.beginTime,t=e.endTime,o=e.title;return c({type:"CREATE_CALENDAR_EVENT",payload:{beginTime:l(n),endTime:l(t),title:o}})},e.requestContact=function(e){var n=(void 0===e?{}:e).filter;return c({type:"GET_CONTACT_DATA",payload:{filter:void 0===n?"phone":n}})},e.logEvent=function(e){var n=e.category,t=e.action,o=e.label,r=e.value,i=function(e,n){var t={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&n.indexOf(o)<0&&(t[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)n.indexOf(o[r])<0&&(t[o[r]]=e[o[r]])}return t}(e,["category","action","label","value"]);if(!n||!t)return console.warn('Analytics event should have "category" and "action"',{category:n,action:t}),Promise.resolve();var a=n;o||(o="null_label"),r||(r=0);var s=d({eventCategory:n,eventAction:t,eventLabel:o,eventValue:r},i);return m({onAndroid:function(e){return e.logEvent&&e.logEvent(a,JSON.stringify(s)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:a,parameters:s}),Promise.resolve()},onWeb:function(e){return new Promise(function(n){e("send","event",d({},s,{hitCallback:n}))})}})},e.logTiming=function(e){var n=e.category,t=void 0===n?"performance_timer":n,o=e.variable,r=e.value,i=e.label;if(!t||!o||!r)return console.warn('Analytics timing should have "category", "variable" and "value"',{category:t,variable:o,value:r}),Promise.resolve();var a={timingCategory:t,timingVar:o,timingValue:r,timingLabel:i},s=t;return m({onAndroid:function(e){return e.logEvent&&e.logEvent(s,JSON.stringify(a)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:s,parameters:a}),Promise.resolve()},onWeb:function(e){return new Promise(function(n){var t;e("send",d(((t={hitType:"timing",hitCallback:n}).dimension8=String(r),t),a))})}})},e.setScreenName=function(e,n){return e?m({onAndroid:function(n){return n.setScreenName&&n.setScreenName(e),Promise.resolve()},onIos:function(n){return n.postMessage({command:"setScreenName",name:e}),Promise.resolve()},onWeb:function(t){return new Promise(function(o){var r=e.startsWith("/")?e:"/"+e;r!==f?(f=r,t(function(){t.getAll().forEach(function(e){e.set("page",r),e.send("pageView",d({},n,{hitCallback:o}))})})):o()})}}):(console.warn("Missing analytics screenName"),Promise.resolve())},e.setUserProperty=function(e,n){return e&&n?(n=String(n),m({onAndroid:function(t){return t.setUserProperty&&t.setUserProperty(e,n),Promise.resolve()},onIos:function(t){return t.postMessage({command:"setUserProperty",name:e,value:n}),Promise.resolve()},onWeb:function(t){var o,r=v[e];return r?(t("set",((o={})["dimension"+r]=String(n),o)),Promise.resolve()):(console.warn("No custom dimension defined for user property",e),Promise.resolve())}})):(console.warn("Trying to set analytics user property without name or value",e,n),Promise.resolve())},e.CD_WEBAPP_INSTALLED=4,e.CD_NOVUM_UID=7,e.CD_EVENT_VALUE=8,Object.defineProperty(e,"__esModule",{value:!0})});
{
"name": "@tef-novum/webview-bridge",
"version": "1.2.1",
"version": "1.3.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",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc