Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Component.prototype.getInitialDomain = function getInitialDomain(props) {
if (typeof this.domain === 'string') {
// $FlowFixMe
return this.domain;
}
var env = props.env || this.defaultEnv;
// $FlowFixMe
if (env && _typeof(this.domain) === 'object' && !isRegex(this.domain) && this.domain[env]) {
return this.domain[env];
}
return getDomainFromUrl(this.getUrl(props));
};
getChildDomain(props : PropsType<p>) : string {
if (this.domain && typeof this.domain === 'string') {
return this.domain;
}
return getDomainFromUrl(this.getUrl(props));
}
</p>
export function getBridgeName(domain : string) : string {
domain = domain || getDomainFromUrl(domain);
const sanitizedDomain = domain.replace(/[^a-zA-Z0-9]+/g, '_');
const id = `${ BRIDGE_NAME_PREFIX }_${ sanitizedDomain }`;
return id;
}
tasks.openBridge = ZalgoPromise.all([ tasks.open, tasks.buildUrl ]).then(([ proxyWin, url ]) => {
return this.openBridge(proxyWin, getDomainFromUrl(url), context);
});
export function openBridge(url : string, domain : string) : ZalgoPromise {
const bridges = globalStore('bridges');
const bridgeFrames = globalStore('bridgeFrames');
domain = domain || getDomainFromUrl(url);
return bridges.getOrSet(domain, () => ZalgoPromise.try(() => {
if (getDomain() === domain) {
throw new Error(`Can not open bridge on the same domain as current domain: ${ domain }`);
}
const name = getBridgeName(domain);
const frame = getFrameByName(window, name);
if (frame) {
throw new Error(`Frame with name ${ name } already exists on page`);
}
const iframe = openBridgeFrame(name, url);
bridgeFrames.set(domain, iframe);
export function hasBridge(url : string, domain : string) : boolean {
const bridges = globalStore('bridges');
return bridges.has(domain || getDomainFromUrl(url));
}
}).then(function (win) {
if (!bridge || !bridge.needsBridge({ win: win, domain: domain }) || bridge.hasBridge(domain, domain)) {
return;
}
var bridgeUrl = _this7.component.getBridgeUrl(_this7.props);
if (!bridgeUrl) {
throw new Error('Bridge url and domain needed to render ' + context);
}
var bridgeDomain = getDomainFromUrl(bridgeUrl);
bridge.linkUrl(win, domain);
return bridge.openBridge(bridgeUrl, bridgeDomain);
});
};
export function needsBridgeForDomain(domain : ?string, win : ?CrossDomainWindowType) : boolean {
if (domain) {
if (getDomain() !== getDomainFromUrl(domain)) {
return true;
}
} else if (win) {
if (!isSameDomain(win)) {
return true;
}
}
return false;
}
export function linkUrl(win : CrossDomainWindowType, url : string) {
linkWindow({ win, domain: getDomainFromUrl(url) });
}