Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getDomain(props : BuiltInPropsType & P) : string | RegExp {
if (isRegex(this.domain)) {
// $FlowFixMe
return this.domain;
}
return this.getInitialDomain(props);
}
getInitialDomain(props : BuiltInPropsType & P) : string {
if (typeof this.domain === 'string') {
// $FlowFixMe
return this.domain;
}
let 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));
}
Component.prototype.getDomain = function getDomain(props) {
if (isRegex(this.domain)) {
// $FlowFixMe
return this.domain;
}
return this.getInitialDomain(props);
};
return ZalgoPromise.try(() => {
if (!matchDomain(domain, origin)) {
// $FlowFixMe
throw new Error(`Method '${ data.name }' domain ${ JSON.stringify(isRegex(meth.domain) ? meth.domain.source : meth.domain) } does not match origin ${ origin } in ${ getDomain(window) }`);
}
if (ProxyWindow.isProxyWindow(methodSource)) {
// $FlowFixMe
return methodSource.matchWindow(source, { send }).then(match => {
if (!match) {
throw new Error(`Method call '${ data.name }' failed - proxy window does not match source in ${ getDomain(window) }`);
}
});
}
}).then(() => {
return val.apply({ source, origin }, data.args);
}).then(({ domain: origin } = {}) => {
if (isRegex(domain)) {
if (!matchDomain(domain, origin)) {
throw new Error(`Remote window domain ${ origin } does not match regex: ${ domain.toString() }`);
}
domain = origin;
}
if (typeof domain !== 'string' && !Array.isArray(domain)) {
throw new TypeError(`Expected domain to be a string or array`);
}
const actualDomain = domain;
const logName = (name === MESSAGE_NAME.METHOD && options.data && typeof options.data.name === 'string') ? `${ options.data.name }()` : name;
return new ZalgoPromise((resolve, reject) => {
} else if (domain) {
throw new Error(`Request listener already exists for ${ name } on domain ${ domain.toString() }`);
} else {
throw new Error(`Request listener already exists for ${ name }`);
}
}
const nameListeners = requestListeners.getOrSet(win, () => ({}));
const domainListeners = getOrSet(nameListeners, name, () => ({}));
const strDomain = domain.toString();
let regexListeners;
let regexListener;
if (isRegex(domain)) {
regexListeners = getOrSet(domainListeners, __DOMAIN_REGEX__, () => []);
regexListener = { regex: domain, listener };
regexListeners.push(regexListener);
} else {
domainListeners[strDomain] = listener;
}
return {
cancel() {
delete domainListeners[strDomain];
if (regexListener) {
regexListeners.splice(regexListeners.indexOf(regexListener, 1));
if (!regexListeners.length) {
delete domainListeners[__DOMAIN_REGEX__];
}).then(function () {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
origin = _ref.domain;
if (isRegex(domain) && !origin) {
return sayHello(win);
}
}).then(function () {
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
}).then(({ domain: origin } = {}) => {
if (isRegex(domain) && !origin) {
return sayHello(win);
}
}).then(({ domain: origin } = {}) => {
}).then(function () {
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
origin = _ref2.domain;
if (isRegex(domain)) {
if (!matchDomain(domain, origin)) {
throw new Error('Remote window domain ' + origin + ' does not match regex: ' + domain.toString());
}
domain = origin;
}
if (typeof domain !== 'string' && !Array.isArray(domain)) {
throw new TypeError('Expected domain to be a string or array');
}
var actualDomain = domain;
var logName = name === MESSAGE_NAME.METHOD && options.data && typeof options.data.name === 'string' ? options.data.name + '()' : name;
return new ZalgoPromise(function (resolve, reject) {