2 * Opens a window to login to a non-private member.
4 * @param {String} mailboxPassword - The admin mailbox password
5 * @param {String} url - Absolute URL path
6 * @param {Number} [timeout]
9 export default ({ UID, mailboxPassword, url: urlString, timeout = 20000 }) => {
10 return new Promise((resolve, reject) => {
11 const url = new URL(urlString);
12 const child = window.open(`${url}`, '_blank');
14 const receive = ({ origin, data, source }) => {
15 if (origin !== url.origin || source !== child) {
18 if (data === 'ready') {
19 child.postMessage({ UID, mailboxPassword }, url.origin);
20 window.removeEventListener('message', receive);
25 window.addEventListener('message', receive, false);
28 window.removeEventListener('message', receive);