How to use the cross-domain-utils/src.PROTOCOL function in cross-domain-utils

To help you get started, we’ve selected a few cross-domain-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github krakenjs / post-robot / dist / module / drivers / send / strategies.js View on Github external
throw new Error(`Attempting to send messsage to mock domain ${dom}, but window is actually cross-domain`);
        } // $FlowFixMe


        const windowDomain = (0, _src.getDomain)(win);

        if (windowDomain !== dom) {
          throw new Error(`Mock domain target ${dom} does not match window domain ${windowDomain}`);
        } // $FlowFixMe


        return (0, _src.getActualDomain)(win);
      }
    }

    if (dom.indexOf(_src.PROTOCOL.FILE) === 0) {
      return _conf.WILDCARD;
    }

    return dom;
  });
  domains.forEach(dom => {
github krakenjs / post-robot / dist / module / drivers / send / strategies.js View on Github external
domains = domains.map(dom => {
    if (__TEST__) {
      if (dom.indexOf(_src.PROTOCOL.MOCK) === 0) {
        if (window.location.protocol === _src.PROTOCOL.FILE) {
          return _conf.WILDCARD;
        }

        if (!(0, _src.isActuallySameDomain)(win)) {
          throw new Error(`Attempting to send messsage to mock domain ${dom}, but window is actually cross-domain`);
        } // $FlowFixMe


        const windowDomain = (0, _src.getDomain)(win);

        if (windowDomain !== dom) {
          throw new Error(`Mock domain target ${dom} does not match window domain ${windowDomain}`);
        } // $FlowFixMe


        return (0, _src.getActualDomain)(win);
github krakenjs / post-robot / dist / module / drivers / receive / index.js View on Github external
}

  (0, _lib.markWindowKnown)(source);

  if (receivedMessages.has(message.id)) {
    return;
  }

  receivedMessages.set(message.id, true);

  if ((0, _src.isWindowClosed)(source) && !message.fireAndForget) {
    return;
  }

  if (message.origin.indexOf(_src.PROTOCOL.FILE) === 0) {
    origin = `${_src.PROTOCOL.FILE}//`;
  }

  _types.RECEIVE_MESSAGE_TYPES[message.type](source, origin, message, {
    on,
    send
  });
}
github krakenjs / post-robot / dist / module / drivers / receive / index.js View on Github external
function messageListener(event, {
  on,
  send
}) {
  try {
    (0, _src2.noop)(event.source);
  } catch (err) {
    return;
  }

  const source = event.source || event.sourceElement;
  let origin = event.origin || event.originalEvent && event.originalEvent.origin;
  const data = event.data;

  if (origin === 'null') {
    origin = `${_src.PROTOCOL.FILE}//`;
  }

  if (!source) {
    return;
  }

  if (!origin) {
    throw new Error(`Post message did not have origin domain`);
  }

  if (__TEST__) {
    if ((0, _lib.needsGlobalMessagingForBrowser)() && (0, _src.isSameTopWindow)(source, window) === false) {
      return;
    }
  }