| 77 | } |
| 78 | |
| 79 | export const normalizeElectronUserAgent = (current: string, isGoogleAccounts: boolean): string => { |
| 80 | // For Google sign-in pages, we keep the Surf version at the end of the User-Agent |
| 81 | // to avoid "secure browser" warnings. For everything else, we strip out both |
| 82 | // Electron and Surf versions. |
| 83 | const surfVersion = |
| 84 | current |
| 85 | .split(' ') |
| 86 | .find((part) => part.startsWith('Surf/')) |
| 87 | ?.replace('Surf/', '') || '' |
| 88 | |
| 89 | let result = current |
| 90 | .split(' ') |
| 91 | .filter((part) => !part.startsWith('Electron/') && !part.startsWith('Surf/')) |
| 92 | .join(' ') |
| 93 | .replace( |
| 94 | process.versions.chrome || '', |
| 95 | process.versions?.chrome |
| 96 | ? process.versions.chrome |
| 97 | .split('.') |
| 98 | .map((v, idx) => (idx === 0 ? v : '0')) |
| 99 | .join('.') |
| 100 | : '' |
| 101 | ) |
| 102 | |
| 103 | if (isGoogleAccounts && surfVersion) { |
| 104 | result += ` Surf/${surfVersion}` |
| 105 | } |
| 106 | |
| 107 | return result |
| 108 | } |
| 109 | |
| 110 | export const firefoxUA = (() => { |
| 111 | const platformMap = { |