Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | 4x 6x 6x 6x 6x 144x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 4x 4x 2x 4x 1x 4x 2x 2x 6x 6x 6x 6x 6x 6x 6x 6x 4x 7x 1x 6x 6x 6x 6x | import { WorkerEnv, isScriptDownloadPathSet, isGetResultPathSet, isProxySecretSet, agentScriptDownloadPathVarName, getResultPathVarName, proxySecretVarName, } from '../env' function generateNonce() { let result = '' const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' const indices = crypto.getRandomValues(new Uint8Array(24)) for (const index of indices) { result += characters[index % characters.length] } return btoa(result) } function buildHeaders(styleNonce: string): Headers { const headers = new Headers() headers.append('Content-Type', 'text/html') headers.append( 'Content-Security-Policy', `default-src 'none'; img-src https://fingerprint.com; style-src 'nonce-${styleNonce}'` ) return headers } function createWorkerVersionElement(): string { return ` <span> ℹ️ Worker version: __current_worker_version__ </span> ` } function createContactInformationElement(): string { return ` <span> ❓Please reach out our support via <a href='mailto:support@fingerprint.com'>support@fingerprint.com</a> if you have any issues </span> ` } function createEnvVarsInformationElement(env: WorkerEnv): string { const isScriptDownloadPathAvailable = isScriptDownloadPathSet(env) const isGetResultPathAvailable = isGetResultPathSet(env) const isProxySecretAvailable = isProxySecretSet(env) const isAllVarsAvailable = isScriptDownloadPathAvailable && isGetResultPathAvailable && isProxySecretAvailable let result = '' if (!isAllVarsAvailable) { result += ` <span> The following environment variables are not defined. Please reach out our support team. </span> ` if (!isScriptDownloadPathAvailable) { result += ` <span> ⚠️ <strong>${agentScriptDownloadPathVarName} </strong> is not set </span> ` } if (!isGetResultPathAvailable) { result += ` <span> ⚠️ <strong>${getResultPathVarName} </strong> is not set </span> ` } if (!isProxySecretAvailable) { result += ` <span> ⚠️ <strong>${proxySecretVarName} </strong> is not set </span> ` } } else { result += ` <span> ✅ All environment variables are set </span> ` } return result } function buildBody(env: WorkerEnv, styleNonce: string): string { let body = ` <html lang='en-US'> <head> <meta charset='utf-8'/> <title>Fingerprint Pro Cloudflare Worker</title> <link rel='icon' type='image/x-icon' href='https://fingerprint.com/img/favicon.ico'> <style nonce='${styleNonce}'> h1, span { display: block; padding-top: 1em; padding-bottom: 1em; text-align: center; } </style> </head> <body> <h1>Fingerprint Pro Cloudflare Integration</h1> ` body += `<span>🎉 Your Cloudflare worker is deployed</span>` body += createWorkerVersionElement() body += createEnvVarsInformationElement(env) body += createContactInformationElement() body += ` </body> </html> ` return body } export function handleStatusPage(request: Request, env: WorkerEnv): Response { if (request.method !== 'GET') { return new Response(null, { status: 405 }) } const styleNonce = generateNonce() const headers = buildHeaders(styleNonce) const body = buildBody(env, styleNonce) return new Response(body, { status: 200, statusText: 'OK', headers, }) } |