Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getPropsForChild(domain : string | RegExp) : (PropsType<p>) {
const result = {};
for (const key of Object.keys(this.props)) {
const prop = this.component.getPropDefinition(key);
if (prop && prop.sendToChild === false) {
continue;
}
if (prop && prop.sameDomain && !matchDomain(domain, getDomain(window))) {
continue;
}
result[key] = this.props[key];
}
// $FlowFixMe
return result;
}
</p>
ParentComponent.prototype.checkAllowRemoteRender = function checkAllowRemoteRender(target) {
if (!target) {
throw this.component.createError('Must pass window to renderTo');
}
if (!isSameTopWindow(window, target)) {
throw new Error('Can only renderTo an adjacent frame');
}
var origin = getDomain();
var domain = this.getDomain();
if (!matchDomain(domain, origin) && !isSameDomain(target)) {
throw new Error('Can not render remotely to ' + domain.toString() + ' - can only render to ' + origin);
}
};
checkAllowRender(target : CrossDomainWindowType, domain : string | RegExp, container : string | HTMLElement) {
if (target === window) {
return;
}
if (!isSameTopWindow(window, target)) {
throw new Error(`Can only renderTo an adjacent frame`);
}
const origin = getDomain();
if (!matchDomain(domain, origin) && !isSameDomain(target)) {
throw new Error(`Can not render remotely to ${ domain.toString() } - can only render to ${ origin }`);
}
if (container && typeof container !== 'string') {
throw new Error(`Container passed to renderTo must be a string selector, got ${ typeof container } }`);
}
}
}).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) {
var responseListener = void 0;
checkParentDomain(domain : string) {
if (!matchDomain(this.component.allowedParentDomains, domain)) {
throw new Error(`Can not be rendered by domain: ${ domain }`);
}
}
}).then(normalizedDomain => {
if (!matchDomain(targetDomain, targetDomain)) {
throw new Error(`Domain ${ stringify(targetDomain) } does not match ${ stringify(targetDomain) }`);
}
return normalizedDomain;
});
}
checkAllowRemoteRender(target : CrossDomainWindowType) {
if (!target) {
throw this.component.createError(`Must pass window to renderTo`);
}
if (!isSameTopWindow(window, target)) {
throw new Error(`Can only renderTo an adjacent frame`);
}
let origin = getDomain();
let domain = this.getDomain();
if (!matchDomain(domain, origin) && !isSameDomain(target)) {
throw new Error(`Can not render remotely to ${ domain.toString() } - can only render to ${ origin }`);
}
}
ChildComponent.prototype.checkParentDomain = function checkParentDomain(domain) {
if (!matchDomain(this.component.allowedParentDomains, domain)) {
throw new Error('Can not be rendered by domain: ' + domain);
}
};