lpw
12 hours ago 49b5f8ec0881daeb9c8bc62822a7e59e4e63e58d
frameworks/Didomi.xcframework/xros-arm64/Didomi.framework/web_sdk_utilities.js
@@ -1,10 +1,15 @@
/** Script allowing to use the Web SDK from a WebView */
// Check if notice was initially displayed
var noticeReady = false;
/**
 * Initialize the SDK with the specified configuration
 */
function initSdk(config, gvl, sdkURL, languageCode) {
function initSdk(config, gvl, sdkURL, languageCode, isUnderage) {
  if (config) {
    // Set the global window configuration to the config object
    window.didomiConfig = prepareConfigFromMobile(config, languageCode);
    window.didomiConfig = prepareConfigFromMobile(config, languageCode, isUnderage);
    // If app, vendors, and iab exist, set the vendorList property
    if (
@@ -57,9 +62,11 @@
/**
 * Open the notice screen
 */
function openNotice(options) {
function openNotice(userStatus, options) {
  handleWebSDKEvents();
  window.didomiOnReady = window.didomiOnReady || [];
  window.didomiOnReady.push(function (Didomi) {
    Didomi.setUserStatus(userStatus);
    if (options != null && options.deepLinkView != null) {
      Didomi.preferences.show(
        options.deepLinkView == 0 ? "purposes" : "vendors"
@@ -67,8 +74,14 @@
    } else {
      Didomi.notice.show();
    }
    noticeReady = true;
  });
}
/**
 * Listen to SDK events
 */
function handleWebSDKEvents() {
  window.didomiEventListeners = window.didomiEventListeners || [];
  // TODO: Handle all iOS events
  window.didomiEventListeners.push(
@@ -140,12 +153,12 @@
    {
      event: 'notice.hidden',
      listener: function () {
          if (noticeReady && !Didomi.preferences.isVisible()) {
        if (isIOS()) {
          if (Didomi.notice.isVisible()) {
            window.webkit.messageHandlers.noticeHidden.postMessage();
          }
              window.webkit.messageHandlers.noticeHidden.postMessage("");
        } else {
          androidInterface.onNoticeHidden();
            }
        }
      }
    },
@@ -398,16 +411,14 @@
}
/**
 * Fix unescaped quotes and html tags.
 * Fix unescaped quotes.
 * @param {string} text
 * @returns the sanitized text
 */
function sanitizeText(text) {
  return text
    // Escape unescaped quotes
    .replace(/(?<!\\)(['"])/g, '\$1')
    // Remove html tags
    .replace(/[<>]/g, '');
    .replace(/(?<!\\)(['"])/g, '\$1');
}
/**
@@ -483,9 +494,10 @@
 * Prepare config file to be consumed by the Web SDK, by disabling the features already handled by Mobile SDKs.
 * @param {*} configFromMobile Config provided by mobile.
 * @param {string} languageCode language code to be set in the Config.
 * @param {boolean} isUnderage whether the notice should be underage or not.
 * @returns Config with unneeded features disabled
 */
function prepareConfigFromMobile(configFromMobile, languageCode) {
function prepareConfigFromMobile(configFromMobile, languageCode, isUnderage) {
  if (configFromMobile == null) {
    return null;
  }
@@ -504,10 +516,24 @@
    configFromMobile.app.consentString.signatureEnabled = false;
  }
  // Ignore daysBeforeShowingAgain as this is already handled by the mobile SDKs.
  if (configFromMobile.notice) {
    delete configFromMobile.notice.daysBeforeShowingAgain;
  }
  if (languageCode) {
    if (languageCode == "pt-PT") {
      // Temporary workaround for https://didomi.atlassian.net/browse/CMP-5552
      languageCode = "pt";
    }
    configFromMobile.languages = { enabled: [languageCode], default: languageCode };
  }
  if (isUnderage) {
    configFromMobile.user = configFromMobile.user || {};
    configFromMobile.user.isUnderage = isUnderage;
  }
  return configFromMobile;
}