How to use the cross-domain-utils/src.matchDomain 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 / zoid / src / parent / index.js View on Github external
getPropsForChild(domain : string | RegExp) : (PropsType<p>) {
        const result = {};

        for (const key of Object.keys(this.props)) {
            const prop = this.component.getPropDefinition(key);

            if (prop &amp;&amp; prop.sendToChild === false) {
                continue;
            }

            if (prop &amp;&amp; prop.sameDomain &amp;&amp; !matchDomain(domain, getDomain(window))) {
                continue;
            }
            
            result[key] = this.props[key];
        }

        // $FlowFixMe
        return result;
    }
</p>
github krakenjs / zoid / dist / module / component / parent / index.js View on Github external
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);
        }
    };
github krakenjs / zoid / src / component / component.js View on Github external
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 } }`);
        }
    }
github krakenjs / post-robot / dist / module / public / client.js View on Github external
}).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;
github krakenjs / zoid / src / child / index.js View on Github external
checkParentDomain(domain : string) {
        if (!matchDomain(this.component.allowedParentDomains, domain)) {
            throw new Error(`Can not be rendered by domain: ${ domain }`);
        }
    }
github krakenjs / post-robot / src / public / send.js View on Github external
}).then(normalizedDomain => {
        if (!matchDomain(targetDomain, targetDomain)) {
            throw new Error(`Domain ${ stringify(targetDomain) } does not match ${ stringify(targetDomain) }`);
        }

        return normalizedDomain;
    });
}
github krakenjs / zoid / src / component / parent / index.js View on Github external
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 }`);
        }
    }
github krakenjs / zoid / dist / module / component / child / index.js View on Github external
ChildComponent.prototype.checkParentDomain = function checkParentDomain(domain) {
        if (!matchDomain(this.component.allowedParentDomains, domain)) {
            throw new Error('Can not be rendered by domain: ' + domain);
        }
    };