How to use the cross-domain-utils/src.getAncestor 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 paypal / paypal-checkout-components / src / api / rest.js View on Github external
});

    }).then(({ body }) : string => {

        logOrderResponse(body.id);

        if (body && body.id) {
            return body.id;
        }

        throw new Error(`Order Api response error:\n\n${ JSON.stringify(body, null, 4) }`);
    });
}

const PROXY_REST = `proxy_rest`;
const parentWin = getAncestor();

on(PROXY_REST, { domain: getPayPalDomain() }, ({ data }) => {
    proxyRest = data;
});

if (parentWin && isPayPalDomain() && !isSameDomain(parentWin)) {
    send(parentWin, PROXY_REST, { createAccessToken, createOrder })
        .catch(() => {
            // pass
        });
}
github krakenjs / zoid / dist / module / component / child / index.js View on Github external
// $FlowFixMe
            var distance = ref.distance;


            if (distance) {
                result = getNthParentFromTop(window, distance);
            } else {
                result = getParent(window);
            }
        }

        if (type === WINDOW_REFERENCES.GLOBAL) {
            // $FlowFixMe
            var uid = ref.uid;

            var ancestor = getAncestor(window);

            if (ancestor) {
                for (var _i2 = 0, _getAllFramesInWindow2 = getAllFramesInWindow(ancestor), _length2 = _getAllFramesInWindow2 == null ? 0 : _getAllFramesInWindow2.length; _i2 < _length2; _i2++) {
                    var frame = _getAllFramesInWindow2[_i2];
                    var global = globalFor(frame);

                    if (global && global.windows && global.windows[uid]) {
                        result = global.windows[uid];
                        break;
                    }
                }
            }
        }

        if (!result) {
            throw new Error('Unable to find ' + type + ' window');
github krakenjs / post-robot / src / lib / hello.js View on Github external
return globalStore('builtinListeners').getOrSet('helloListener', () => {
        const listener = listenForHello({ on });

        const parent = getAncestor();
        if (parent) {
            sayHello(parent, { send }).catch(noop);
        }

        return listener;
    });
}
github krakenjs / zoid / src / child / index.js View on Github external
getParentComponentWindow(ref : WindowRef) : CrossDomainWindowType {
        const { type } = ref;
    
        if (type === WINDOW_REFERENCES.OPENER) {
            return assertExists('opener', getOpener(window));
    
        } else if (type === WINDOW_REFERENCES.PARENT && typeof ref.distance === 'number') {
            return assertExists('parent', getNthParentFromTop(window, ref.distance));

        } else if (type === WINDOW_REFERENCES.GLOBAL && ref.uid && typeof ref.uid === 'string') {
            const { uid } = ref;
            const ancestor = getAncestor(window);

            if (!ancestor) {
                throw new Error(`Can not find ancestor window`);
            }

            for (const frame of getAllFramesInWindow(ancestor)) {
                if (isSameDomain(frame)) {
                    const global = getGlobal(frame);

                    if (global && global.windows && global.windows[uid]) {
                        return global.windows[uid];
                    }
                }
            }
        }
github krakenjs / post-robot / src / public / client.js View on Github external
export function sendToParent(name : string, data : ?Object, options : ?RequestOptionsType) : ZalgoPromise {

    let win = getAncestor();

    if (!win) {
        return new ZalgoPromise((resolve, reject) => reject(new Error('Window does not have a parent')));
    }

    return send(win, name, data, options);
}
github krakenjs / post-robot / dist / module / public / client.js View on Github external
export function sendToParent(name, data, options) {

    var win = getAncestor();

    if (!win) {
        return new ZalgoPromise(function (resolve, reject) {
            return reject(new Error('Window does not have a parent'));
        });
    }

    return _send(win, name, data, options);
}
github krakenjs / post-robot / dist / module / lib / ready.js View on Github external
export function initOnReady() {

    onHello(function (_ref3) {
        var source = _ref3.source,
            origin = _ref3.origin;

        var promise = global.readyPromises.get(source) || new ZalgoPromise();
        promise.resolve({ origin: origin });
        global.readyPromises.set(source, promise);
    });

    var parent = getAncestor();
    if (parent) {
        sayHello(parent)['catch'](noop);
    }
}