()
| 2959 | } |
| 2960 | |
| 2961 | async function resolveIcloudPremiumMailService() { |
| 2962 | const errors = []; |
| 2963 | const state = await getState(); |
| 2964 | const setupUrls = await getPreferredIcloudSetupUrls(state); |
| 2965 | |
| 2966 | for (const setupUrl of setupUrls) { |
| 2967 | try { |
| 2968 | const data = await validateIcloudSession(setupUrl); |
| 2969 | const preferredIcloudHost = normalizeIcloudHost(new URL(setupUrl).host); |
| 2970 | if (preferredIcloudHost && preferredIcloudHost !== normalizeIcloudHost(state.preferredIcloudHost)) { |
| 2971 | await setState({ preferredIcloudHost }); |
| 2972 | } |
| 2973 | return { |
| 2974 | setupUrl, |
| 2975 | serviceUrl: String(data.webservices.premiummailsettings.url || '').replace(/\/$/, ''), |
| 2976 | }; |
| 2977 | } catch (err) { |
| 2978 | errors.push(`${new URL(setupUrl).host}: ${getErrorMessage(err)}`); |
| 2979 | } |
| 2980 | } |
| 2981 | |
| 2982 | throw new Error(errors.length |
| 2983 | ? `Could not validate iCloud session. ${errors.join(' | ')}` |
| 2984 | : 'Could not validate iCloud session. 请先在当前浏览器登录 icloud.com.cn 或 icloud.com。'); |
| 2985 | } |
| 2986 | |
| 2987 | function getIcloudAliasLabel() { |
| 2988 | const now = new Date(); |
no test coverage detected