(function () { 'use strict' var CACHE_KEY = 'access_guard_decision_v1' var ENDPOINT = '/_v/access-guard/evaluate' var REQUEST_TIMEOUT_MS = 900 var UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i function readCache() { try { var value = JSON.parse(window.sessionStorage.getItem(CACHE_KEY) || 'null') if ( value && (value.decision === 'allow' || value.decision === 'deny') && typeof value.expiresAt === 'number' && value.expiresAt > Date.now() ) { return value } window.sessionStorage.removeItem(CACHE_KEY) } catch (_error) { return null } return null } function writeCache(value) { try { window.sessionStorage.setItem(CACHE_KEY, JSON.stringify(value)) } catch (_error) { // sessionStorage pode estar indisponível; a navegação continua normalmente. } } function browserFromUa(ua) { var candidates = [ ['Edge', /Edg\/(\d+)/], ['Chrome', /Chrome\/(\d+)/], ['Firefox', /Firefox\/(\d+)/], ['Safari', /Version\/(\d+).+Safari/], ] for (var index = 0; index !== candidates.length; index += 1) { var match = ua.match(candidates[index][1]) if (match) return { name: candidates[index][0], version: match[1] } } return { name: 'Unknown' } } function osFromUa(ua) { var windows = ua.match(/Windows NT ([\d.]+)/) if (windows) { return { name: 'Windows', version: 'Windows NT ' + windows[1] } } var android = ua.match(/Android ([\d.]+)/) if (android) return { name: 'Android', version: android[1] } var ios = ua.match(/(?:iPhone|CPU) OS ([\d_]+)/) if (ios) return { name: 'iOS', version: ios[1].replace(/_/g, '.') } var mac = ua.match(/Mac OS X ([\d_]+)/) if (mac) return { name: 'macOS', version: mac[1].replace(/_/g, '.') } if (/Linux/i.test(ua)) return { name: 'Linux' } return { name: 'Unknown' } } function getDeviceType(ua, mobileHint) { if (/iPad|Tablet|Android(?!.*Mobile)/i.test(ua)) return 'tablet' if (mobileHint || /Mobi|iPhone|Android/i.test(ua)) return 'mobile' return window.innerWidth > 0 ? 'desktop' : 'unknown' } function getTimezone() { try { return Intl.DateTimeFormat().resolvedOptions().timeZone } catch (_error) { return undefined } } function highEntropy() { var data = navigator.userAgentData if (!data || typeof data.getHighEntropyValues !== 'function') { return Promise.resolve({}) } return Promise.race([ data.getHighEntropyValues([ 'architecture', 'bitness', 'model', 'platformVersion', 'uaFullVersion', ]), new Promise(function (resolve) { window.setTimeout(function () { resolve({}) }, 120) }), ]).catch(function () { return {} }) } function collectFingerprint() { var ua = navigator.userAgent || '' var browser = browserFromUa(ua) var os = osFromUa(ua) var data = navigator.userAgentData return highEntropy().then(function (entropy) { var brands = (data && data.brands) || [] var hintedBrowser = null for (var index = 0; index !== brands.length; index += 1) { if (!/Not.?A.?Brand/i.test(brands[index].brand)) { hintedBrowser = brands[index] break } } return { browser: (hintedBrowser && hintedBrowser.brand) || browser.name, browserVersion: String(entropy.uaFullVersion || '').split('.')[0] || (hintedBrowser && hintedBrowser.version) || browser.version, os: (data && data.platform) || os.name, osVersion: os.version, deviceType: getDeviceType(ua, data && data.mobile), screenWidth: Number(window.screen && window.screen.width) || 0, screenHeight: Number(window.screen && window.screen.height) || 0, viewportWidth: Number(window.innerWidth) || 0, viewportHeight: Number(window.innerHeight) || 0, devicePixelRatio: Number(window.devicePixelRatio) || 1, orientation: window.screen && window.screen.orientation && window.screen.orientation.type, language: navigator.language || '', languages: Array.prototype.slice.call(navigator.languages || [], 0, 10), timezone: getTimezone(), userAgent: ua.slice(0, 512), platform: navigator.platform || undefined, } }) } function appendText(parent, tag, text, className) { var element = document.createElement(tag) element.textContent = text if (className) element.className = className parent.appendChild(element) return element } function renderDenied(requestId) { if (!UUID_PATTERN.test(requestId || '')) return try { window.stop() } catch (_error) { // Alguns navegadores não expõem window.stop. } var head = document.createElement('head') var metaCharset = document.createElement('meta') metaCharset.setAttribute('charset', 'utf-8') head.appendChild(metaCharset) var viewport = document.createElement('meta') viewport.setAttribute('name', 'viewport') viewport.setAttribute('content', 'width=device-width, initial-scale=1') head.appendChild(viewport) var robots = document.createElement('meta') robots.setAttribute('name', 'robots') robots.setAttribute('content', 'noindex, nofollow, noarchive') head.appendChild(robots) var title = document.createElement('title') title.textContent = 'Acesso indisponível' head.appendChild(title) var style = document.createElement('style') style.textContent = '*{box-sizing:border-box}html,body{margin:0;min-height:100%;font-family:Arial,sans-serif;background:#f7f7f7;color:#2b2b2b}body{display:grid;min-height:100vh;place-items:center;padding:24px}.ag-card{width:min(100%,600px);background:#fff;border:1px solid #ddd;border-radius:8px;padding:clamp(24px,6vw,48px);box-shadow:0 8px 28px rgba(0,0,0,.08)}h1{font-size:clamp(1.5rem,5vw,2rem);line-height:1.2;margin:0 0 20px}p{font-size:1rem;line-height:1.6;margin:0 0 16px}.ag-label{font-weight:700;margin-top:24px}.ag-code{display:block;overflow-wrap:anywhere;padding:12px;background:#f2f2f2;border-radius:4px;font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:.9rem}@media(prefers-reduced-motion:reduce){*{scroll-behavior:auto!important}}' head.appendChild(style) var body = document.createElement('body') var main = document.createElement('main') main.className = 'ag-card' main.setAttribute('role', 'main') appendText(main, 'h1', 'Acesso indisponível') appendText( main, 'p', 'Não foi possível disponibilizar esta página para a sua conexão.' ) appendText( main, 'p', 'Caso você considere que isso seja um engano, entre em contato com o atendimento e informe o código abaixo:' ) appendText(main, 'p', 'Código de atendimento', 'ag-label') appendText(main, 'code', requestId, 'ag-code') body.appendChild(main) var html = document.documentElement while (html.firstChild) html.removeChild(html.firstChild) html.setAttribute('lang', 'pt-BR') html.appendChild(head) html.appendChild(body) } var cached = readCache() if (cached) { if (cached.decision === 'deny') renderDenied(cached.requestId) return } collectFingerprint() .then(function (fingerprint) { var controller = typeof AbortController === 'function' ? new AbortController() : null var timer = window.setTimeout(function () { if (controller) controller.abort() }, REQUEST_TIMEOUT_MS) return fetch(ENDPOINT, { method: 'POST', credentials: 'same-origin', cache: 'no-store', referrerPolicy: 'same-origin', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ fingerprint: fingerprint }), signal: controller ? controller.signal : undefined, }).then(function (response) { window.clearTimeout(timer) if (!response.ok) throw new Error('access_guard_unavailable') return response.json() }) }) .then(function (result) { if ( !result || (result.decision !== 'allow' && result.decision !== 'deny') ) { return } if (result.decision === 'deny' && !UUID_PATTERN.test(result.requestId || '')) { return } var ttl = Number(result.cacheTtlSeconds) if (!Number.isFinite(ttl)) return ttl = Math.max(60, Math.min(3600, ttl)) var cachedDecision = { decision: result.decision, expiresAt: Date.now() + ttl * 1000, configVersion: typeof result.configVersion === 'string' ? result.configVersion : undefined, requestId: result.decision === 'deny' ? result.requestId : undefined, } writeCache(cachedDecision) if (cachedDecision.decision === 'deny') { renderDenied(cachedDecision.requestId) } }) .catch(function () { // Fail-open: qualquer falha libera silenciosamente e não altera o layout. }) })()