@tef-novum/webview-bridge
Advanced tools
Comparing version 3.41.0 to 3.43.0
@@ -8,3 +8,3 @@ export { isWebViewBridgeAvailable, onNativeEvent, NativeEventHandler, setLogger, } from './src/post-message'; | ||
requestSimImsi, requestDeviceImei, internalNavigation, dismiss, requestVibration, getDiskSpaceInfo, getEsimInfo, getAttStatus, getDeviceModel, getDeviceTac, shareBase64, downloadBase64, getBatteryInfo, } from './src/device'; | ||
export { attachToEmail, share, setWebViewTitle, updateNavigationBar, notifyPageLoaded, notifyBridgeReady, getRemoteConfig, isABTestingAvailable, reportStatus, fetch, checkPermissionStatus, getAppMetadata, getNetworkConnectionInfo, setActionBehavior, getTopazToken, getTopazValues, getPincodeInfo, onNavigationBarIconClicked, triggerPinOrBiometricAuthentication, focusNavbar, } from './src/utils'; | ||
export { attachToEmail, share, setWebViewTitle, updateNavigationBar, notifyPageLoaded, notifyBridgeReady, getRemoteConfig, isABTestingAvailable, reportStatus, fetch, checkPermissionStatus, getAppMetadata, getNetworkConnectionInfo, setActionBehavior, getTopazToken, getTopazValues, getPincodeInfo, onNavigationBarIconClicked, triggerPinOrBiometricAuthentication, focusNavbar, showLoadingOverlay, hideLoadingOverlay, } from './src/utils'; | ||
export type { ShareOptions, NavigationBarIcon } from './src/utils'; | ||
@@ -11,0 +11,0 @@ export { createCalendarEvent } from './src/calendar'; |
@@ -0,2 +1,12 @@ | ||
/** | ||
* These functions try to use the Web Clipboard API if available, otherwise fall back to the bridge | ||
* implementation in native apps. | ||
* | ||
* According to the tests done, the Web Clipboard API works fine in iOS webviews but fails with a permissions | ||
* error in Android in some cases. Also, old versions of Chrome in Android may not have support for the Web | ||
* Clipboard API at all. | ||
* | ||
* We have decided to not implement the bridge method in iOS apps, as the Web Clipboard API works fine. | ||
*/ | ||
export declare const readTextFromClipboard: () => Promise<string>; | ||
export declare const writeTextToClipboard: (text: string) => Promise<void>; |
@@ -387,2 +387,12 @@ /** | ||
}; | ||
SHOW_LOADING_OVERLAY: { | ||
type: 'SHOW_LOADING_OVERLAY'; | ||
id: string; | ||
payload: void; | ||
}; | ||
HIDE_LOADING_OVERLAY: { | ||
type: 'HIDE_LOADING_OVERLAY'; | ||
id: string; | ||
payload: void; | ||
}; | ||
}; | ||
@@ -389,0 +399,0 @@ export declare type NativeAppResponsePayload<Type extends keyof ResponsesFromNativeApp> = ResponsesFromNativeApp[Type]['payload']; |
@@ -166,2 +166,41 @@ import { NativeAppResponsePayload } from './post-message'; | ||
}>; | ||
export declare const showLoadingOverlay: (payload: { | ||
/** | ||
* Whether the in animation is enabled (false by default) | ||
*/ | ||
inAnimation?: boolean; | ||
/** | ||
* Whether the out animation is enabled (false by default) | ||
*/ | ||
outAnimation?: boolean; | ||
/** | ||
* Minimum duration of the loop animation in milliseconds (0 by default) | ||
*/ | ||
minimumLoopDurationMs?: number; | ||
/** | ||
* whether the loop animation should be stopped immediately or not (true by default) | ||
*/ | ||
stopAnimationCycle?: boolean; | ||
/** | ||
* Whether the background animation is enabled (false by default) | ||
*/ | ||
backgroundAnimation?: boolean; | ||
/** | ||
* List of description texts to be shown one after the other | ||
*/ | ||
descriptions?: Array<string>; | ||
/** | ||
* Duration of each description in milliseconds (3000 by default) | ||
*/ | ||
descriptionDurationMs?: number; | ||
/** | ||
* After this timeout loading screen would be hidden automatically (20000 by default) | ||
*/ | ||
timeoutMs?: number; | ||
/** | ||
* (Only Android) If true, after loading screen has been hidden, if user presses android back button, webview window will close (true by default) | ||
*/ | ||
closeOnBackButtonPressAfterFinish?: boolean; | ||
}) => Promise<void>; | ||
export declare const hideLoadingOverlay: () => Promise<void>; | ||
export {}; |
@@ -247,6 +247,3 @@ define(['exports'], (function (exports) { 'use strict'; | ||
return postMessageToNativeApp({ type: 'SIM_ICC' }, TIMEOUT) | ||
.then(function (_a) { | ||
var icc = _a.icc; | ||
return icc; | ||
}) | ||
.then(function (response) { return response.icc; }) | ||
.catch(function () { return null; }); | ||
@@ -257,6 +254,3 @@ }; | ||
return postMessageToNativeApp({ type: 'IMSI' }, TIMEOUT) | ||
.then(function (_a) { | ||
var imsi = _a.imsi; | ||
return imsi; | ||
}) | ||
.then(function (response) { return response.imsi; }) | ||
.catch(function () { return null; }); | ||
@@ -266,6 +260,3 @@ }; | ||
return postMessageToNativeApp({ type: 'IMEI' }, TIMEOUT) | ||
.then(function (_a) { | ||
var imei = _a.imei; | ||
return imei; | ||
}) | ||
.then(function (response) { return response.imei; }) | ||
.catch(function () { return null; }); | ||
@@ -383,57 +374,2 @@ }; | ||
function __awaiter(thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
} | ||
function __generator(thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
} | ||
function __read(o, n) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator]; | ||
if (!m) return o; | ||
var i = m.call(o), r, ar = [], e; | ||
try { | ||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); | ||
} | ||
catch (error) { e = { error: error }; } | ||
finally { | ||
try { | ||
if (r && !r.done && (m = i["return"])) m.call(i); | ||
} | ||
finally { if (e) throw e.error; } | ||
} | ||
return ar; | ||
} | ||
var attachToEmail = function (_a) { | ||
@@ -533,17 +469,10 @@ var url = _a.url, subject = _a.subject, fileName = _a.fileName, recipient = _a.recipient, body = _a.body; | ||
var url = _a.url, method = _a.method, headers = _a.headers, body = _a.body; | ||
if (isWebViewBridgeAvailable()) { | ||
return postMessageToNativeApp({ | ||
type: 'FETCH', | ||
payload: { url: url, method: method, headers: headers, body: body }, | ||
}).catch(function () { return ({ | ||
status: 500, | ||
headers: {}, | ||
body: 'Bridge call failed', | ||
}); }); | ||
} | ||
return Promise.resolve({ | ||
return postMessageToNativeApp({ | ||
type: 'FETCH', | ||
payload: { url: url, method: method, headers: headers, body: body }, | ||
}).catch(function () { return ({ | ||
status: 500, | ||
headers: {}, | ||
body: 'Bridge not available', | ||
}); | ||
body: 'Bridge call failed', | ||
}); }); | ||
}; | ||
@@ -615,2 +544,8 @@ var checkPermissionStatus = function (feature, params) { | ||
}; | ||
var showLoadingOverlay = function (payload) { | ||
return postMessageToNativeApp({ type: 'SHOW_LOADING_OVERLAY', payload: payload }); | ||
}; | ||
var hideLoadingOverlay = function () { | ||
return postMessageToNativeApp({ type: 'HIDE_LOADING_OVERLAY' }); | ||
}; | ||
@@ -735,4 +670,5 @@ var msToS = function (ms) { return Math.floor(ms / 1000); }; | ||
var sanitizedParams = {}; | ||
Object.entries(params).forEach(function (_a) { | ||
var _b = __read(_a, 2), key = _b[0], value = _b[1]; | ||
Object.entries(params).forEach(function (entry) { | ||
var key = entry[0]; | ||
var value = entry[1]; | ||
var sanitizedValue = value; | ||
@@ -955,6 +891,3 @@ var sanitizedKey = key.slice(0, EVENT_PARAM_NAME_CHARS_LIMIT); | ||
payload: { accessToken: oldAccessToken || null }, | ||
}, options.timeout).then(function (_a) { | ||
var accessToken = _a.accessToken; | ||
return accessToken; | ||
}); | ||
}, options.timeout).then(function (result) { return result.accessToken; }); | ||
}; | ||
@@ -967,5 +900,4 @@ /** | ||
var onSessionRenewed = function (handler) { | ||
return listenToNativeMessage('SESSION_RENEWED', function (_a) { | ||
var accessToken = _a.accessToken; | ||
return handler(accessToken); | ||
return listenToNativeMessage('SESSION_RENEWED', function (result) { | ||
return handler(result.accessToken); | ||
}); | ||
@@ -988,35 +920,25 @@ }; | ||
var sheetLock = false; | ||
var bottomSheet = function (payload) { return __awaiter(void 0, void 0, void 0, function () { | ||
var tid, response, e_1; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (sheetLock) { | ||
throw { | ||
code: 423, | ||
reason: 'BottomSheet is locked. You can only have one bottom sheet in the screen', | ||
}; | ||
} | ||
sheetLock = true; | ||
tid = setTimeout(function () { | ||
sheetLock = false; | ||
}, 1000); | ||
_a.label = 1; | ||
case 1: | ||
_a.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, postMessageToNativeApp({ type: 'SHEET', payload: payload })]; | ||
case 2: | ||
response = _a.sent(); | ||
sheetLock = false; | ||
clearTimeout(tid); | ||
return [2 /*return*/, response]; | ||
case 3: | ||
e_1 = _a.sent(); | ||
sheetLock = false; | ||
clearTimeout(tid); | ||
throw e_1; | ||
case 4: return [2 /*return*/]; | ||
} | ||
var bottomSheet = function (payload) { | ||
if (sheetLock) { | ||
return Promise.reject({ | ||
code: 423, | ||
reason: 'BottomSheet is locked. You can only have one bottom sheet in the screen', | ||
}); | ||
} | ||
sheetLock = true; | ||
var tid = setTimeout(function () { | ||
sheetLock = false; | ||
}, 1000); | ||
return postMessageToNativeApp({ type: 'SHEET', payload: payload }) | ||
.then(function (response) { | ||
sheetLock = false; | ||
clearTimeout(tid); | ||
return response; | ||
}) | ||
.catch(function (e) { | ||
sheetLock = false; | ||
clearTimeout(tid); | ||
throw e; | ||
}); | ||
}); }; | ||
}; | ||
var bottomSheetSingleSelector = function (_a) { | ||
@@ -1088,26 +1010,17 @@ var title = _a.title, subtitle = _a.subtitle, description = _a.description, selectedId = _a.selectedId, items = _a.items; | ||
var title = _a.title, subtitle = _a.subtitle, description = _a.description, items = _a.items; | ||
return __awaiter(void 0, void 0, void 0, function () { | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: return [4 /*yield*/, bottomSheet({ | ||
title: title, | ||
subtitle: subtitle, | ||
description: description, | ||
content: [ | ||
{ | ||
type: 'LIST', | ||
id: 'list-0', | ||
listType: 'INFORMATIVE', | ||
autoSubmit: false, | ||
selectedIds: [], | ||
items: items, | ||
}, | ||
], | ||
})]; | ||
case 1: | ||
_b.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
return bottomSheet({ | ||
title: title, | ||
subtitle: subtitle, | ||
description: description, | ||
content: [ | ||
{ | ||
type: 'LIST', | ||
id: 'list-0', | ||
listType: 'INFORMATIVE', | ||
autoSubmit: false, | ||
selectedIds: [], | ||
items: items, | ||
}, | ||
], | ||
}).then(function () { return undefined; }); | ||
}; | ||
@@ -1133,7 +1046,28 @@ | ||
/** | ||
* These functions try to use the Web Clipboard API if available, otherwise fall back to the bridge | ||
* implementation in native apps. | ||
* | ||
* According to the tests done, the Web Clipboard API works fine in iOS webviews but fails with a permissions | ||
* error in Android in some cases. Also, old versions of Chrome in Android may not have support for the Web | ||
* Clipboard API at all. | ||
* | ||
* We have decided to not implement the bridge method in iOS apps, as the Web Clipboard API works fine. | ||
*/ | ||
var readTextFromClipboard = function () { | ||
return postMessageToNativeApp({ type: 'CLIPBOARD_READ_TEXT' }); | ||
var _a; | ||
return (((_a = navigator.clipboard) === null || _a === void 0 ? void 0 : _a.readText) | ||
? navigator.clipboard.readText() | ||
: Promise.reject()).catch(function () { return postMessageToNativeApp({ type: 'CLIPBOARD_READ_TEXT' }); }); | ||
}; | ||
var writeTextToClipboard = function (text) { | ||
return postMessageToNativeApp({ type: 'CLIPBOARD_WRITE_TEXT', payload: text }); | ||
var _a; | ||
return (((_a = navigator.clipboard) === null || _a === void 0 ? void 0 : _a.writeText) | ||
? navigator.clipboard.writeText(text) | ||
: Promise.reject()).catch(function () { | ||
return postMessageToNativeApp({ | ||
type: 'CLIPBOARD_WRITE_TEXT', | ||
payload: text, | ||
}); | ||
}); | ||
}; | ||
@@ -1170,2 +1104,3 @@ | ||
exports.getTopazValues = getTopazValues; | ||
exports.hideLoadingOverlay = hideLoadingOverlay; | ||
exports.highlightNavigationTab = highlightNavigationTab; | ||
@@ -1207,2 +1142,3 @@ exports.internalNavigation = internalNavigation; | ||
exports.showAppRating = showAppRating; | ||
exports.showLoadingOverlay = showLoadingOverlay; | ||
exports.startProfileImageFlow = startProfileImageFlow; | ||
@@ -1209,0 +1145,0 @@ exports.triggerPinOrBiometricAuthentication = triggerPinOrBiometricAuthentication; |
@@ -249,6 +249,3 @@ 'use strict'; | ||
return postMessageToNativeApp({ type: 'SIM_ICC' }, TIMEOUT) | ||
.then(function (_a) { | ||
var icc = _a.icc; | ||
return icc; | ||
}) | ||
.then(function (response) { return response.icc; }) | ||
.catch(function () { return null; }); | ||
@@ -259,6 +256,3 @@ }; | ||
return postMessageToNativeApp({ type: 'IMSI' }, TIMEOUT) | ||
.then(function (_a) { | ||
var imsi = _a.imsi; | ||
return imsi; | ||
}) | ||
.then(function (response) { return response.imsi; }) | ||
.catch(function () { return null; }); | ||
@@ -268,6 +262,3 @@ }; | ||
return postMessageToNativeApp({ type: 'IMEI' }, TIMEOUT) | ||
.then(function (_a) { | ||
var imei = _a.imei; | ||
return imei; | ||
}) | ||
.then(function (response) { return response.imei; }) | ||
.catch(function () { return null; }); | ||
@@ -385,57 +376,2 @@ }; | ||
function __awaiter(thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
} | ||
function __generator(thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
} | ||
function __read(o, n) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator]; | ||
if (!m) return o; | ||
var i = m.call(o), r, ar = [], e; | ||
try { | ||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); | ||
} | ||
catch (error) { e = { error: error }; } | ||
finally { | ||
try { | ||
if (r && !r.done && (m = i["return"])) m.call(i); | ||
} | ||
finally { if (e) throw e.error; } | ||
} | ||
return ar; | ||
} | ||
var attachToEmail = function (_a) { | ||
@@ -535,17 +471,10 @@ var url = _a.url, subject = _a.subject, fileName = _a.fileName, recipient = _a.recipient, body = _a.body; | ||
var url = _a.url, method = _a.method, headers = _a.headers, body = _a.body; | ||
if (isWebViewBridgeAvailable()) { | ||
return postMessageToNativeApp({ | ||
type: 'FETCH', | ||
payload: { url: url, method: method, headers: headers, body: body }, | ||
}).catch(function () { return ({ | ||
status: 500, | ||
headers: {}, | ||
body: 'Bridge call failed', | ||
}); }); | ||
} | ||
return Promise.resolve({ | ||
return postMessageToNativeApp({ | ||
type: 'FETCH', | ||
payload: { url: url, method: method, headers: headers, body: body }, | ||
}).catch(function () { return ({ | ||
status: 500, | ||
headers: {}, | ||
body: 'Bridge not available', | ||
}); | ||
body: 'Bridge call failed', | ||
}); }); | ||
}; | ||
@@ -617,2 +546,8 @@ var checkPermissionStatus = function (feature, params) { | ||
}; | ||
var showLoadingOverlay = function (payload) { | ||
return postMessageToNativeApp({ type: 'SHOW_LOADING_OVERLAY', payload: payload }); | ||
}; | ||
var hideLoadingOverlay = function () { | ||
return postMessageToNativeApp({ type: 'HIDE_LOADING_OVERLAY' }); | ||
}; | ||
@@ -737,4 +672,5 @@ var msToS = function (ms) { return Math.floor(ms / 1000); }; | ||
var sanitizedParams = {}; | ||
Object.entries(params).forEach(function (_a) { | ||
var _b = __read(_a, 2), key = _b[0], value = _b[1]; | ||
Object.entries(params).forEach(function (entry) { | ||
var key = entry[0]; | ||
var value = entry[1]; | ||
var sanitizedValue = value; | ||
@@ -957,6 +893,3 @@ var sanitizedKey = key.slice(0, EVENT_PARAM_NAME_CHARS_LIMIT); | ||
payload: { accessToken: oldAccessToken || null }, | ||
}, options.timeout).then(function (_a) { | ||
var accessToken = _a.accessToken; | ||
return accessToken; | ||
}); | ||
}, options.timeout).then(function (result) { return result.accessToken; }); | ||
}; | ||
@@ -969,5 +902,4 @@ /** | ||
var onSessionRenewed = function (handler) { | ||
return listenToNativeMessage('SESSION_RENEWED', function (_a) { | ||
var accessToken = _a.accessToken; | ||
return handler(accessToken); | ||
return listenToNativeMessage('SESSION_RENEWED', function (result) { | ||
return handler(result.accessToken); | ||
}); | ||
@@ -990,35 +922,25 @@ }; | ||
var sheetLock = false; | ||
var bottomSheet = function (payload) { return __awaiter(void 0, void 0, void 0, function () { | ||
var tid, response, e_1; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (sheetLock) { | ||
throw { | ||
code: 423, | ||
reason: 'BottomSheet is locked. You can only have one bottom sheet in the screen', | ||
}; | ||
} | ||
sheetLock = true; | ||
tid = setTimeout(function () { | ||
sheetLock = false; | ||
}, 1000); | ||
_a.label = 1; | ||
case 1: | ||
_a.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, postMessageToNativeApp({ type: 'SHEET', payload: payload })]; | ||
case 2: | ||
response = _a.sent(); | ||
sheetLock = false; | ||
clearTimeout(tid); | ||
return [2 /*return*/, response]; | ||
case 3: | ||
e_1 = _a.sent(); | ||
sheetLock = false; | ||
clearTimeout(tid); | ||
throw e_1; | ||
case 4: return [2 /*return*/]; | ||
} | ||
var bottomSheet = function (payload) { | ||
if (sheetLock) { | ||
return Promise.reject({ | ||
code: 423, | ||
reason: 'BottomSheet is locked. You can only have one bottom sheet in the screen', | ||
}); | ||
} | ||
sheetLock = true; | ||
var tid = setTimeout(function () { | ||
sheetLock = false; | ||
}, 1000); | ||
return postMessageToNativeApp({ type: 'SHEET', payload: payload }) | ||
.then(function (response) { | ||
sheetLock = false; | ||
clearTimeout(tid); | ||
return response; | ||
}) | ||
.catch(function (e) { | ||
sheetLock = false; | ||
clearTimeout(tid); | ||
throw e; | ||
}); | ||
}); }; | ||
}; | ||
var bottomSheetSingleSelector = function (_a) { | ||
@@ -1090,26 +1012,17 @@ var title = _a.title, subtitle = _a.subtitle, description = _a.description, selectedId = _a.selectedId, items = _a.items; | ||
var title = _a.title, subtitle = _a.subtitle, description = _a.description, items = _a.items; | ||
return __awaiter(void 0, void 0, void 0, function () { | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: return [4 /*yield*/, bottomSheet({ | ||
title: title, | ||
subtitle: subtitle, | ||
description: description, | ||
content: [ | ||
{ | ||
type: 'LIST', | ||
id: 'list-0', | ||
listType: 'INFORMATIVE', | ||
autoSubmit: false, | ||
selectedIds: [], | ||
items: items, | ||
}, | ||
], | ||
})]; | ||
case 1: | ||
_b.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
return bottomSheet({ | ||
title: title, | ||
subtitle: subtitle, | ||
description: description, | ||
content: [ | ||
{ | ||
type: 'LIST', | ||
id: 'list-0', | ||
listType: 'INFORMATIVE', | ||
autoSubmit: false, | ||
selectedIds: [], | ||
items: items, | ||
}, | ||
], | ||
}).then(function () { return undefined; }); | ||
}; | ||
@@ -1135,7 +1048,28 @@ | ||
/** | ||
* These functions try to use the Web Clipboard API if available, otherwise fall back to the bridge | ||
* implementation in native apps. | ||
* | ||
* According to the tests done, the Web Clipboard API works fine in iOS webviews but fails with a permissions | ||
* error in Android in some cases. Also, old versions of Chrome in Android may not have support for the Web | ||
* Clipboard API at all. | ||
* | ||
* We have decided to not implement the bridge method in iOS apps, as the Web Clipboard API works fine. | ||
*/ | ||
var readTextFromClipboard = function () { | ||
return postMessageToNativeApp({ type: 'CLIPBOARD_READ_TEXT' }); | ||
var _a; | ||
return (((_a = navigator.clipboard) === null || _a === void 0 ? void 0 : _a.readText) | ||
? navigator.clipboard.readText() | ||
: Promise.reject()).catch(function () { return postMessageToNativeApp({ type: 'CLIPBOARD_READ_TEXT' }); }); | ||
}; | ||
var writeTextToClipboard = function (text) { | ||
return postMessageToNativeApp({ type: 'CLIPBOARD_WRITE_TEXT', payload: text }); | ||
var _a; | ||
return (((_a = navigator.clipboard) === null || _a === void 0 ? void 0 : _a.writeText) | ||
? navigator.clipboard.writeText(text) | ||
: Promise.reject()).catch(function () { | ||
return postMessageToNativeApp({ | ||
type: 'CLIPBOARD_WRITE_TEXT', | ||
payload: text, | ||
}); | ||
}); | ||
}; | ||
@@ -1172,2 +1106,3 @@ | ||
exports.getTopazValues = getTopazValues; | ||
exports.hideLoadingOverlay = hideLoadingOverlay; | ||
exports.highlightNavigationTab = highlightNavigationTab; | ||
@@ -1209,2 +1144,3 @@ exports.internalNavigation = internalNavigation; | ||
exports.showAppRating = showAppRating; | ||
exports.showLoadingOverlay = showLoadingOverlay; | ||
exports.startProfileImageFlow = startProfileImageFlow; | ||
@@ -1211,0 +1147,0 @@ exports.triggerPinOrBiometricAuthentication = triggerPinOrBiometricAuthentication; |
@@ -248,6 +248,3 @@ var webviewBridge = (function (exports) { | ||
return postMessageToNativeApp({ type: 'SIM_ICC' }, TIMEOUT) | ||
.then(function (_a) { | ||
var icc = _a.icc; | ||
return icc; | ||
}) | ||
.then(function (response) { return response.icc; }) | ||
.catch(function () { return null; }); | ||
@@ -258,6 +255,3 @@ }; | ||
return postMessageToNativeApp({ type: 'IMSI' }, TIMEOUT) | ||
.then(function (_a) { | ||
var imsi = _a.imsi; | ||
return imsi; | ||
}) | ||
.then(function (response) { return response.imsi; }) | ||
.catch(function () { return null; }); | ||
@@ -267,6 +261,3 @@ }; | ||
return postMessageToNativeApp({ type: 'IMEI' }, TIMEOUT) | ||
.then(function (_a) { | ||
var imei = _a.imei; | ||
return imei; | ||
}) | ||
.then(function (response) { return response.imei; }) | ||
.catch(function () { return null; }); | ||
@@ -384,57 +375,2 @@ }; | ||
function __awaiter(thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
} | ||
function __generator(thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
} | ||
function __read(o, n) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator]; | ||
if (!m) return o; | ||
var i = m.call(o), r, ar = [], e; | ||
try { | ||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); | ||
} | ||
catch (error) { e = { error: error }; } | ||
finally { | ||
try { | ||
if (r && !r.done && (m = i["return"])) m.call(i); | ||
} | ||
finally { if (e) throw e.error; } | ||
} | ||
return ar; | ||
} | ||
var attachToEmail = function (_a) { | ||
@@ -534,17 +470,10 @@ var url = _a.url, subject = _a.subject, fileName = _a.fileName, recipient = _a.recipient, body = _a.body; | ||
var url = _a.url, method = _a.method, headers = _a.headers, body = _a.body; | ||
if (isWebViewBridgeAvailable()) { | ||
return postMessageToNativeApp({ | ||
type: 'FETCH', | ||
payload: { url: url, method: method, headers: headers, body: body }, | ||
}).catch(function () { return ({ | ||
status: 500, | ||
headers: {}, | ||
body: 'Bridge call failed', | ||
}); }); | ||
} | ||
return Promise.resolve({ | ||
return postMessageToNativeApp({ | ||
type: 'FETCH', | ||
payload: { url: url, method: method, headers: headers, body: body }, | ||
}).catch(function () { return ({ | ||
status: 500, | ||
headers: {}, | ||
body: 'Bridge not available', | ||
}); | ||
body: 'Bridge call failed', | ||
}); }); | ||
}; | ||
@@ -616,2 +545,8 @@ var checkPermissionStatus = function (feature, params) { | ||
}; | ||
var showLoadingOverlay = function (payload) { | ||
return postMessageToNativeApp({ type: 'SHOW_LOADING_OVERLAY', payload: payload }); | ||
}; | ||
var hideLoadingOverlay = function () { | ||
return postMessageToNativeApp({ type: 'HIDE_LOADING_OVERLAY' }); | ||
}; | ||
@@ -736,4 +671,5 @@ var msToS = function (ms) { return Math.floor(ms / 1000); }; | ||
var sanitizedParams = {}; | ||
Object.entries(params).forEach(function (_a) { | ||
var _b = __read(_a, 2), key = _b[0], value = _b[1]; | ||
Object.entries(params).forEach(function (entry) { | ||
var key = entry[0]; | ||
var value = entry[1]; | ||
var sanitizedValue = value; | ||
@@ -956,6 +892,3 @@ var sanitizedKey = key.slice(0, EVENT_PARAM_NAME_CHARS_LIMIT); | ||
payload: { accessToken: oldAccessToken || null }, | ||
}, options.timeout).then(function (_a) { | ||
var accessToken = _a.accessToken; | ||
return accessToken; | ||
}); | ||
}, options.timeout).then(function (result) { return result.accessToken; }); | ||
}; | ||
@@ -968,5 +901,4 @@ /** | ||
var onSessionRenewed = function (handler) { | ||
return listenToNativeMessage('SESSION_RENEWED', function (_a) { | ||
var accessToken = _a.accessToken; | ||
return handler(accessToken); | ||
return listenToNativeMessage('SESSION_RENEWED', function (result) { | ||
return handler(result.accessToken); | ||
}); | ||
@@ -989,35 +921,25 @@ }; | ||
var sheetLock = false; | ||
var bottomSheet = function (payload) { return __awaiter(void 0, void 0, void 0, function () { | ||
var tid, response, e_1; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (sheetLock) { | ||
throw { | ||
code: 423, | ||
reason: 'BottomSheet is locked. You can only have one bottom sheet in the screen', | ||
}; | ||
} | ||
sheetLock = true; | ||
tid = setTimeout(function () { | ||
sheetLock = false; | ||
}, 1000); | ||
_a.label = 1; | ||
case 1: | ||
_a.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, postMessageToNativeApp({ type: 'SHEET', payload: payload })]; | ||
case 2: | ||
response = _a.sent(); | ||
sheetLock = false; | ||
clearTimeout(tid); | ||
return [2 /*return*/, response]; | ||
case 3: | ||
e_1 = _a.sent(); | ||
sheetLock = false; | ||
clearTimeout(tid); | ||
throw e_1; | ||
case 4: return [2 /*return*/]; | ||
} | ||
var bottomSheet = function (payload) { | ||
if (sheetLock) { | ||
return Promise.reject({ | ||
code: 423, | ||
reason: 'BottomSheet is locked. You can only have one bottom sheet in the screen', | ||
}); | ||
} | ||
sheetLock = true; | ||
var tid = setTimeout(function () { | ||
sheetLock = false; | ||
}, 1000); | ||
return postMessageToNativeApp({ type: 'SHEET', payload: payload }) | ||
.then(function (response) { | ||
sheetLock = false; | ||
clearTimeout(tid); | ||
return response; | ||
}) | ||
.catch(function (e) { | ||
sheetLock = false; | ||
clearTimeout(tid); | ||
throw e; | ||
}); | ||
}); }; | ||
}; | ||
var bottomSheetSingleSelector = function (_a) { | ||
@@ -1089,26 +1011,17 @@ var title = _a.title, subtitle = _a.subtitle, description = _a.description, selectedId = _a.selectedId, items = _a.items; | ||
var title = _a.title, subtitle = _a.subtitle, description = _a.description, items = _a.items; | ||
return __awaiter(void 0, void 0, void 0, function () { | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: return [4 /*yield*/, bottomSheet({ | ||
title: title, | ||
subtitle: subtitle, | ||
description: description, | ||
content: [ | ||
{ | ||
type: 'LIST', | ||
id: 'list-0', | ||
listType: 'INFORMATIVE', | ||
autoSubmit: false, | ||
selectedIds: [], | ||
items: items, | ||
}, | ||
], | ||
})]; | ||
case 1: | ||
_b.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
return bottomSheet({ | ||
title: title, | ||
subtitle: subtitle, | ||
description: description, | ||
content: [ | ||
{ | ||
type: 'LIST', | ||
id: 'list-0', | ||
listType: 'INFORMATIVE', | ||
autoSubmit: false, | ||
selectedIds: [], | ||
items: items, | ||
}, | ||
], | ||
}).then(function () { return undefined; }); | ||
}; | ||
@@ -1134,7 +1047,28 @@ | ||
/** | ||
* These functions try to use the Web Clipboard API if available, otherwise fall back to the bridge | ||
* implementation in native apps. | ||
* | ||
* According to the tests done, the Web Clipboard API works fine in iOS webviews but fails with a permissions | ||
* error in Android in some cases. Also, old versions of Chrome in Android may not have support for the Web | ||
* Clipboard API at all. | ||
* | ||
* We have decided to not implement the bridge method in iOS apps, as the Web Clipboard API works fine. | ||
*/ | ||
var readTextFromClipboard = function () { | ||
return postMessageToNativeApp({ type: 'CLIPBOARD_READ_TEXT' }); | ||
var _a; | ||
return (((_a = navigator.clipboard) === null || _a === void 0 ? void 0 : _a.readText) | ||
? navigator.clipboard.readText() | ||
: Promise.reject()).catch(function () { return postMessageToNativeApp({ type: 'CLIPBOARD_READ_TEXT' }); }); | ||
}; | ||
var writeTextToClipboard = function (text) { | ||
return postMessageToNativeApp({ type: 'CLIPBOARD_WRITE_TEXT', payload: text }); | ||
var _a; | ||
return (((_a = navigator.clipboard) === null || _a === void 0 ? void 0 : _a.writeText) | ||
? navigator.clipboard.writeText(text) | ||
: Promise.reject()).catch(function () { | ||
return postMessageToNativeApp({ | ||
type: 'CLIPBOARD_WRITE_TEXT', | ||
payload: text, | ||
}); | ||
}); | ||
}; | ||
@@ -1171,2 +1105,3 @@ | ||
exports.getTopazValues = getTopazValues; | ||
exports.hideLoadingOverlay = hideLoadingOverlay; | ||
exports.highlightNavigationTab = highlightNavigationTab; | ||
@@ -1208,2 +1143,3 @@ exports.internalNavigation = internalNavigation; | ||
exports.showAppRating = showAppRating; | ||
exports.showLoadingOverlay = showLoadingOverlay; | ||
exports.startProfileImageFlow = startProfileImageFlow; | ||
@@ -1210,0 +1146,0 @@ exports.triggerPinOrBiometricAuthentication = triggerPinOrBiometricAuthentication; |
@@ -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())},T=null,E=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])},h=function(e){return Math.floor(e/1e3)},I=0,A=function(e){var t=setTimeout(function(){e(),I++},500);return function(){clearTimeout(t),I=0,e()}},S=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()},_=function(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"")},N=function(e){return _(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="",R=!1,M=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(R)throw{code:423,reason:"BottomSheet is locked. You can only have one bottom sheet in the screen"};R=!0,t=setTimeout(function(){R=!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(),R=!1,clearTimeout(t),[2,n];case 3:throw r=o.sent(),R=!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=M,e.bottomSheetActionSelector=function(e){var t=e.title,n=e.subtitle,r=e.description,o=e.items;return M({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,M({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 M({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:h(t),endTime:h(n),title:r}})},e.dismiss=function(e){return p({type:"DISMISS",payload:{onCompletionUrl:e}})},e.downloadBase64=function(e){return p({type:"DOWNLOAD_BASE64",payload:{content:e.contentInBase64,fileName:e.fileName}})},e.fetch=function(e){var t=e.url,n=e.method,r=e.headers,o=e.body;return 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.focusNavbar=function(){return p({type:"FOCUS_NAVBAR"})},e.getAppMetadata=function(e){return p({type:"GET_APP_METADATA",payload:{appToken:e}})},e.getAttStatus=function(){return p({type:"GET_ATT_STATUS"}).catch(function(){return null})},e.getBatteryInfo=function(){return p({type:"GET_BATTERY_INFO"})},e.getDeviceModel=function(){return p({type:"MODEL"}).catch(function(){return null})},e.getDeviceTac=function(){return p({type:"TAC"}).catch(function(){return{tac:null}})},e.getDiskSpaceInfo=function(){return p({type:"GET_DISK_SPACE_INFO"})},e.getEsimInfo=function(){return p({type:"GET_ESIM_INFO"}).catch(function(){return{supportsEsim:!1,eid:null}})},e.getNetworkConnectionInfo=function(){return p({type:"DATA_CONNECTION_INFO",payload:{}})},e.getPincodeInfo=function(){return p({type:"GET_PINCODE_INFO"})},e.getProfileImage=function(){return p({type:"GET_PROFILE_IMAGE"})},e.getRemoteConfig=E,e.getTopazToken=function(e){return void 0===e&&(e={}),p({type:"GET_TOPAZ_TOKEN",payload:{}},e.timeout)},e.getTopazValues=function(){return p({type:"GET_TOPAZ_VALUES",payload:{}})},e.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 E().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}),S({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:_(i),eventValue:a},u),s=e.category}return l=m(m({},l),{screenName:l.screenName||C}),S({onAndroid:function(e){return e.logEvent&&e.logEvent(s,JSON.stringify(l)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:s,parameters:l}),Promise.resolve()},onWeb:function(e){return new Promise(function(t){e("event",s,m(m({},l),{event_callback:A(t)}))})}})},e.logTiming=function(e){var t=e.category,n=void 0===t?"performance_timer":t,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 S({onAndroid:function(e){return e.logEvent&&e.logEvent(u,JSON.stringify(a)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:u,parameters:a}),Promise.resolve()},onWeb:function(){return new Promise(function(e){gtag("event",u,m(m({},a),{event_callback:A(e)}))})}})},e.logout=function(){return p({type:"LOG_OUT"})},e.nativeAlert=function(e){var t=e.message,n=e.title,r=e.buttonText;return d()?p({type:"ALERT",payload:{title:n,message:t,buttonText:r}}):("undefined"!=typeof window&&window.alert(t),Promise.resolve())},e.nativeConfirm=function(e){var t=e.message,n=e.title,r=e.acceptText,o=e.cancelText,i=e.destructive;return d()?p({type:"CONFIRM",payload:{message:t,title:n,acceptText:r,cancelText:o,destructive:i}}).then(function(e){return e.result}):Promise.resolve("undefined"!=typeof window&&window.confirm(t))},e.nativeMessage=function(e){var t=e.message,n=e.duration,r=e.buttonText,o=e.buttonAccessibilityLabel,i=e.type,a=e.withDismiss;return d()?p({type:"MESSAGE",payload:{message:t,duration:n,buttonText:r,buttonAccessibilityLabel:o,type:i,withDismiss:a}}).then(function(e){return e&&e.action?e:{action:"DISMISS"}}):("undefined"!=typeof window&&window.alert(t),Promise.resolve({action:"DISMISS"}))},e.notifyBridgeReady=function(){return p({type:"BRIDGE_READY"})},e.notifyPageLoaded=function(){return p({type:"PAGE_LOADED"})},e.onNativeEvent=function(e){return y("NATIVE_EVENT",function(t){return{action:e({event:t.event}).action||"default"}})},e.onNavigationBarIconClicked=function(e){return y("NAVIGATION_BAR_ICON_CLICKED",e)},e.onSessionRenewed=function(e){return y("SESSION_RENEWED",function(t){var n=t.accessToken;return e(n)})},e.openOnboarding=function(){return p({type:"OPEN_ONBOARDING"})},e.readTextFromClipboard=function(){return p({type:"CLIPBOARD_READ_TEXT"})},e.renewSession=function(e,t){return void 0===t&&(t={}),p({type:"RENEW_SESSION",payload:{accessToken:e||null}},t.timeout).then(function(e){return e.accessToken})},e.reportStatus=function(e){var t=e.feature,n=e.status,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.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,S({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:A(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),S({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.shareBase64=function(e){return p({type:"SHARE_BASE64",payload:{content:e.contentInBase64,fileName:e.fileName}})},e.showAppRating=function(){return p({type:"SHOW_APP_RATING"})},e.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}})},e.writeTextToClipboard=function(e){return p({type:"CLIPBOARD_WRITE_TEXT",payload:e})},Object.defineProperty(e,"__esModule",{value:!0}),e}({}); | ||
var webviewBridge=function(e){"use strict";var t=1,n="".concat(Date.now(),"-").concat(String(Math.random()).slice(-8)),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")))},d=void 0,f=function(){return!l()&&(r()||i())},p=function(e,o){var r=e.type,i=e.id,u=void 0===i?"web-".concat(t++,"-").concat(n):i,l=e.payload,f=a(),p=JSON.stringify({type:r,id:u,payload:l});return null===d||void 0===d||d("[WebView Bridge] SEND:",p),f?(setTimeout(function(){f(p)}),new Promise(function(e,t){var n=!1,i=function(o){o.id!==u||n||(o.type===r?e(o.payload):"ERROR"===o.type?t(o.payload):t({code:500,reason:"bad type: ".concat(o.type,". Expecting ").concat(r)}),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===d||void 0===d||d("[WebView Bridge] RCVD:",e);try{t=JSON.parse(e)}catch(t){throw Error("Problem parsing webview message: ".concat(e))}u.forEach(function(e){return e(t)})}});var y=function(e,t){var n=function(n){n.type===e&&Promise.resolve(t(n.payload)).then(function(e){var t=a();t&&t(JSON.stringify({type:n.type,id:n.id,payload:e}))})};return 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}var g=function(e){return f()?p({type:"NAVIGATION_BAR",payload:e}):(void 0!==e.title&&"undefined"!=typeof document&&(document.title=e.title),Promise.resolve())},w=null,T=function(){if(w)return Promise.resolve(m({},w));var e=new Promise(function(e){setTimeout(function(){e({result:{}})},500)}),t=p({type:"GET_REMOTE_CONFIG"}).then(function(e){return m({},w=e)});return Promise.race([e,t])},E=function(e){return Math.floor(e/1e3)},b=0,I=function(e){var t=setTimeout(function(){e(),b++},500);return function(){clearTimeout(t),b=0,e()}},A=function(e){var t=e.onAndroid,n=e.onIos,o=e.onWeb;return"undefined"==typeof window?Promise.resolve():window.AnalyticsWebInterface?t(window.AnalyticsWebInterface):window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.firebase?n(window.webkit.messageHandlers.firebase):window.gtag&&b<3?o(window.gtag):Promise.resolve()},_=function(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"")},h=function(e){return _(e).toLocaleLowerCase().replace(/[^a-zß0-9\s\-\_\/\|\:]/g,"").replace(/\s+/g," ").trim().replace(/\s/g,"_").slice(0,100)},N=function(e){var t={};return Object.entries(e).forEach(function(e){var n=e[0],o=e[1],r=o,i=n.slice(0,40);"string"==typeof o&&(r=h(o)),t[i]=r}),t},S={sanitize:!0},O="",P=!1,R=function(e){if(P)return Promise.reject({code:423,reason:"BottomSheet is locked. You can only have one bottom sheet in the screen"});P=!0;var t=setTimeout(function(){P=!1},1e3);return p({type:"SHEET",payload:e}).then(function(e){return P=!1,clearTimeout(t),e}).catch(function(e){throw P=!1,clearTimeout(t),e})};return e.CD_EVENT_VALUE=8,e.CD_NOVUM_UID=7,e.CD_WEBAPP_INSTALLED=4,e.attachToEmail=function(e){var t=e.url,n=e.subject,o=e.fileName,r=e.recipient,i=e.body;return p({type:"ATTACH_TO_EMAIL",payload:{url:t,subject:n,fileName:o,recipient:r,body:i}})},e.bottomSheet=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 R({title:t,subtitle:n,description:o,content:[{type:"LIST",id:"list-0",listType:"INFORMATIVE",autoSubmit:!1,selectedIds:[],items:r}]}).then(function(){})},e.bottomSheetSingleSelector=function(e){var t=e.title,n=e.subtitle,o=e.description,r=e.selectedId,i=e.items;return 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.downloadBase64=function(e){return p({type:"DOWNLOAD_BASE64",payload:{content:e.contentInBase64,fileName:e.fileName}})},e.fetch=function(e){var t=e.url,n=e.method,o=e.headers,r=e.body;return p({type:"FETCH",payload:{url:t,method:n,headers:o,body:r}}).catch(function(){return{status:500,headers:{},body:"Bridge call failed"}})},e.fetchContactsByPhone=function(e){return p({type:"FETCH_CONTACTS_DATA",payload:{phoneNumbers:e}})},e.fetchPhoneNumbers=function(){return p({type:"FETCH_PHONE_NUMBERS"})},e.focusNavbar=function(){return p({type:"FOCUS_NAVBAR"})},e.getAppMetadata=function(e){return p({type:"GET_APP_METADATA",payload:{appToken:e}})},e.getAttStatus=function(){return p({type:"GET_ATT_STATUS"}).catch(function(){return null})},e.getBatteryInfo=function(){return p({type:"GET_BATTERY_INFO"})},e.getDeviceModel=function(){return p({type:"MODEL"}).catch(function(){return null})},e.getDeviceTac=function(){return p({type:"TAC"}).catch(function(){return{tac:null}})},e.getDiskSpaceInfo=function(){return p({type:"GET_DISK_SPACE_INFO"})},e.getEsimInfo=function(){return p({type:"GET_ESIM_INFO"}).catch(function(){return{supportsEsim:!1,eid:null}})},e.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.getTopazValues=function(){return p({type:"GET_TOPAZ_VALUES",payload:{}})},e.hideLoadingOverlay=function(){return p({type:"HIDE_LOADING_OVERLAY"})},e.highlightNavigationTab=function(e){var t=e.tab,n=e.highlight,o=e.count;return p({type:"HIGHLIGHT_TAB",payload:{tab:t,highlight:n,count:o}})},e.internalNavigation=function(e){return p({type:"INTERNAL_NAVIGATION",payload:{feature:e}})},e.isABTestingAvailable=function(e){return T().then(function(){return function(e){return"true"===w.result[e]}(e)}).catch(function(){return!1})},e.isWebViewBridgeAvailable=f,e.logEcommerceEvent=function(e,t){return t=m(m({},t),{screenName:t.screenName||O}),A({onAndroid:function(n){return n.logEvent&&n.logEvent(e,JSON.stringify(t)),Promise.resolve()},onIos:function(n){return n.postMessage({command:"logEvent",name:e,parameters:t}),Promise.resolve()},onWeb:function(){return Promise.resolve()}})},e.logEvent=function(e,t){var n,o,r,i,a,u,c=m(m({},S),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=N(l),s=h(s));else{if(!e.category||!e.action)return console.warn('LegacyAnalyticsEvent should have "category" and "action"',{category:e.category,action:e.action}),Promise.resolve();o=(n=e).category,r=n.action,i=n.label,a=n.value,u=v(n,["category","action","label","value"]),i||(i="null_label"),a||(a=0),l=m({eventCategory:o,eventAction:r,eventLabel:_(i),eventValue:a},u),s=e.category}return l=m(m({},l),{screenName:l.screenName||O}),A({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 A({onAndroid:function(e){return e.logEvent&&e.logEvent(u,JSON.stringify(a)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:u,parameters:a}),Promise.resolve()},onWeb:function(){return new Promise(function(e){gtag("event",u,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 f()?p({type:"ALERT",payload:{title:n,message:t,buttonText:o}}):("undefined"!=typeof window&&window.alert(t),Promise.resolve())},e.nativeConfirm=function(e){var t=e.message,n=e.title,o=e.acceptText,r=e.cancelText,i=e.destructive;return f()?p({type:"CONFIRM",payload:{message:t,title:n,acceptText:o,cancelText:r,destructive:i}}).then(function(e){return e.result}):Promise.resolve("undefined"!=typeof window&&window.confirm(t))},e.nativeMessage=function(e){var t=e.message,n=e.duration,o=e.buttonText,r=e.buttonAccessibilityLabel,i=e.type,a=e.withDismiss;return f()?p({type:"MESSAGE",payload:{message:t,duration:n,buttonText:o,buttonAccessibilityLabel:r,type:i,withDismiss:a}}).then(function(e){return e&&e.action?e:{action:"DISMISS"}}):("undefined"!=typeof window&&window.alert(t),Promise.resolve({action:"DISMISS"}))},e.notifyBridgeReady=function(){return p({type:"BRIDGE_READY"})},e.notifyPageLoaded=function(){return p({type:"PAGE_LOADED"})},e.onNativeEvent=function(e){return y("NATIVE_EVENT",function(t){return{action:e({event:t.event}).action||"default"}})},e.onNavigationBarIconClicked=function(e){return y("NAVIGATION_BAR_ICON_CLICKED",e)},e.onSessionRenewed=function(e){return y("SESSION_RENEWED",function(t){return e(t.accessToken)})},e.openOnboarding=function(){return p({type:"OPEN_ONBOARDING"})},e.readTextFromClipboard=function(){var e;return((null===(e=navigator.clipboard)||void 0===e?void 0:e.readText)?navigator.clipboard.readText():Promise.reject()).catch(function(){return p({type:"CLIPBOARD_READ_TEXT"})})},e.renewSession=function(e,t){return void 0===t&&(t={}),p({type:"RENEW_SESSION",payload:{accessToken:e||null}},t.timeout).then(function(e){return e.accessToken})},e.reportStatus=function(e){var t=e.feature,n=e.status,o=e.reason;return p({type:"STATUS_REPORT",payload:{feature:t,status:n,reason:o}})},e.requestContact=function(e){var t=(void 0===e?{}:e).filter;return p({type:"GET_CONTACT_DATA",payload:{filter:void 0===t?"phone":t}})},e.requestDeviceImei=function(){return p({type:"IMEI"},200).then(function(e){return e.imei}).catch(function(){return null})},e.requestSimIcc=function(){return p({type:"SIM_ICC"},200).then(function(e){return e.icc}).catch(function(){return null})},e.requestSimImsi=function(){return p({type:"IMSI"},200).then(function(e){return e.imsi}).catch(function(){return null})},e.requestVibration=function(e){return p({type:"VIBRATION",payload:{type:e}})},e.sanitizeAnalyticsParam=h,e.sanitizeAnalyticsParams=N,e.setActionBehavior=function(e){return p({type:"SET_ACTION_BEHAVIOR",payload:{actions:e}}).catch(function(){})},e.setLogger=function(e){d=e},e.setScreenName=function(e,t){if(void 0===t&&(t={}),!e)return console.warn("Missing analytics screenName"),Promise.resolve();var n=O;return O=e,A({onAndroid:function(n){return n.setScreenNameWithParams?n.setScreenNameWithParams(e,JSON.stringify(N(t))):n.setScreenName&&n.setScreenName(e),Promise.resolve()},onIos:function(n){return n.postMessage({command:"setScreenName",name:e,parameters:N(t)}),Promise.resolve()},onWeb:function(o){return new Promise(function(r){o("event","page_view",m(m({screenName:e,page_title:e,previousScreenName:n},N(t)),{event_callback:I(r)}))})}})},e.setTrackingProperty=function(e,t,n){return p({type:"SET_TRACKING_PROPERTY",payload:{system:e,name:t,value:n}}).catch(function(){})},e.setUserProperty=function(e,t){return e&&t?(t=String(t),A({onAndroid:function(n){return n.setUserProperty&&n.setUserProperty(e,t),Promise.resolve()},onIos:function(n){return n.postMessage({command:"setUserProperty",name:e,value:t}),Promise.resolve()},onWeb:function(n){var o;return n("set","user_properties",((o={})[e]=h(t),o)),Promise.resolve()}})):(console.warn("Trying to set analytics user property without name or value",e,t),Promise.resolve())},e.setWebViewTitle=function(e){return f()?g({title:e}):("undefined"!=typeof document&&(document.title=e),Promise.resolve())},e.share=function(e){return p({type:"SHARE",payload:e})},e.shareBase64=function(e){return p({type:"SHARE_BASE64",payload:{content:e.contentInBase64,fileName:e.fileName}})},e.showAppRating=function(){return p({type:"SHOW_APP_RATING"})},e.showLoadingOverlay=function(e){return p({type:"SHOW_LOADING_OVERLAY",payload:e})},e.startProfileImageFlow=function(){return p({type:"START_PROFILE_IMAGE_FLOW"})},e.triggerPinOrBiometricAuthentication=function(e){return p({type:"TRIGGER_PIN_OR_BIOMETRIC_AUTHENTICATION",payload:{maxSecondsSinceLastValidation:e}})},e.updateNavigationBar=g,e.updatePhoneNumbers=function(e){return p({type:"UPDATE_PHONE_NUMBERS",payload:{phoneNumbers:e}})},e.writeTextToClipboard=function(e){var t;return((null===(t=navigator.clipboard)||void 0===t?void 0:t.writeText)?navigator.clipboard.writeText(e):Promise.reject()).catch(function(){return p({type:"CLIPBOARD_WRITE_TEXT",payload:e})})},Object.defineProperty(e,"__esModule",{value:!0}),e}({}); |
@@ -251,6 +251,3 @@ (function (global, factory) { | ||
return postMessageToNativeApp({ type: 'SIM_ICC' }, TIMEOUT) | ||
.then(function (_a) { | ||
var icc = _a.icc; | ||
return icc; | ||
}) | ||
.then(function (response) { return response.icc; }) | ||
.catch(function () { return null; }); | ||
@@ -261,6 +258,3 @@ }; | ||
return postMessageToNativeApp({ type: 'IMSI' }, TIMEOUT) | ||
.then(function (_a) { | ||
var imsi = _a.imsi; | ||
return imsi; | ||
}) | ||
.then(function (response) { return response.imsi; }) | ||
.catch(function () { return null; }); | ||
@@ -270,6 +264,3 @@ }; | ||
return postMessageToNativeApp({ type: 'IMEI' }, TIMEOUT) | ||
.then(function (_a) { | ||
var imei = _a.imei; | ||
return imei; | ||
}) | ||
.then(function (response) { return response.imei; }) | ||
.catch(function () { return null; }); | ||
@@ -387,57 +378,2 @@ }; | ||
function __awaiter(thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
} | ||
function __generator(thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
} | ||
function __read(o, n) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator]; | ||
if (!m) return o; | ||
var i = m.call(o), r, ar = [], e; | ||
try { | ||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); | ||
} | ||
catch (error) { e = { error: error }; } | ||
finally { | ||
try { | ||
if (r && !r.done && (m = i["return"])) m.call(i); | ||
} | ||
finally { if (e) throw e.error; } | ||
} | ||
return ar; | ||
} | ||
var attachToEmail = function (_a) { | ||
@@ -537,17 +473,10 @@ var url = _a.url, subject = _a.subject, fileName = _a.fileName, recipient = _a.recipient, body = _a.body; | ||
var url = _a.url, method = _a.method, headers = _a.headers, body = _a.body; | ||
if (isWebViewBridgeAvailable()) { | ||
return postMessageToNativeApp({ | ||
type: 'FETCH', | ||
payload: { url: url, method: method, headers: headers, body: body }, | ||
}).catch(function () { return ({ | ||
status: 500, | ||
headers: {}, | ||
body: 'Bridge call failed', | ||
}); }); | ||
} | ||
return Promise.resolve({ | ||
return postMessageToNativeApp({ | ||
type: 'FETCH', | ||
payload: { url: url, method: method, headers: headers, body: body }, | ||
}).catch(function () { return ({ | ||
status: 500, | ||
headers: {}, | ||
body: 'Bridge not available', | ||
}); | ||
body: 'Bridge call failed', | ||
}); }); | ||
}; | ||
@@ -619,2 +548,8 @@ var checkPermissionStatus = function (feature, params) { | ||
}; | ||
var showLoadingOverlay = function (payload) { | ||
return postMessageToNativeApp({ type: 'SHOW_LOADING_OVERLAY', payload: payload }); | ||
}; | ||
var hideLoadingOverlay = function () { | ||
return postMessageToNativeApp({ type: 'HIDE_LOADING_OVERLAY' }); | ||
}; | ||
@@ -739,4 +674,5 @@ var msToS = function (ms) { return Math.floor(ms / 1000); }; | ||
var sanitizedParams = {}; | ||
Object.entries(params).forEach(function (_a) { | ||
var _b = __read(_a, 2), key = _b[0], value = _b[1]; | ||
Object.entries(params).forEach(function (entry) { | ||
var key = entry[0]; | ||
var value = entry[1]; | ||
var sanitizedValue = value; | ||
@@ -959,6 +895,3 @@ var sanitizedKey = key.slice(0, EVENT_PARAM_NAME_CHARS_LIMIT); | ||
payload: { accessToken: oldAccessToken || null }, | ||
}, options.timeout).then(function (_a) { | ||
var accessToken = _a.accessToken; | ||
return accessToken; | ||
}); | ||
}, options.timeout).then(function (result) { return result.accessToken; }); | ||
}; | ||
@@ -971,5 +904,4 @@ /** | ||
var onSessionRenewed = function (handler) { | ||
return listenToNativeMessage('SESSION_RENEWED', function (_a) { | ||
var accessToken = _a.accessToken; | ||
return handler(accessToken); | ||
return listenToNativeMessage('SESSION_RENEWED', function (result) { | ||
return handler(result.accessToken); | ||
}); | ||
@@ -992,35 +924,25 @@ }; | ||
var sheetLock = false; | ||
var bottomSheet = function (payload) { return __awaiter(void 0, void 0, void 0, function () { | ||
var tid, response, e_1; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
if (sheetLock) { | ||
throw { | ||
code: 423, | ||
reason: 'BottomSheet is locked. You can only have one bottom sheet in the screen', | ||
}; | ||
} | ||
sheetLock = true; | ||
tid = setTimeout(function () { | ||
sheetLock = false; | ||
}, 1000); | ||
_a.label = 1; | ||
case 1: | ||
_a.trys.push([1, 3, , 4]); | ||
return [4 /*yield*/, postMessageToNativeApp({ type: 'SHEET', payload: payload })]; | ||
case 2: | ||
response = _a.sent(); | ||
sheetLock = false; | ||
clearTimeout(tid); | ||
return [2 /*return*/, response]; | ||
case 3: | ||
e_1 = _a.sent(); | ||
sheetLock = false; | ||
clearTimeout(tid); | ||
throw e_1; | ||
case 4: return [2 /*return*/]; | ||
} | ||
var bottomSheet = function (payload) { | ||
if (sheetLock) { | ||
return Promise.reject({ | ||
code: 423, | ||
reason: 'BottomSheet is locked. You can only have one bottom sheet in the screen', | ||
}); | ||
} | ||
sheetLock = true; | ||
var tid = setTimeout(function () { | ||
sheetLock = false; | ||
}, 1000); | ||
return postMessageToNativeApp({ type: 'SHEET', payload: payload }) | ||
.then(function (response) { | ||
sheetLock = false; | ||
clearTimeout(tid); | ||
return response; | ||
}) | ||
.catch(function (e) { | ||
sheetLock = false; | ||
clearTimeout(tid); | ||
throw e; | ||
}); | ||
}); }; | ||
}; | ||
var bottomSheetSingleSelector = function (_a) { | ||
@@ -1092,26 +1014,17 @@ var title = _a.title, subtitle = _a.subtitle, description = _a.description, selectedId = _a.selectedId, items = _a.items; | ||
var title = _a.title, subtitle = _a.subtitle, description = _a.description, items = _a.items; | ||
return __awaiter(void 0, void 0, void 0, function () { | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: return [4 /*yield*/, bottomSheet({ | ||
title: title, | ||
subtitle: subtitle, | ||
description: description, | ||
content: [ | ||
{ | ||
type: 'LIST', | ||
id: 'list-0', | ||
listType: 'INFORMATIVE', | ||
autoSubmit: false, | ||
selectedIds: [], | ||
items: items, | ||
}, | ||
], | ||
})]; | ||
case 1: | ||
_b.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
return bottomSheet({ | ||
title: title, | ||
subtitle: subtitle, | ||
description: description, | ||
content: [ | ||
{ | ||
type: 'LIST', | ||
id: 'list-0', | ||
listType: 'INFORMATIVE', | ||
autoSubmit: false, | ||
selectedIds: [], | ||
items: items, | ||
}, | ||
], | ||
}).then(function () { return undefined; }); | ||
}; | ||
@@ -1137,7 +1050,28 @@ | ||
/** | ||
* These functions try to use the Web Clipboard API if available, otherwise fall back to the bridge | ||
* implementation in native apps. | ||
* | ||
* According to the tests done, the Web Clipboard API works fine in iOS webviews but fails with a permissions | ||
* error in Android in some cases. Also, old versions of Chrome in Android may not have support for the Web | ||
* Clipboard API at all. | ||
* | ||
* We have decided to not implement the bridge method in iOS apps, as the Web Clipboard API works fine. | ||
*/ | ||
var readTextFromClipboard = function () { | ||
return postMessageToNativeApp({ type: 'CLIPBOARD_READ_TEXT' }); | ||
var _a; | ||
return (((_a = navigator.clipboard) === null || _a === void 0 ? void 0 : _a.readText) | ||
? navigator.clipboard.readText() | ||
: Promise.reject()).catch(function () { return postMessageToNativeApp({ type: 'CLIPBOARD_READ_TEXT' }); }); | ||
}; | ||
var writeTextToClipboard = function (text) { | ||
return postMessageToNativeApp({ type: 'CLIPBOARD_WRITE_TEXT', payload: text }); | ||
var _a; | ||
return (((_a = navigator.clipboard) === null || _a === void 0 ? void 0 : _a.writeText) | ||
? navigator.clipboard.writeText(text) | ||
: Promise.reject()).catch(function () { | ||
return postMessageToNativeApp({ | ||
type: 'CLIPBOARD_WRITE_TEXT', | ||
payload: text, | ||
}); | ||
}); | ||
}; | ||
@@ -1174,2 +1108,3 @@ | ||
exports.getTopazValues = getTopazValues; | ||
exports.hideLoadingOverlay = hideLoadingOverlay; | ||
exports.highlightNavigationTab = highlightNavigationTab; | ||
@@ -1211,2 +1146,3 @@ exports.internalNavigation = internalNavigation; | ||
exports.showAppRating = showAppRating; | ||
exports.showLoadingOverlay = showLoadingOverlay; | ||
exports.startProfileImageFlow = startProfileImageFlow; | ||
@@ -1213,0 +1149,0 @@ exports.triggerPinOrBiometricAuthentication = triggerPinOrBiometricAuthentication; |
@@ -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())},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,A=function(e){var t=setTimeout(function(){e(),I++},500);return function(){clearTimeout(t),I=0,e()}},S=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()},_=function(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"")},N=function(e){return _(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="",R=!1,M=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(R)throw{code:423,reason:"BottomSheet is locked. You can only have one bottom sheet in the screen"};R=!0,t=setTimeout(function(){R=!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(),R=!1,clearTimeout(t),[2,n];case 3:throw o=r.sent(),R=!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=M,e.bottomSheetActionSelector=function(e){var t=e.title,n=e.subtitle,o=e.description,r=e.items;return M({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,M({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 M({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.downloadBase64=function(e){return p({type:"DOWNLOAD_BASE64",payload:{content:e.contentInBase64,fileName:e.fileName}})},e.fetch=function(e){var t=e.url,n=e.method,o=e.headers,r=e.body;return 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.focusNavbar=function(){return p({type:"FOCUS_NAVBAR"})},e.getAppMetadata=function(e){return p({type:"GET_APP_METADATA",payload:{appToken:e}})},e.getAttStatus=function(){return p({type:"GET_ATT_STATUS"}).catch(function(){return null})},e.getBatteryInfo=function(){return p({type:"GET_BATTERY_INFO"})},e.getDeviceModel=function(){return p({type:"MODEL"}).catch(function(){return null})},e.getDeviceTac=function(){return p({type:"TAC"}).catch(function(){return{tac:null}})},e.getDiskSpaceInfo=function(){return p({type:"GET_DISK_SPACE_INFO"})},e.getEsimInfo=function(){return p({type:"GET_ESIM_INFO"}).catch(function(){return{supportsEsim:!1,eid:null}})},e.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.getTopazValues=function(){return p({type:"GET_TOPAZ_VALUES",payload:{}})},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}),S({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:_(i),eventValue:a},u),s=e.category}return l=m(m({},l),{screenName:l.screenName||C}),S({onAndroid:function(e){return e.logEvent&&e.logEvent(s,JSON.stringify(l)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:s,parameters:l}),Promise.resolve()},onWeb:function(e){return new Promise(function(t){e("event",s,m(m({},l),{event_callback:A(t)}))})}})},e.logTiming=function(e){var t=e.category,n=void 0===t?"performance_timer":t,o=e.variable,r=e.value,i=e.label;if(!n||!o||!r)return console.warn('Analytics timing should have "category", "variable" and "value"',{category:n,variable:o,value:r}),Promise.resolve();var a={timingCategory:n,timingVar:o,timingValue:r=Math.round(r),timingLabel:i},u=n;return S({onAndroid:function(e){return e.logEvent&&e.logEvent(u,JSON.stringify(a)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:u,parameters:a}),Promise.resolve()},onWeb:function(){return new Promise(function(e){gtag("event",u,m(m({},a),{event_callback:A(e)}))})}})},e.logout=function(){return p({type:"LOG_OUT"})},e.nativeAlert=function(e){var t=e.message,n=e.title,o=e.buttonText;return d()?p({type:"ALERT",payload:{title:n,message:t,buttonText:o}}):("undefined"!=typeof window&&window.alert(t),Promise.resolve())},e.nativeConfirm=function(e){var t=e.message,n=e.title,o=e.acceptText,r=e.cancelText,i=e.destructive;return d()?p({type:"CONFIRM",payload:{message:t,title:n,acceptText:o,cancelText:r,destructive:i}}).then(function(e){return e.result}):Promise.resolve("undefined"!=typeof window&&window.confirm(t))},e.nativeMessage=function(e){var t=e.message,n=e.duration,o=e.buttonText,r=e.buttonAccessibilityLabel,i=e.type,a=e.withDismiss;return d()?p({type:"MESSAGE",payload:{message:t,duration:n,buttonText:o,buttonAccessibilityLabel:r,type:i,withDismiss:a}}).then(function(e){return e&&e.action?e:{action:"DISMISS"}}):("undefined"!=typeof window&&window.alert(t),Promise.resolve({action:"DISMISS"}))},e.notifyBridgeReady=function(){return p({type:"BRIDGE_READY"})},e.notifyPageLoaded=function(){return p({type:"PAGE_LOADED"})},e.onNativeEvent=function(e){return y("NATIVE_EVENT",function(t){return{action:e({event:t.event}).action||"default"}})},e.onNavigationBarIconClicked=function(e){return y("NAVIGATION_BAR_ICON_CLICKED",e)},e.onSessionRenewed=function(e){return y("SESSION_RENEWED",function(t){var n=t.accessToken;return e(n)})},e.openOnboarding=function(){return p({type:"OPEN_ONBOARDING"})},e.readTextFromClipboard=function(){return p({type:"CLIPBOARD_READ_TEXT"})},e.renewSession=function(e,t){return void 0===t&&(t={}),p({type:"RENEW_SESSION",payload:{accessToken:e||null}},t.timeout).then(function(e){return e.accessToken})},e.reportStatus=function(e){var t=e.feature,n=e.status,o=e.reason;return p({type:"STATUS_REPORT",payload:{feature:t,status:n,reason:o}})},e.requestContact=function(e){var t=(void 0===e?{}:e).filter;return p({type:"GET_CONTACT_DATA",payload:{filter:void 0===t?"phone":t}})},e.requestDeviceImei=function(){return p({type:"IMEI"},200).then(function(e){return e.imei}).catch(function(){return null})},e.requestSimIcc=function(){return p({type:"SIM_ICC"},200).then(function(e){return e.icc}).catch(function(){return null})},e.requestSimImsi=function(){return p({type:"IMSI"},200).then(function(e){return e.imsi}).catch(function(){return null})},e.requestVibration=function(e){return p({type:"VIBRATION",payload:{type:e}})},e.sanitizeAnalyticsParam=N,e.sanitizeAnalyticsParams=P,e.setActionBehavior=function(e){return p({type:"SET_ACTION_BEHAVIOR",payload:{actions:e}}).catch(function(){})},e.setLogger=function(e){f=e},e.setScreenName=function(e,t){if(void 0===t&&(t={}),!e)return console.warn("Missing analytics screenName"),Promise.resolve();var n=C;return C=e,S({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:A(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),S({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.shareBase64=function(e){return p({type:"SHARE_BASE64",payload:{content:e.contentInBase64,fileName:e.fileName}})},e.showAppRating=function(){return p({type:"SHOW_APP_RATING"})},e.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}})},e.writeTextToClipboard=function(e){return p({type:"CLIPBOARD_WRITE_TEXT",payload:e})},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).webviewBridge={})}(this,function(e){"use strict";var t=1,n="".concat(Date.now(),"-").concat(String(Math.random()).slice(-8)),o="__tuenti_webview_bridge",r=function(){return!("undefined"==typeof window||!window.tuentiWebView||!window.tuentiWebView.postMessage)},i=function(){return!!("undefined"!=typeof window&&window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.tuentiWebView&&window.webkit.messageHandlers.tuentiWebView.postMessage)},a=function(){return"undefined"==typeof window?null:r()?function(e){window.tuentiWebView.postMessage(e)}:i()?function(e){window.webkit.messageHandlers.tuentiWebView.postMessage(e)}:null},u=[],c=function(e){u.push(e)},s=function(e){u=u.filter(function(t){return t!==e})},l=function(){var e;return"undefined"!=typeof window&&(!!function(){try{return window.self!==window.top}catch(e){return!0}}()&&!(null===(e=null===window||void 0===window?void 0:window.frameElement)||void 0===e?void 0:e.hasAttribute("data-enable-webview-bridge")))},d=void 0,f=function(){return!l()&&(r()||i())},p=function(e,o){var r=e.type,i=e.id,u=void 0===i?"web-".concat(t++,"-").concat(n):i,l=e.payload,f=a(),p=JSON.stringify({type:r,id:u,payload:l});return null===d||void 0===d||d("[WebView Bridge] SEND:",p),f?(setTimeout(function(){f(p)}),new Promise(function(e,t){var n=!1,i=function(o){o.id!==u||n||(o.type===r?e(o.payload):"ERROR"===o.type?t(o.payload):t({code:500,reason:"bad type: ".concat(o.type,". Expecting ").concat(r)}),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===d||void 0===d||d("[WebView Bridge] RCVD:",e);try{t=JSON.parse(e)}catch(t){throw Error("Problem parsing webview message: ".concat(e))}u.forEach(function(e){return e(t)})}});var y=function(e,t){var n=function(n){n.type===e&&Promise.resolve(t(n.payload)).then(function(e){var t=a();t&&t(JSON.stringify({type:n.type,id:n.id,payload:e}))})};return 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}var g=function(e){return f()?p({type:"NAVIGATION_BAR",payload:e}):(void 0!==e.title&&"undefined"!=typeof document&&(document.title=e.title),Promise.resolve())},T=null,w=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])},b=function(e){return Math.floor(e/1e3)},E=0,I=function(e){var t=setTimeout(function(){e(),E++},500);return function(){clearTimeout(t),E=0,e()}},A=function(e){var t=e.onAndroid,n=e.onIos,o=e.onWeb;return"undefined"==typeof window?Promise.resolve():window.AnalyticsWebInterface?t(window.AnalyticsWebInterface):window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers.firebase?n(window.webkit.messageHandlers.firebase):window.gtag&&E<3?o(window.gtag):Promise.resolve()},h=function(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"")},_=function(e){return h(e).toLocaleLowerCase().replace(/[^a-zß0-9\s\-\_\/\|\:]/g,"").replace(/\s+/g," ").trim().replace(/\s/g,"_").slice(0,100)},N=function(e){var t={};return Object.entries(e).forEach(function(e){var n=e[0],o=e[1],r=o,i=n.slice(0,40);"string"==typeof o&&(r=_(o)),t[i]=r}),t},S={sanitize:!0},O="",P=!1,R=function(e){if(P)return Promise.reject({code:423,reason:"BottomSheet is locked. You can only have one bottom sheet in the screen"});P=!0;var t=setTimeout(function(){P=!1},1e3);return p({type:"SHEET",payload:e}).then(function(e){return P=!1,clearTimeout(t),e}).catch(function(e){throw P=!1,clearTimeout(t),e})};e.CD_EVENT_VALUE=8,e.CD_NOVUM_UID=7,e.CD_WEBAPP_INSTALLED=4,e.attachToEmail=function(e){var t=e.url,n=e.subject,o=e.fileName,r=e.recipient,i=e.body;return p({type:"ATTACH_TO_EMAIL",payload:{url:t,subject:n,fileName:o,recipient:r,body:i}})},e.bottomSheet=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 R({title:t,subtitle:n,description:o,content:[{type:"LIST",id:"list-0",listType:"INFORMATIVE",autoSubmit:!1,selectedIds:[],items:r}]}).then(function(){})},e.bottomSheetSingleSelector=function(e){var t=e.title,n=e.subtitle,o=e.description,r=e.selectedId,i=e.items;return 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:b(t),endTime:b(n),title:o}})},e.dismiss=function(e){return p({type:"DISMISS",payload:{onCompletionUrl:e}})},e.downloadBase64=function(e){return p({type:"DOWNLOAD_BASE64",payload:{content:e.contentInBase64,fileName:e.fileName}})},e.fetch=function(e){var t=e.url,n=e.method,o=e.headers,r=e.body;return p({type:"FETCH",payload:{url:t,method:n,headers:o,body:r}}).catch(function(){return{status:500,headers:{},body:"Bridge call failed"}})},e.fetchContactsByPhone=function(e){return p({type:"FETCH_CONTACTS_DATA",payload:{phoneNumbers:e}})},e.fetchPhoneNumbers=function(){return p({type:"FETCH_PHONE_NUMBERS"})},e.focusNavbar=function(){return p({type:"FOCUS_NAVBAR"})},e.getAppMetadata=function(e){return p({type:"GET_APP_METADATA",payload:{appToken:e}})},e.getAttStatus=function(){return p({type:"GET_ATT_STATUS"}).catch(function(){return null})},e.getBatteryInfo=function(){return p({type:"GET_BATTERY_INFO"})},e.getDeviceModel=function(){return p({type:"MODEL"}).catch(function(){return null})},e.getDeviceTac=function(){return p({type:"TAC"}).catch(function(){return{tac:null}})},e.getDiskSpaceInfo=function(){return p({type:"GET_DISK_SPACE_INFO"})},e.getEsimInfo=function(){return p({type:"GET_ESIM_INFO"}).catch(function(){return{supportsEsim:!1,eid:null}})},e.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=w,e.getTopazToken=function(e){return void 0===e&&(e={}),p({type:"GET_TOPAZ_TOKEN",payload:{}},e.timeout)},e.getTopazValues=function(){return p({type:"GET_TOPAZ_VALUES",payload:{}})},e.hideLoadingOverlay=function(){return p({type:"HIDE_LOADING_OVERLAY"})},e.highlightNavigationTab=function(e){var t=e.tab,n=e.highlight,o=e.count;return p({type:"HIGHLIGHT_TAB",payload:{tab:t,highlight:n,count:o}})},e.internalNavigation=function(e){return p({type:"INTERNAL_NAVIGATION",payload:{feature:e}})},e.isABTestingAvailable=function(e){return w().then(function(){return function(e){return"true"===T.result[e]}(e)}).catch(function(){return!1})},e.isWebViewBridgeAvailable=f,e.logEcommerceEvent=function(e,t){return t=m(m({},t),{screenName:t.screenName||O}),A({onAndroid:function(n){return n.logEvent&&n.logEvent(e,JSON.stringify(t)),Promise.resolve()},onIos:function(n){return n.postMessage({command:"logEvent",name:e,parameters:t}),Promise.resolve()},onWeb:function(){return Promise.resolve()}})},e.logEvent=function(e,t){var n,o,r,i,a,u,c=m(m({},S),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=N(l),s=_(s));else{if(!e.category||!e.action)return console.warn('LegacyAnalyticsEvent should have "category" and "action"',{category:e.category,action:e.action}),Promise.resolve();o=(n=e).category,r=n.action,i=n.label,a=n.value,u=v(n,["category","action","label","value"]),i||(i="null_label"),a||(a=0),l=m({eventCategory:o,eventAction:r,eventLabel:h(i),eventValue:a},u),s=e.category}return l=m(m({},l),{screenName:l.screenName||O}),A({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 A({onAndroid:function(e){return e.logEvent&&e.logEvent(u,JSON.stringify(a)),Promise.resolve()},onIos:function(e){return e.postMessage({command:"logEvent",name:u,parameters:a}),Promise.resolve()},onWeb:function(){return new Promise(function(e){gtag("event",u,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 f()?p({type:"ALERT",payload:{title:n,message:t,buttonText:o}}):("undefined"!=typeof window&&window.alert(t),Promise.resolve())},e.nativeConfirm=function(e){var t=e.message,n=e.title,o=e.acceptText,r=e.cancelText,i=e.destructive;return f()?p({type:"CONFIRM",payload:{message:t,title:n,acceptText:o,cancelText:r,destructive:i}}).then(function(e){return e.result}):Promise.resolve("undefined"!=typeof window&&window.confirm(t))},e.nativeMessage=function(e){var t=e.message,n=e.duration,o=e.buttonText,r=e.buttonAccessibilityLabel,i=e.type,a=e.withDismiss;return f()?p({type:"MESSAGE",payload:{message:t,duration:n,buttonText:o,buttonAccessibilityLabel:r,type:i,withDismiss:a}}).then(function(e){return e&&e.action?e:{action:"DISMISS"}}):("undefined"!=typeof window&&window.alert(t),Promise.resolve({action:"DISMISS"}))},e.notifyBridgeReady=function(){return p({type:"BRIDGE_READY"})},e.notifyPageLoaded=function(){return p({type:"PAGE_LOADED"})},e.onNativeEvent=function(e){return y("NATIVE_EVENT",function(t){return{action:e({event:t.event}).action||"default"}})},e.onNavigationBarIconClicked=function(e){return y("NAVIGATION_BAR_ICON_CLICKED",e)},e.onSessionRenewed=function(e){return y("SESSION_RENEWED",function(t){return e(t.accessToken)})},e.openOnboarding=function(){return p({type:"OPEN_ONBOARDING"})},e.readTextFromClipboard=function(){var e;return((null===(e=navigator.clipboard)||void 0===e?void 0:e.readText)?navigator.clipboard.readText():Promise.reject()).catch(function(){return p({type:"CLIPBOARD_READ_TEXT"})})},e.renewSession=function(e,t){return void 0===t&&(t={}),p({type:"RENEW_SESSION",payload:{accessToken:e||null}},t.timeout).then(function(e){return e.accessToken})},e.reportStatus=function(e){var t=e.feature,n=e.status,o=e.reason;return p({type:"STATUS_REPORT",payload:{feature:t,status:n,reason:o}})},e.requestContact=function(e){var t=(void 0===e?{}:e).filter;return p({type:"GET_CONTACT_DATA",payload:{filter:void 0===t?"phone":t}})},e.requestDeviceImei=function(){return p({type:"IMEI"},200).then(function(e){return e.imei}).catch(function(){return null})},e.requestSimIcc=function(){return p({type:"SIM_ICC"},200).then(function(e){return e.icc}).catch(function(){return null})},e.requestSimImsi=function(){return p({type:"IMSI"},200).then(function(e){return e.imsi}).catch(function(){return null})},e.requestVibration=function(e){return p({type:"VIBRATION",payload:{type:e}})},e.sanitizeAnalyticsParam=_,e.sanitizeAnalyticsParams=N,e.setActionBehavior=function(e){return p({type:"SET_ACTION_BEHAVIOR",payload:{actions:e}}).catch(function(){})},e.setLogger=function(e){d=e},e.setScreenName=function(e,t){if(void 0===t&&(t={}),!e)return console.warn("Missing analytics screenName"),Promise.resolve();var n=O;return O=e,A({onAndroid:function(n){return n.setScreenNameWithParams?n.setScreenNameWithParams(e,JSON.stringify(N(t))):n.setScreenName&&n.setScreenName(e),Promise.resolve()},onIos:function(n){return n.postMessage({command:"setScreenName",name:e,parameters:N(t)}),Promise.resolve()},onWeb:function(o){return new Promise(function(r){o("event","page_view",m(m({screenName:e,page_title:e,previousScreenName:n},N(t)),{event_callback:I(r)}))})}})},e.setTrackingProperty=function(e,t,n){return p({type:"SET_TRACKING_PROPERTY",payload:{system:e,name:t,value:n}}).catch(function(){})},e.setUserProperty=function(e,t){return e&&t?(t=String(t),A({onAndroid:function(n){return n.setUserProperty&&n.setUserProperty(e,t),Promise.resolve()},onIos:function(n){return n.postMessage({command:"setUserProperty",name:e,value:t}),Promise.resolve()},onWeb:function(n){var o;return n("set","user_properties",((o={})[e]=_(t),o)),Promise.resolve()}})):(console.warn("Trying to set analytics user property without name or value",e,t),Promise.resolve())},e.setWebViewTitle=function(e){return f()?g({title:e}):("undefined"!=typeof document&&(document.title=e),Promise.resolve())},e.share=function(e){return p({type:"SHARE",payload:e})},e.shareBase64=function(e){return p({type:"SHARE_BASE64",payload:{content:e.contentInBase64,fileName:e.fileName}})},e.showAppRating=function(){return p({type:"SHOW_APP_RATING"})},e.showLoadingOverlay=function(e){return p({type:"SHOW_LOADING_OVERLAY",payload:e})},e.startProfileImageFlow=function(){return p({type:"START_PROFILE_IMAGE_FLOW"})},e.triggerPinOrBiometricAuthentication=function(e){return p({type:"TRIGGER_PIN_OR_BIOMETRIC_AUTHENTICATION",payload:{maxSecondsSinceLastValidation:e}})},e.updateNavigationBar=g,e.updatePhoneNumbers=function(e){return p({type:"UPDATE_PHONE_NUMBERS",payload:{phoneNumbers:e}})},e.writeTextToClipboard=function(e){var t;return((null===(t=navigator.clipboard)||void 0===t?void 0:t.writeText)?navigator.clipboard.writeText(e):Promise.reject()).catch(function(){return p({type:"CLIPBOARD_WRITE_TEXT",payload:e})})},Object.defineProperty(e,"__esModule",{value:!0})}); |
{ | ||
"name": "@tef-novum/webview-bridge", | ||
"version": "3.41.0", | ||
"version": "3.43.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", |
@@ -1260,2 +1260,66 @@ <p align="center"> | ||
### showLoadingOverlay / hideLoadingOverlay | ||
<kbd>App version >=24.10</kbd> | ||
Shows a loading overlay screen while a task is being performed. You can control | ||
when to hide it with the `hideLoadingOverlay` method. | ||
```ts | ||
showLoadingOverlay: ({ | ||
/** | ||
* Whether the in animation is enabled (false by default) | ||
*/ | ||
inAnimation?: boolean; | ||
/** | ||
* Whether the out animation is enabled (false by default) | ||
*/ | ||
outAnimation?: boolean; | ||
/** | ||
* Minimum duration of the loop animation in milliseconds (0 by default) | ||
*/ | ||
minimumLoopDurationMs?: number; | ||
/** | ||
* whether the loop animation should be stopped immediately or not (true by default) | ||
*/ | ||
stopAnimationCycle?: boolean; | ||
/** | ||
* Whether the background animation is enabled (false by default) | ||
*/ | ||
backgroundAnimation?: boolean; | ||
/** | ||
* List of description texts to be shown one after the other | ||
*/ | ||
descriptions?: Array<string>; | ||
/** | ||
* Duration of each description in milliseconds (3000 by default) | ||
*/ | ||
descriptionDurationMs?: number; | ||
/** | ||
* After this timeout loading screen would be hidden automatically (20000 by default) | ||
*/ | ||
timeoutMs?: number; | ||
/** | ||
* (Only Android) If true, after loading screen has been hidden, if user presses android back button, webview window will close (true by default) | ||
*/ | ||
closeOnBackButtonPressAfterFinish?: boolean; | ||
}) => Promise<void>; | ||
hideLoadingOverlay: () => Promise<void>; | ||
``` | ||
#### Example | ||
```ts | ||
await showLoadingOverlay({ | ||
inAnimation: true, | ||
outAnimation: true, | ||
stopAnimationCycle: false, | ||
descriptions: ['Loading...', 'Please wait...'], | ||
descriptionDurationMs: 3000, | ||
}); | ||
await doExpensiveTask(); | ||
await hideLoadingOverlay(); | ||
``` | ||
## Error handling | ||
@@ -1262,0 +1326,0 @@ |
Sorry, the diff of this file is not supported yet
1344
312741
6494