2017-08-15 13:54:22 +02:00
global . window = undefined
function getUrls ( env ) {
if ( env . staticUrl ) {
2022-04-20 11:00:52 +02:00
const staticUrlParts = env . staticUrl . split ( "//" )
const apiUrl = staticUrlParts [ 0 ] + "//*.api." + staticUrlParts [ 1 ]
return env . staticUrl + " ws" + env . staticUrl . substring ( 4 ) + " " + apiUrl
2017-08-15 13:54:22 +02:00
} else {
return ""
}
}
/ * *
* Renders the initial HTML page to bootstrap Tutanota for different environments
* /
2019-09-13 13:49:11 +02:00
export async function renderHtml ( scripts , env ) {
2022-03-02 13:49:49 +01:00
return ` <!DOCTYPE html>
< html >
< head >
< meta charset = "utf-8" >
$ { csp ( env ) }
< meta name = "apple-mobile-web-app-capable" content = "yes" >
< meta name = "mobile-web-app-capable" content = "yes" >
< meta name = "referrer" content = "no-referrer" >
< meta name = "viewport" content = "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover" >
2022-03-14 17:52:03 +01:00
$ { scripts . map ( renderScriptImport ) . join ( "\n\t" ) }
2022-03-02 13:49:49 +01:00
<!-- TutanotaTags -- >
< title > Mail . Done . Right . Tutanota Login & amp ; Sign up for an Ad - free Mailbox < / t i t l e >
< meta name = "description" content = "Mail. Done. Right. Get a free mail account that does not abuse your emails for advertising. Tutanota is fast, easy, secure and free of ads." >
< link rel = "shortcut icon" type = "image/x-icon" href = "images/logo-favicon-152.png" >
< meta name = "application-name" content = "Tutanota" >
< link rel = "apple-touch-icon" sizes = "152x152" href = "images/logo-favicon-152.png" >
< link rel = "icon" sizes = "192x192" href = "/images/logo-favicon-192.png" >
< meta name = "twitter:card" content = "summary" >
< meta name = "twitter:site" content = "@TutanotaTeam" >
< meta name = "twitter:domain" content = "tutanota.com" >
< meta name = "twitter:image" content = "https://tutanota.com/images/share_image.png" >
2022-07-19 15:45:42 +02:00
< meta property = "og:site_name" content = "Tutanota" >
< meta property = "og:title" content = "Secure Emails Become a Breeze" >
< meta property = "og:description" content = "Get your encrypted mailbox for free and show the Internet spies that you won&#39;t make it easy for them! Why? Because you simply can." >
< meta property = "og:locale" content = "en_US" >
< meta property = "og:url" content = "https://tutanota.com/" >
< meta property = "og:image" content = "https://tutanota.com/images/share_image.png" >
< meta property = "article:publisher" content = "https://www.facebook.com/tutanota" >
2022-03-02 13:49:49 +01:00
< meta itemprop = "name" content = "Secure Emails Become a Breeze." >
< meta itemprop = "description" content = "Get your encrypted mailbox for free and show the Internet spies that you won&#39;t make it easy for them! Why? Because you simply can." >
< meta itemprop = "image" content = "https://tutanota.com/images/share_image.png" >
< meta name = "apple-itunes-app" content = "app-id=id922429609, affiliate-data=10lSfb" >
< / h e a d >
< body style = "background-color:transparent" >
< noscript > This site requires javascript to be enabled . Please activate it in the settings of your browser . < / n o s c r i p t >
< / b o d y >
< / h t m l > `
2017-08-15 13:54:22 +02:00
}
2022-03-02 13:49:49 +01:00
function csp ( env ) {
2019-09-13 13:49:11 +02:00
if ( env . dist ) {
if ( env . mode === "App" || env . mode === "Desktop" ) {
// differences in comparison to web csp:
// * Content Security Policies delivered via a <meta> element may not contain the frame-ancestors directive.
2022-03-02 13:49:49 +01:00
const cspContent = "default-src 'none';"
+ " script-src 'self';"
+ " child-src 'self';"
+ " font-src 'self';"
+ " img-src http: blob: data: *;"
+ " style-src 'unsafe-inline';"
+ "base-uri 'none';"
+ ` connect-src 'self' ${ getUrls ( env ) } https://tutanota.com; `
return ` <meta http-equiv="Content-Security-Policy" content=" ${ cspContent } "> `
2019-09-13 13:49:11 +02:00
} else {
2022-03-14 17:52:03 +01:00
return ""
2019-09-13 13:49:11 +02:00
}
2018-07-18 16:07:25 +02:00
} else {
2022-03-02 13:49:49 +01:00
const cspContent = "default-src * 'unsafe-inline' 'unsafe-eval';"
2019-09-13 13:49:11 +02:00
+ " script-src * 'unsafe-inline' 'unsafe-eval';"
+ " img-src * data: blob: 'unsafe-inline';"
+ " media-src * data: blob: 'unsafe-inline';"
+ " style-src * 'unsafe-inline';"
2022-03-02 13:49:49 +01:00
+ " frame-src *;"
+ ` connect-src 'self' 'unsafe-inline' ${ getUrls ( env ) } ws://localhost:9001; `
return ` <meta http-equiv="Content-Security-Policy" content=" ${ cspContent } "> `
2018-07-18 16:07:25 +02:00
}
}
2022-03-02 13:49:49 +01:00
function renderScriptImport ( { src , type } ) {
2022-05-03 13:38:19 +02:00
const typeString = type ? ` type=" ${ type } " ` : ""
2022-03-14 17:52:03 +01:00
return ` <script src=" ${ src } " ${ typeString } defer></script> `
2019-09-13 13:49:11 +02:00
}