Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
try {
// $FlowFixMe
sendMessage(source, origin, {
type,
ack,
hash: message.hash,
name: message.name,
...response
}, { on, send });
} catch (err) {
throw new Error(`Send response message failed for ${ logName } in ${ getDomain() }\n\n${ stringifyError(err) }`);
}
}
return ZalgoPromise.all([
sendResponse(MESSAGE_TYPE.ACK),
ZalgoPromise.try(() => {
if (!options) {
throw new Error(`No handler found for post message: ${ message.name } from ${ origin } in ${ window.location.protocol }//${ window.location.host }${ window.location.pathname }`);
}
if (!matchDomain(options.domain, origin)) {
throw new Error(`Request origin ${ origin } does not match domain ${ options.domain.toString() }`);
}
const data = message.data;
return options.handler({ source, origin, data });
export function destroyAll() : ZalgoPromise {
if (bridge) {
bridge.destroyBridges();
}
const results = [];
const global = getGlobal();
global.activeComponents = global.activeComponents || [];
while (global.activeComponents.length) {
results.push(global.activeComponents[0].destroy(new Error(`zoid destroyed all`), false));
}
return ZalgoPromise.all(results).then(noop);
}
ParentComponent.destroyAll = function destroyAll() {
var results = [];
while (ParentComponent.activeComponents.length) {
results.push(ParentComponent.activeComponents[0].destroy());
}
return ZalgoPromise.all(results).then(noop);
};
export function promiseMap(items : Array, method : (item : T) => mixed | ZalgoPromise) : ZalgoPromise> {
let results = [];
for (let i = 0; i < items.length; i++) {
results.push(ZalgoPromise.try(() => {
return method(items[i]);
}));
}
return ZalgoPromise.all(results);
}
tasks.openBridge = ZalgoPromise.all([tasks.open, tasks.buildUrl]).then(function (_ref4) {
var proxyWin = _ref4[0],
url = _ref4[1];
return _this2.openBridge(proxyWin, getDomainFromUrl(url), context);
});
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();
.catch(err => {
return ZalgoPromise.all([
close(),
ZalgoPromise.reject(err)
]);
}).then(noop);
});
static destroyAll() : ZalgoPromise {
let results = [];
while (ParentComponent.activeComponents.length) {
results.push(ParentComponent.activeComponents[0].destroy());
}
return ZalgoPromise.all(results).then(noop);
}
}
const onApproveListener = socket.on(SOCKET_MESSAGE.ON_APPROVE, ({ data: { payerID, paymentID, billingToken } }) => {
getLogger().info(`native_message_onapprove`).flush();
const data = { payerID, paymentID, billingToken, forceRestAPI: true };
const actions = { restart: () => fallbackToWebCheckout() };
return ZalgoPromise.all([
onApprove(data, actions),
close()
]);
});
const close = () => {
retry = false;
requestListeners = {};
errorListeners = [];
for (const requestUID of Object.keys(responseListeners)) {
const { listenerPromise } = responseListeners[requestUID];
listenerPromise.asyncReject(new Error(`Socket closed`));
}
ZalgoPromise.all(activeRequests).then(() => {
return socketPromise.then(
socket => socket.close(),
noop
);
});
};
return ZalgoPromise.delay(FADE_TIME).then(() => {
setVisible(false);
return ZalgoPromise.all([ onBlur(), hide() ]);
});
};