Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const setupPrerenderTask = initPromise.then(() => {
return ZalgoPromise.hash({ prerenderDetails: getPrerenderDetails(), initPromise }).then(({ prerenderDetails }) => {
if (!prerenderDetails) {
return;
}
const { win, fundingSource, card } = prerenderDetails;
const button = document.querySelector(`[${ DATA_ATTRIBUTES.FUNDING_SOURCE }=${ fundingSource }]`);
if (!button) {
throw new Error(`Can not find button element`);
}
const payment = { win, button, fundingSource, card };
const payPromise = initiatePayment({ payment });
// $FlowFixMe
button.payPromise = payPromise;
focus() : ZalgoPromise {
const isPopupPromise = this.isPopup();
const getNamePromise = this.getName();
const reopenPromise = ZalgoPromise.hash({ isPopup: isPopupPromise, name: getNamePromise }).then(({ isPopup, name }) => {
if (isPopup && name) {
window.open('', name);
}
});
const focusPromise = this.serializedWindow.focus();
return ZalgoPromise.all([
reopenPromise,
focusPromise
]).then(() => this);
}
const getSDKProps = () : ZalgoPromise => {
return ZalgoPromise.hash({
orderID: createOrder(),
pageUrl: getPageUrl()
}).then(({ orderID, pageUrl }) => {
const userAgent = getUserAgent();
const webCheckoutUrl = getWebCheckoutUrl({ orderID });
const forceEligible = isNativeOptedIn({ props });
return {
orderID, facilitatorAccessToken, pageUrl, commit, webCheckoutUrl,
userAgent, buttonSessionID, env, stageHost, apiStageHost, forceEligible
};
});
};
tasks.loadUrl = ZalgoPromise.all([tasks.open, tasks.buildUrl, tasks.setWindowName]).then(function (_ref5) {
var proxyWin = _ref5[0],
url = _ref5[1];
return _this2.loadUrl(proxyWin, url);
});
tasks.switchPrerender = ZalgoPromise.all([tasks.prerender, _this2.onInit]).then(function () {
return _this2.switchPrerender();
});
tasks.runTimeout = tasks.loadUrl.then(function () {
return _this2.runTimeout();
});
return ZalgoPromise.hash(tasks);
}).then(function () {
return _this2.props.onEnter();
export function setupCheckout() : ZalgoPromise {
checkoutOpen = false;
const [ parent, top ] = [ getParent(window), getTop(window) ];
const tasks = {};
if (top && parent && parent !== top) {
tasks.canRenderTo = window.paypal.Checkout.canRenderTo(top).then(result => {
canRenderTop = result;
});
}
return ZalgoPromise.hash(tasks).then(noop);
}
tasks.open,
tasks.buildUrl,
tasks.setWindowName
]).then(([ proxyWin, url ]) => {
return this.loadUrl(proxyWin, url);
});
tasks.switchPrerender = ZalgoPromise.all([ tasks.prerender, this.onInit ]).then(() => {
return this.switchPrerender();
});
tasks.runTimeout = tasks.loadUrl.then(() => {
return this.runTimeout();
});
return ZalgoPromise.hash(tasks);
}).then(() => {
return this.props.onEnter();
if (prerenderDetails) {
const { win, fundingSource, card } = prerenderDetails;
return checkout({ win, fundingSource, card });
}
});
});
tasks.remember = ZalgoPromise.try(() => {
if (fundingEligibility && fundingEligibility.venmo && fundingEligibility.venmo.eligible) {
return window.xprops.remember([ FUNDING.VENMO ]);
}
});
tasks.setupCheckout = setupCheckout();
return ZalgoPromise.hash(tasks).then(noop);
}
return ZalgoPromise.try(() => {
if (this.actualWindow) {
return win === this.actualWindow;
}
return ZalgoPromise.hash({
proxyInstanceID: this.getInstanceID(),
knownWindowInstanceID: getWindowInstanceID(win, { send })
}).then(({ proxyInstanceID, knownWindowInstanceID }) => {
const match = proxyInstanceID === knownWindowInstanceID;
if (match) {
this.setWindow(win, { send });
}
return match;
});
});
}
function setupCheckout({ components } : { components : Components }) : ZalgoPromise {
const { Checkout } = components;
checkoutOpen = false;
const [ parent, top ] = [ getParent(window), getTop(window) ];
const tasks = {};
if (top && parent && parent !== top) {
tasks.canRenderTo = Checkout.canRenderTo(top).then(result => {
canRenderTop = result;
});
}
return ZalgoPromise.hash(tasks).then(noop);
}
return this.event.trigger(EVENT.DISPLAY);
});
const openBridge = open.then(proxyWin => {
return this.openBridge(proxyWin, childDomain, context);
});
const runTimeout = loadUrl.then(() => {
return this.runTimeout();
});
const onRendered = init.then(() => {
return this.event.trigger(EVENT.RENDERED);
});
return ZalgoPromise.hash({
init, buildUrl, onRender, getProxyContainer, openFrame, openPrerenderFrame, renderContainer, open,
openPrerender, setState, prerender, loadUrl, buildWindowName, setWindowName, watchForClose, onDisplay,
openBridge, runTimeout, onRendered
});
}).catch(err => {
return ZalgoPromise.all([