@finsweet/consentpro-scan 1.0.18 → 1.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/results.js +3 -3
- package/dist/scan.js +1 -1
- package/package.json +1 -1
package/dist/results.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";(()=>{var
|
|
1
|
+
"use strict";(()=>{var Ne=Object.defineProperty;var $e=(t,e,o)=>e in t?Ne(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o;var J=(t,e,o)=>$e(t,typeof e!="symbol"?e+"":e,o);var ee=(t=document)=>t.documentElement.getAttribute("data-wf-site");var te=async t=>{let{Webflow:e}=window;if(!(!e||!("destroy"in e)||!("ready"in e)||!("require"in e))&&!(t&&!t.length)){if(t||(e.destroy(),e.ready()),!t||t.includes("ix2")){let o=e.require("ix2");if(o){let{store:n,actions:s}=o,{eventState:r}=n.getState().ixSession,i=Object.entries(r);t||o.destroy(),o.init(),await Promise.all(i.map(m=>n.dispatch(s.eventStateChanged(...m))))}}if(!t||t.includes("commerce")){let o=e.require("commerce"),n=ee();o&&n&&(o.destroy(),o.init({siteId:n,apiUrl:"https://render.webflow.com"}))}if(t?.includes("lightbox")&&e.require("lightbox")?.ready(),t?.includes("slider")){let o=e.require("slider");o&&(o.redraw(),o.ready())}return t?.includes("tabs")&&e.require("tabs")?.redraw(),new Promise(o=>e.push(()=>o(void 0)))}};var S=t=>t.type==="script"||t.type==="iframe"||t.type==="link"||t.type==="noscript",T=t=>t.type==="cookie"||t.type==="local-storage"||t.type==="session-storage",oe=t=>t.type==="banner",Oe=["essential","necessary"],L=t=>!!t&&Oe.includes(t),Ue=/googletagmanager\.com\/gtm\.js\?(?:[^"'#\s]*&)?id=(GTM-[A-Z0-9]+)/gi,ne=t=>t.type!=="script"?!1:Ue.test(t.source),se=t=>t.filter(S),re=t=>t.filter(e=>e.type==="script"),_e=t=>t.filter(e=>e.type==="iframe"),Fe=t=>t.filter(e=>e.type==="link"),Ve=t=>t.filter(e=>e.type==="noscript"),je=t=>t.filter(e=>S(e)&&e.isThirdParty&&!L(e.category)&&!ne(e)),qe=t=>t.filter(e=>e.type==="script"&&e.isThirdParty&&!L(e.category)&&!ne(e)),H=t=>t.filter(T),ie=t=>t.filter(e=>e.type==="cookie"),We=t=>t.filter(e=>e.type==="local-storage"),Be=t=>t.filter(e=>e.type==="session-storage"),Ge=t=>t.filter(e=>T(e)&&!L(e.category)),V=t=>t.filter(e=>e.type==="cookie"&&!L(e.category)),ae=t=>t.filter(e=>e.type==="local-storage"&&!L(e.category)),ce=t=>t.filter(e=>e.type==="session-storage"&&!L(e.category)),j=t=>t.filter(e=>e.type==="cookie"&&(!e.category||e.category==="uncategorized")),Ye=/google\s*tag\s*manager|^gtm$/i,le=t=>Ye.test(t.label),U=t=>t.filter(e=>!L(e.category)&&!le(e)),Ze=(t,e)=>t.filter(o=>o.category===e),q=t=>t.filter(e=>e.category==="analytics"&&!le(e)),W=t=>t.filter(e=>e.category==="marketing"),Ke=t=>t.filter(e=>!e.category||e.category==="uncategorized"),B=t=>U(t).flatMap(o=>o.resources||[]),Xe=t=>{let e=B(t);return new Set(e.map(o=>o.id))},fe=t=>{let e=B(t),o=["script","link","iframe","noscript"];return new Set(e.filter(n=>o.includes(n.type)).map(n=>n.id))},ge=t=>{let e=B(t),o=["cookie","local-storage","session-storage"];return new Set(e.filter(n=>o.includes(n.type)).map(n=>n.id))},Qe=(t,e)=>{let o=fe(e);return t.filter(n=>S(n)&&o.has(n.id))},Je=(t,e)=>{let o=ge(e);return t.filter(n=>T(n)&&o.has(n.id))},M={isEssentialCategory:L,isResourceItem:S,isStorageItem:T,isBannerItem:oe,isGTMContainerScript:ne,isGTMContainerTracker:le,domResources:se,scripts:re,iframes:_e,links:Fe,noscripts:Ve,loadedDOMResources:je,loadedScripts:qe,storageResources:H,cookies:ie,localStorage:We,sessionStorage:Be,loadedStorageResources:Ge,loadedCookies:V,loadedLocalStorage:ae,loadedSessionStorage:ce,uncategorizedCookies:j,violatingTrackers:U,trackersByCategory:Ze,analyticsTrackers:q,marketingTrackers:W,uncategorizedTrackers:Ke,getViolatingTrackerResources:B,getViolatingResourceIds:Xe,getViolatingDOMResourceIds:fe,getViolatingStorageResourceIds:ge,affiliatedDOMResources:Qe,affiliatedStorageResources:Je};var et=[{id:"cookieyes",name:"CookieYes",patterns:{scripts:[/cookieyes\.com/i,/cookie-law-info/i],cookies:[/cookieyes-consent/i,/cky-consent/i,/cookielawinfo/i],dom:[/cky-consent/i,/cookie-law-info/i]}},{id:"termly",name:"Termly",patterns:{scripts:[/termly\.io/i,/termly-embed/i],cookies:[/termly/i],dom:[/termly/i]}},{id:"consentmanager",name:"Consentmanager.net",patterns:{scripts:[/consentmanager\.net/i,/consent-manager/i],cookies:[/consentmanager/i,/cmapi/i],dom:[/consent-manager/i]}},{id:"enzuzo",name:"Enzuzo",patterns:{scripts:[/enzuzo\.com/i],cookies:[/enzuzo/i],dom:[/enzuzo/i]}},{id:"cookiebot",name:"Cookiebot (by Usercentrics)",patterns:{scripts:[/cookiebot\.com/i,/consent\.cookiebot/i],cookies:[/CookieConsent/i,/cookiebot/i],dom:[/CookieConsent/i,/cookiebot/i]}},{id:"iubenda",name:"Iubenda",patterns:{scripts:[/iubenda\.com/i,/iubenda_cs/i],cookies:[/_iub_cs/i,/iubenda/i],dom:[/iubenda/i,/_iub_cs/i]}},{id:"osano",name:"Osano",patterns:{scripts:[/osano\.com/i],cookies:[/osano/i],dom:[/osano/i]}},{id:"usercentrics",name:"Usercentrics",patterns:{scripts:[/usercentrics\.eu/i,/usercentrics\.com/i],cookies:[/usercentrics/i,/uc_user_interaction/i],dom:[/usercentrics/i]}},{id:"cookiescript",name:"CookieScript",patterns:{scripts:[/cookiescript\.com/i,/cookie-script/i],cookies:[/CookieScriptConsent/i],dom:[/cookie-script/i]}},{id:"secureprivacy",name:"Secure Privacy",patterns:{scripts:[/secureprivacy\.ai/i],cookies:[/secureprivacy/i],dom:[/secureprivacy/i]}},{id:"onetrust",name:"OneTrust",patterns:{scripts:[/onetrust\.com/i,/optanon/i],cookies:[/OptanonConsent/i,/OptanonAlertBoxClosed/i],dom:[/onetrust/i,/optanon/i]}},{id:"trustarc",name:"TrustArc",patterns:{scripts:[/trustarc\.com/i,/truste\.com/i],cookies:[/truste/i,/notice_behavior/i],dom:[/truste/i]}},{id:"axeptio",name:"Axeptio",patterns:{scripts:[/axept\.io/i,/static\.axept\.io/i],cookies:[/axeptio_/i,/axeptio/i],dom:[/axeptio/i]}},{id:"complianz",name:"Complianz",patterns:{scripts:[/complianz/i],cookies:[/complianz/i,/cmplz/i],dom:[/complianz/i,/cmplz/i]}},{id:"quantcast",name:"Quantcast",patterns:{scripts:[/quantcast/i,/quantserve/i],cookies:[/quantcast/i,/__qca/i],dom:[/quantcast/i]}},{id:"cookieconsent-termsfeed",name:"Cookie Consent by TermsFeed",patterns:{scripts:[/cookieconsent\.com/i,/termsfeed\.com/i],cookies:[/cc_cookie/i],dom:[/cookieconsent/i]}},{id:"finsweet-fs-cc",name:"Finsweet [fs-cc] Consent",patterns:{scripts:[/@finsweet\/cookie-consent/i,/fs-cc\.js/i],cookies:[/fs-cc/i,/finsweet.*cookie/i],dom:[/fs-cc-(mode|src|category|placeholder)\s*=/i,/(?:^|[^-])fs-cc(?:[^-]|$)/i,/fs-consent-element/i,/fs-consent_banner/i],banners:[/fs-cc/i,/fs-consent/i,/cookie-consent/i]}},{id:"finsweet-cookie-consent",name:"Finsweet Cookie Consent | Finsweet Consent Pro",patterns:{scripts:[/@finsweet\/fs-components/i,/finsweet.*cookie-consent/i,/fs-cc\.js/i],cookies:[/fs-consent/i,/(?:^|[^-])fs-cc(?:[^-]|$)/i,/(?:^|[^-])fs-consent(?:[^-]|$)/i,/finsweet.*cookie/i],dom:[/fs-components-installed\s*=\s*["']consent["']/i,/(?:^|[^-])fs-cc(?:[^-]|$)/i,/(?:^|[^-])fs-consent(?:[^-]|$)/i,/fs-consent-element/i,/fs-consent_banner/i],banners:[/fs-consent/i,/fs-cc/i,/consentpro/i,/cookie-consent/i,/fs-components.*consent/i]}}],ye=/youtube\.com|youtu\.be|vimeo\.com|player\.vimeo/i,he=/maps\.google|maps\.googleapis|google\.com\/maps/i,ke=/fonts\.googleapis\.com|fonts\.gstatic\.com|use\.typekit\.net|use\.typekit\.com|p\.typekit\.net|fast\.fonts\.net|hello\.myfonts\.net|cloud\.typography\.com|api\.fontshare\.com|cdn\.fontshare\.com|fonts\.cdnfonts\.com/i,ve=/googletagmanager\.com|gtm\.js/i,tt=/cdn\.intellimize\.co\/snippet\/\d+\.js/i,me=/intellimize/i;function Ce(t){let e=[];e.push(ot(t)),e.push(nt(t)),e.push(st(t)),e.push(rt(t)),e.push(ue(t)),e.push(it(t)),e.push(at(t)),e.push(ct(t)),e.push({id:"script-head-placement",name:"Script Head Placement",description:"Verify consent script is placed at the top of <head> section",status:"not-verifiable",details:"Cannot be verified from scan results. Manual review required."}),e.push(lt(t)),e.push({id:"auto-placeholder",name:"Auto-placeholder Support",description:"Check if blocked videos have placeholder elements",status:"not-verifiable",details:"Cannot be verified from scan results. Manual review required."});let o={passed:e.filter(l=>l.status==="pass").length,failed:e.filter(l=>l.status==="fail").length,notVerifiable:e.filter(l=>l.status==="not-verifiable").length},n=e.filter(l=>l.status!=="not-verifiable");if(n.length===0)return{overallScore:0,hasViolations:o.failed>0,criteria:e,summary:o};let s=["pre-consent-trackers","consent-tool"],r=0,i=0;console.log(`
|
|
2
2
|
========================================`),console.log(" COMPLIANCE SCORE BREAKDOWN "),console.log(`========================================
|
|
3
3
|
`),console.log("Criteria Weights:"),console.log(" - pre-consent-trackers: 3x (most critical)"),console.log(" - consent-tool: 2x (important)"),console.log(" - all others: 1x (standard)"),console.log(`
|
|
4
4
|
Scoring: pass = 1.0 points, fail = 0.0 points`),console.log(`Formula: (sum of weighted points / total weight) \xD7 100
|
|
5
|
-
`),console.log("----------------------------------------"),console.log("CRITERIA BREAKDOWN:"),console.log("----------------------------------------");let m=[];for(let l of n){let p=1;l.id==="pre-consent-trackers"?p=3:s.includes(l.id)&&(p=2);let
|
|
6
|
-
`),{overallScore:c,hasViolations:o.failed>0,criteria:e,summary:o}}function Y(t){if(!t.results)throw new Error("No results found in response for compliance evaluation");return Ee(t.results)}function st(t){let e=t.trackersInfo?.trackers??[],o=t.trackersInfo?.providers??[],n=new Map;o.forEach(p=>n.set(p.id,p.name));let s=_(e),r=B(e).length,i=W(e).length,m=[...new Set(s.map(p=>n.get(p.providerId)||p.name||p.domain||p.providerId))];if(s.length===0)return{id:"pre-consent-trackers",name:"Pre-Consent Trackers",description:"Check for tracking scripts running before user consent",status:"pass",details:"No tracking scripts detected running before consent."};let c=[];r>0&&c.push(`${r} analytics`),i>0&&c.push(`${i} marketing`);let l=s.length-r-i;return l>0&&c.push(`${l} other`),{id:"pre-consent-trackers",name:"Pre-Consent Trackers",description:"Check for tracking scripts running before user consent",status:"fail",details:`Found ${s.length} tracker(s) running before consent (${c.join(", ")}). These should be blocked until user provides consent.`,affectedItems:m}}function rt(t){let e=t.detectedItems.filter(T).filter(s=>he.test(s.domain)||he.test(s.source)),o=e.map(s=>s.id);if(e.length===0)return{id:"video-embeds",name:"YouTube/Vimeo Detection",description:"Detect YouTube or Vimeo video embeds that may store cookies",status:"pass",details:"No YouTube or Vimeo embeds detected."};let n=e.filter(s=>s.isThirdParty);return{id:"video-embeds",name:"YouTube/Vimeo Detection",description:"Detect YouTube or Vimeo video embeds that may store cookies",status:"fail",details:`Found ${e.length} video embed(s) from YouTube/Vimeo. ${n.length} are third-party resources that may store cookies before consent.`,affectedItems:o}}function it(t){let e=t.detectedItems.filter(T).filter(n=>ke.test(n.domain)||ke.test(n.source)),o=e.map(n=>n.id);return e.length===0?{id:"google-maps",name:"Google Maps Detection",description:"Detect Google Maps embeds that may store cookies",status:"pass",details:"No Google Maps embeds detected."}:{id:"google-maps",name:"Google Maps Detection",description:"Detect Google Maps embeds that may store cookies",status:"fail",details:`Found ${e.length} Google Maps embed(s) that may store cookies before consent.`,affectedItems:o}}function at(t){let e=t.detectedItems.filter(T).filter(n=>ve.test(n.domain)||ve.test(n.source)),o=e.map(n=>n.id);return e.length===0?{id:"external-fonts",name:"External Fonts Detection",description:"Detect external fonts (Google Fonts, Typekit, etc.) which transfer IP addresses without consent",status:"pass",details:"No external fonts detected. Website may be using self-hosted fonts."}:{id:"external-fonts",name:"External Fonts Detection",description:"Detect external fonts (Google Fonts, Typekit, etc.) which transfer IP addresses without consent",status:"fail",details:`Found ${e.length} external font resource(s). This transfers visitor IP addresses to third-party servers without consent, which may violate data privacy regulations (GDPR, CCPA, HIPAA, etc.). Fonts should be self-hosted or loaded only after consent.`,affectedItems:o}}function ue(t){if(t.detectedCmps&&t.detectedCmps.length>0)return{id:"consent-tool",name:"Consent Tool Detection",description:"Check if a cookie consent management tool is installed",status:"pass",details:`Detected consent tool(s): ${t.detectedCmps.map(r=>r.version?`${r.name} (v${r.version})`:r.name).join(", ")}`};let e=[],o=new Map;for(let s of ot){let r=0;if(t.detectedItems&&Array.isArray(t.detectedItems)){for(let i of t.detectedItems)if(T(i)&&i.type==="script"){let{source:m}=i,c=i.element?.outerHTML||"";for(let l of s.patterns.scripts)if(l.test(m)||l.test(c)){r+=1,e.includes(i.id)||e.push(i.id);break}}}if(t.trackersInfo?.providers&&Array.isArray(t.trackersInfo.providers))for(let i of t.trackersInfo.providers){let m=i.name||"";for(let c of s.patterns.scripts)if(c.test(m)){r+=1,e.includes(i.id)||e.push(i.id);break}}if(t.detectedItems&&Array.isArray(t.detectedItems)){for(let i of t.detectedItems)if(w(i)&&i.type==="cookie"){let{name:m}=i;for(let c of s.patterns.cookies)if(c.test(m)){r+=1,e.includes(i.id)||e.push(i.id);break}}}if(t.detectedItems&&Array.isArray(t.detectedItems))for(let i of t.detectedItems){let c=T(i)&&i.element?.outerHTML||"";for(let l of s.patterns.dom)if(l.test(c)){r+=1,e.includes(i.id)||e.push(i.id);break}}if(t.detectedItems&&Array.isArray(t.detectedItems)){for(let i of t.detectedItems)if(oe(i)){let m=i.element||"",c=s.patterns.banners||s.patterns.dom;for(let l of c)if(l.test(m)){r+=3,e.includes(i.id)||e.push(i.id);break}}}r>0&&o.set(s.name,r)}let n=Array.from(o.entries()).sort((s,r)=>r[1]-s[1]).map(([s])=>s);return n.length===0?{id:"consent-tool",name:"No cookie consent tool detected",description:"Check if a cookie consent management tool is installed",status:"fail",details:"No cookie consent tool detected. A consent banner is required for compliance with data privacy regulations (GDPR, CCPA, etc.). Note: Not all CMP tools can be automatically detected. If you have a CMP installed that is not recognized, please verify manually."}:{id:"consent-tool",name:"Consent Tool Detection",description:"Check if a cookie consent management tool is installed",status:"pass",details:`Detected consent tool(s): ${n.join(", ")}. Note: Detection is based on known patterns and may not identify all CMP configurations.`,affectedItems:e}}function ct(t){let o=(t.trackersInfo?.trackers??[]).filter(s=>Ce.test(s.label)||Ce.test(s.domain??"")?!1:!s.category||s.category==="uncategorized"),n=o.map(s=>s.id);return o.length===0?{id:"uncategorized-trackers",name:"Uncategorized Trackers",description:"Check for trackers without proper categorization",status:"pass",details:"All trackers are properly categorized."}:{id:"uncategorized-trackers",name:"Uncategorized Trackers",description:"Check for trackers without proper categorization",status:"fail",details:`Found ${o.length} uncategorized tracker(s). These should be categorized for proper consent management.`,affectedItems:n}}function lt(t){let e=j(t.detectedItems),o=e.map(n=>n.id);return e.length===0?{id:"non-essential-cookies",name:"Non-Essential Cookies",description:"Check for non-essential cookies set before consent",status:"pass",details:"No non-essential cookies detected before consent."}:{id:"non-essential-cookies",name:"Non-Essential Cookies",description:"Check for non-essential cookies set before consent",status:"fail",details:`Found ${e.length} non-essential cookie(s) being set before consent. These should be blocked until user provides consent.`,affectedItems:o}}function mt(t){let e=q(t.detectedItems),o=e.map(n=>n.id);return e.length===0?{id:"uncategorized-cookies",name:"Uncategorized Cookies",description:"Check for cookies without proper categorization",status:"pass",details:"All cookies are properly categorized."}:{id:"uncategorized-cookies",name:"Uncategorized Cookies",description:"Check for cookies without proper categorization",status:"fail",details:`Found ${e.length} uncategorized cookie(s). These should be reviewed and assigned to appropriate consent categories.`,affectedItems:o}}function dt(t){let e=t.detectedItems??[];if(!e.some(c=>T(c)&&c.type==="script"&&nt.test(c.source)))return{id:"webflow-optimize",name:"Webflow Optimize Detection",description:"Detect Webflow Optimize and Analyze configurations",status:"pass",details:"Webflow Optimize/Analyze (Intellimize) not detected."};if(ue(t).status!=="pass")return{id:"webflow-optimize",name:"Webflow Optimize Detection",description:"Detect Webflow Optimize and Analyze configurations",status:"pass",details:"Webflow Optimize detected; no CMP\u2014consent-gating not applicable."};let s=e.filter(c=>w(c)&&c.type==="cookie"&&me.test(c.name)),r=e.filter(c=>w(c)&&c.type==="session-storage"&&me.test(c.name)),i=e.filter(c=>w(c)&&c.type==="local-storage"&&me.test(c.name)),m=[];if(s.length>0&&m.push(`${s.length} cookie(s)`),r.length>0&&m.push(`${r.length} session-storage key(s)`),i.length>0&&m.push(`${i.length} local-storage key(s)`),m.length>0){let c=[...s.map(l=>l.id),...r.map(l=>l.id),...i.map(l=>l.id)];return{id:"webflow-optimize",name:"Webflow Optimize Detection",description:"Detect Webflow Optimize and Analyze configurations",status:"fail",details:`Intellimize cookies/storage present despite CMP: ${m.join(", ")}.`,affectedItems:c}}return{id:"webflow-optimize",name:"Webflow Optimize Detection",description:"Detect Webflow Optimize and Analyze configurations",status:"pass",details:"Webflow Optimize detected; CMP present and no Intellimize cookies or storage detected."}}function pe(t){if(t.detectedCmps&&t.detectedCmps.length>0)return t.detectedCmps.map(n=>n.name).join(", ");let e=ue(t);return e.status!=="pass"||!e.details?null:e.details.match(/Detected consent tool\(s\): (.+)/)?.[1]?.trim()??null}function xe(t){return Ee(t).criteria.filter(o=>o.status==="fail").map(o=>`${o.name}: ${o.details}`)}function be(t){let e=[],o=t.trackersInfo?.trackers??[],n=t.trackersInfo?.providers??[],s=t.detectedItems??[],r=z(s),i=new Map;n.forEach(h=>i.set(h.id,h.name));let m=_(o),c=B(o),l=W(o);if(c.length>0){let h=de(c,3,i);e.push(`${c.length} analytics tracker(s) running before consent: ${h}`)}if(l.length>0){let h=de(l,3,i);e.push(`${l.length} marketing tracker(s) firing before consent: ${h}`)}let p=m.filter(h=>h.category!=="analytics"&&h.category!=="marketing");if(p.length>0){let h=de(p,3,i);e.push(`${p.length} other tracker(s) need consent: ${h}`)}let g=j(r);g.length>0&&e.push(`${g.length} non-essential cookies set before consent`);let d=q(r);d.length>0&&e.push(`${d.length} uncategorized cookies detected - review and categorize`);let f=ae(r),v=ce(r),x=f.length+v.length;return x>0&&e.push(`${x} localStorage/sessionStorage items set pre-consent`),pe(t)||e.push("No consent management platform detected"),e}function de(t,e,o){let n=[...new Set(t.map(s=>o.get(s.providerId)||s.name||s.domain||"Unknown"))];return n.length<=e?n.join(", "):`${n.slice(0,e).join(", ")} +${n.length-e} more`}var ut=localStorage.getItem("cs-dev")==="true",F=ut?"https://fs-consentpro-api-dev.finsweet.workers.dev":"https://api.consentpro.com",ho=1440*60*1e3;var y={success:"#07601d",warning:"#bb5902",error:"#8F0C3D",info:"#598FFF","success-foreground":"#25fc54","warning-foreground":"#FFAA00","error-foreground":"#FF265A","info-foreground":"#d5e8ff"};function Se(t){if(!t.results)throw new Error("No results found in response for scan summary extraction");let{results:e}=t;return{scanId:e.trackingId,scanDuration:e.scanDuration,pagesScanned:e.pagesScanned.length,totalPages:e.totalPagesFound,detectedItemsCount:e.detectedItems.length,scannedAt:e.scannedAt}}function Te(t){let e=Y(t);return{compliant:!e.hasViolations,score:e.overallScore,violations:e.summary.failed}}function Ie(t){if(!t.results)throw new Error("No results found in response for actionable items extraction");let{results:e}=t,o=re(e.detectedItems).length,n=ie(e.detectedItems).length,s=pe(e);return{scripts:o,cookies:n,cmpInstalled:s??void 0}}function we(t){if(!t.results)throw new Error("No results found in response for violations extraction");return xe(t.results)}function Re(t){if(!t.results)throw new Error("No results found in response for detected items extraction");let{results:e}=t,o=se(e.detectedItems),n=z(e.detectedItems);return{dom:o,storage:n}}function Le(t){let e=Y(t);return{pass:e.summary.passed,fail:e.summary.failed,unverified:e.summary.notVerifiable}}function Ae(t){if(!t.results)throw new Error("No results found in response for attention items extraction");return be(t.results)}function Me(t){if(!t.results)throw new Error("No results found in response for statistics extraction");let{results:e}=t;return{scanDuration:gt(e.scanDuration),resourcesCount:e.detectedItems.length,storageCount:z(e.detectedItems).length,firstParty:e.statistics?.firstPartyResources??0,thirdParty:e.statistics?.thirdPartyResources??0,categories:Object.keys(e.statistics?.categoryCounts||{}).length}}function pt(t){return Y(t)}function ft(t){return{scanSummary:Se(t),compliance:Te(t),actionableItems:Ie(t),violations:we(t),detectedItems:Re(t),complianceSummary:Le(t),attentionItems:Ae(t),statistics:Me(t)}}function gt(t){let e=Math.floor(t/1e3);if(e<60)return`${e}s`;let o=Math.floor(e/60),n=e%60;return`${o}m ${n}s`}var R={extractScanSummary:Se,extractCompliance:Te,extractActionableItems:Ie,extractViolations:we,extractDetectedItems:Re,extractComplianceSummary:Le,extractAttentionItems:Ae,extractStatistics:Me,extractFullCompliance:pt,extractAll:ft};var De="data-fs-cs";var a=(t,e=document)=>e.querySelector(`[${De}="${t}"]`),P=(t,e=document)=>e.querySelectorAll(`[${De}="${t}"]`);var He={"X-Finsweet-ConsentPro-Version":"v2"},ze={"X-Finsweet-ConsentPro-Version":"v2","Content-Type":"application/json"},A=class extends Error{constructor(o,n,s){super(o);J(this,"status");J(this,"response");this.name="ScannerApiError",this.status=n,this.response=s}};async function Z(t){if(!t.ok){let e=t.statusText,o;try{let n=await t.json();o=n,n&&typeof n.error=="string"&&(e=n.error)}catch{o=await t.text().catch(()=>"Unknown error")}throw new A(`Report request failed: ${e}`,t.status,o)}return t.json()}var K={async startScan(t){let e=await fetch(`${F}/v2/scanner/public/scan`,{method:"POST",headers:ze,body:JSON.stringify({url:t,acceptAll:!1})});if(e.status===409){let n=await e.json().catch(()=>({}));throw new A("A scan is already in progress for this website. Please wait for it to complete.",409,n)}if(e.status!==201){let n=await e.text().catch(()=>"Unknown error");throw new A(`Expected 201 Created but got ${e.status}`,e.status,n)}return await Z(e)},async getStatus(t){let e=await fetch(`${F}/v2/scanner/public/status/${t}`,{headers:He});return await Z(e)},async getResults(t){let e=await fetch(`${F}/v2/scanner/public/results/${t}`,{headers:He});return await Z(e)},async cancelScan(t){let e=await fetch(`${F}/v2/scanner/public/scan/${t}`,{method:"DELETE",headers:ze});return await Z(e)}};var ht='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"/><path d="M12 9v4"/><path d="M12 17h.01"/></svg>',kt='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/></svg>',vt='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22 22" fill="currentColor"><path d="M11 0C17.0751 0 22 4.92487 22 11C22 17.0751 17.0751 22 11 22C4.92487 22 0 17.0751 0 11C0 4.92487 4.92487 0 11 0ZM11 2C6.02944 2 2 6.02944 2 11C2 15.9706 6.02944 20 11 20C15.9706 20 20 15.9706 20 11C20 6.02944 15.9706 2 11 2ZM13.293 7.29297C13.6835 6.90244 14.3165 6.90244 14.707 7.29297C15.0975 7.6835 15.0975 8.31653 14.707 8.70703L12.4141 11L14.707 13.293C15.0975 13.6835 15.0975 14.3165 14.707 14.707C14.3165 15.0975 13.6835 15.0975 13.293 14.707L11 12.4141L8.70703 14.707C8.31653 15.0975 7.6835 15.0975 7.29297 14.707C6.90244 14.3165 6.90244 13.6835 7.29297 13.293L9.58594 11L7.29297 8.70703C6.90244 8.31651 6.90244 7.68349 7.29297 7.29297C7.68349 6.90244 8.31651 6.90244 8.70703 7.29297L11 9.58594L13.293 7.29297Z"/></svg>',Ct='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m2 2 20 20"/><path d="M8.35 2.69A10 10 0 0 1 21.3 15.65"/><path d="M19.08 19.08A10 10 0 1 1 4.92 4.92"/></svg>',Et='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 16h.01M12 8v4M7.86 2h8.28L22 7.86v8.28L16.14 22H7.86L2 16.14V7.86z"/></svg>',xt='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m9 18 6-6-6-6"/></svg>',bt='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="12" x2="12" y1="8" y2="12"/><line x1="12" x2="12.01" y1="16" y2="16"/></svg>',St='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/></svg>',Tt='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"/><path d="M12 17h.01"/></svg>',It={"warning-triangle":ht,"check-circle":kt,"close-circle":vt,"circle-off":Ct,"alert-octagon":Et,"chevron-right":xt,"alert-circle":bt,clock:St,"help-circle":Tt},wt=(t,e)=>{let o=It[t];return e?.color&&(o=o.replace(/currentColor/g,e.color)),e?.size&&(o=o.replace("<svg",`<svg width="${e.size}" height="${e.size}"`)),o},N=(t,e,o)=>{let n=wt(e,o),s=document.createElement("template");s.innerHTML=n.trim();let r=s.content.firstElementChild;if(!r)return null;if(r.setAttribute("data-fs-icon",e),o?.size&&(r.style.setProperty("width",`${o.size}px`,"important"),r.style.setProperty("height",`${o.size}px`,"important")),t.className){let i=r.getAttribute("class")||"";r.setAttribute("class",`${i} ${t.className}`.trim())}return t.replaceWith(r),r};var Rt=1e3,X={compliant:"check-circle",notCompliant:"close-circle"},Pe={pass:{icon:"check-circle",color:y["success-foreground"],label:"pass"},fail:{icon:"alert-circle",color:y["error-foreground"],label:"fail"},"not-verifiable":{icon:"help-circle",color:y.info,label:"not verifiable"}},Lt=()=>{let t=new URLSearchParams(window.location.search),e=t.get("trid"),o=t.get("site");return!e||!o?(console.error("[Results] Missing required query parameters:",{trid:e,site:o}),window.location.assign("/scan"),null):{trackingId:e,site:o}},At=t=>{let e=a("current-scan-activity");e&&(e.textContent=t,console.log(`[Results] Current scan activity: ${t}`))},Mt=(t,e)=>{let o=a("scan-progress");if(o){let n=e>0?Math.round(t/e*100):0;o.textContent=`${t} / ${e} pages (${n}%)`,console.log(`[Results] Scan progress: ${t} / ${e} pages (${n}%)`)}},Dt=()=>{let t=a("scan-progress-container"),e=a("scan-error-container");t&&(t.style.display="flex"),e&&(e.style.display="none")},Q=t=>{let e=a("scan-progress-container"),o=a("scan-error-container"),n=a("current-scan-error");e&&(e.style.display="none"),o&&(o.style.display="flex"),n&&(n.innerHTML=t)},Ht=async t=>(Dt(),new Promise((e,o)=>{let n=setInterval(async()=>{try{let s=await K.getStatus(t);if(console.log("[Results] Polled scan status:",s),s.currentActivity&&At(s.currentActivity),s.progress){let{pagesScanned:r,totalPages:i}=s.progress;Mt(r,i)}if(s.status==="completed")clearInterval(n),e();else if(s.status==="failed"){let r=s.error||"Scan failed unexpectedly";console.error("[Results] Scan failed:",r),Q(`Scan failed: ${r}`),clearInterval(n),o(new Error(r))}}catch(s){console.error("[Results] Error polling status:",s),Q("Unable to check scan status. Please try again."),clearInterval(n),o(s)}},Rt)})),zt=()=>{let t=a("scan-status_style");t&&t.remove()},Pt=async t=>K.getResults(t),Nt=t=>{if(!t.results)return null;let{pagesScanned:e,issues:o}=t.results;return e.length>0?null:o.siteInaccessible?o.siteInaccessible:o.notFound&&o.notFound.length>0?"<strong>No pages found</strong><br><br>We couldn't find any pages at the URL you provided. Please ensure you entered the correct URL and try scanning again.":"<strong>Scan completed with no pages</strong><br><br>No pages were scanned. Please verify the URL is correct and the site is publicly accessible, then try again."},$t=t=>{if(!t.results)return;let{pagesScanned:e,origin:o}=t.results,n=e.length>0?e[0]:o;P("target-website").forEach(i=>{i.textContent=n}),P("target-website-url").forEach(i=>{i instanceof HTMLAnchorElement?i.href=n:i.textContent=n})},Ot=t=>{let e=R.extractFullCompliance(t),o=a("compliance-score");if(o){let n=a("value",o);if(n){let s=Math.round(e.overallScore);n.textContent=`${s}%`;let r;s>=80?r=y["success-foreground"]:s>=50?r=y["warning-foreground"]:r=y["error-foreground"],n.style.color=r}}},Ut=t=>{P("target-website").forEach(n=>{n.textContent=t}),P("target-website-url").forEach(n=>{n instanceof HTMLAnchorElement?n.href=t:n.textContent=t})},_t=t=>{let e=Math.floor(t/1e3);if(e<60)return`${e}s`;let o=Math.floor(e/60),n=e%60;return`${o}m ${n}s`},Ft=t=>new Date(t).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),H=(t,e,o,n)=>{let s=a(t);if(!s)return;let r=a("value",s),i=a("text",s);r&&(r.textContent=e),i&&o&&(i.textContent=o),n&&(s.style.backgroundColor=y[n])},Vt=t=>{if(!t.results)return;let{scanDuration:e,pagesScanned:o,detectedItems:n,scannedAt:s}=t.results;H("scan-duration-card",_t(e)),H("pages-scanned-card",o.length.toString()),H("items-detected-card",n.length.toString()),H("scan-date-card",Ft(s))},jt=t=>{if(!t.results)return;let{detectedItems:e,trackersInfo:o}=t.results,n=o?.trackers??[],s=D.affiliatedDOMResources(e,n).length,r=D.loadedStorageResources(e).length,m=R.extractFullCompliance(t).summary.failed,{cmpInstalled:c}=R.extractActionableItems(t);H("scripts-detected-card",s.toString(),void 0,s===0?"success":"error"),H("cookies-detected-card",r.toString(),void 0,r===0?"success":"warning"),H("action-items-card",m.toString(),"Violations",m===0?"success":"error"),qt(!!c)},qt=t=>{let e=a("cmp-status-card");if(!e)return;let o=a("icon",e),n=a("text",e),s=t?y["success-foreground"]:y["error-foreground"];o&&N(o,t?X.compliant:X.notCompliant,{color:s,size:24}),n&&(n.textContent=t?"CMP Detected":"CMP Not Found"),e.style.backgroundColor=t?y.success:y.error},Bt=t=>{if(!t.results)return;let e=P("compliance-container");if(e.length===0)return;let o=R.extractFullCompliance(t),{summary:n}=o,s=n.failed,r=s===0?"compliant":"non-compliant",i=()=>{if(s===0)return"No compliance violations detected. Nice work!";let f=o.criteria.filter(v=>v.status==="fail").map(v=>v.name);return`Found ${s} issue${s>1?"s":""}: ${f.slice(0,3).join(", ")}${f.length>3?", ...":""}. Action needed.`},c={compliant:{label:"Compliant",message:i(),icon:X.compliant,color:y.success,iconColor:y["success-foreground"]},"non-compliant":{label:"Not Compliant",message:i(),icon:X.notCompliant,color:y.error,iconColor:y["error-foreground"]}}[r];e.forEach(f=>{f.setAttribute("fs-cloak",""),f.classList.add("hide")});let l=null;e.forEach(f=>{(r==="compliant"&&f.classList.contains("compliant")||r!=="compliant"&&!f.classList.contains("compliant"))&&(l=f)}),l||([l]=e),l.removeAttribute("fs-cloak"),l.classList.remove("hide");let p=a("compliance-status",l);if(p){let f=a("icon",p),v=a("text",p);f&&N(f,c.icon,{color:c.iconColor,size:30}),v&&(v.textContent=c.label)}let g=a("compliance-details",l);g&&(g.textContent=c.message);let d=a("violations-wrapper",l);if(d){let f=a("value",d);f&&(f.textContent=s.toString())}l.style.backgroundColor=c.color},Wt=t=>{if(!t.results)return;let{trackersInfo:e}=t.results,o=a("violations-component"),n=a("violations-list"),s=a("violation-template");if(!n||!s)return;let r=D.violatingTrackers(e?.trackers??[]);if(o){let d=a("icon",o);d&&N(d,"alert-octagon",{color:y["error-foreground"],size:24})}Array.from(n.children).forEach(d=>{d!==s&&d.remove()}),s.style.display="none";let m=a("violations-list-empty");if(r.length===0){m&&(m.removeAttribute("fs-cloak"),m.classList.remove("hide")),n.setAttribute("fs-cloak",""),n.classList.add("hide");return}m&&(m.setAttribute("fs-cloak",""),m.classList.add("hide")),n.removeAttribute("fs-cloak"),n.classList.remove("hide");let c=e?.providers??[],l=new Map;c.forEach(d=>l.set(d.id,d.name));let p={analytics:"\u{1F4CA}",marketing:"\u{1F4E2}",advertising:"\u{1F4FA}",functional:"\u2699\uFE0F",uncategorized:"\u2753"},g=new Set;r.forEach(d=>{let v=l.get(d.providerId)||d.name||d.domain||d.providerId||"Unknown",x=`${d.category}-${v}`;if(g.has(x))return;g.add(x);let h=s.cloneNode(!0);h.removeAttribute("data-fs-cs"),h.style.display="";let I=a("icon",h);I&&N(I,"chevron-right",{color:y["error-foreground"],size:16});let C=a("text",h);if(C){let u=p[d.category]??"\u{1F534}",k=d.category||"uncategorized";C.textContent=`${u} ${v}: ${k} tracker running before consent`}n.appendChild(h)})},Gt=t=>{let e=t?.toLowerCase()||"uncategorized";return["uncategorized","unknown","marketing","advertising"].includes(e)?y["error-foreground"]:["analytics","performance","functional","personalization"].includes(e)?y["warning-foreground"]:["essential","necessary","strictly-necessary","strictly_necessary"].includes(e)?null:y["error-foreground"]},V=t=>{let e=t?.toLowerCase()||"uncategorized";return["uncategorized","unknown"].includes(e)?1:["marketing","advertising"].includes(e)?2:["analytics","performance"].includes(e)?3:["functional","personalization"].includes(e)?4:["essential","necessary","strictly-necessary","strictly_necessary"].includes(e)?5:1},Ne=t=>{switch(V(t)){case 1:return"Highest Violation Risk - Uncategorized resource requiring immediate attention";case 2:return"High Violation Risk - Marketing/Advertising tracker requiring consent";case 3:return"Medium Violation Risk - Analytics/Performance tracker requiring consent";case 4:return"Low Violation Risk - Functional resource that may require consent";case 5:return"No Violation Risk - Essential resource";default:return"Unknown risk level"}},$e=t=>{let e=Gt(t);return e?e===y["error-foreground"]?"brightness(0) saturate(100%) invert(21%) sepia(100%) saturate(7000%) hue-rotate(336deg) brightness(100%) contrast(105%)":e===y["warning-foreground"]?"brightness(0) saturate(100%) invert(68%) sepia(78%) saturate(1000%) hue-rotate(4deg) brightness(103%) contrast(104%)":null:null},Yt=t=>{if(!t.results)return;let{detectedItems:e,trackersInfo:o}=t.results,n=o?.trackers??[],s=o?.providers??[],r=new Map;s.forEach(C=>r.set(C.id,C.name));let i=new Map;D.violatingTrackers(n).forEach(C=>{C.resources?.forEach(u=>{i.set(u.id,C)})});let c=D.loadedDOMResources(e).sort((C,u)=>V(C.category)-V(u.category)),l=D.loadedStorageResources(e).sort((C,u)=>V(C.category)-V(u.category)),p=a("scripts-component"),g=a("script-list"),d=a("script-item"),f=a("script-list-empty");if(g&&d){if(p){let u=a("scripts-title",p);u&&(u.textContent=`Detected DOM Resources (${c.length})`)}Array.from(g.children).forEach(u=>{u!==d&&u.remove()}),d.style.display="none",c.length===0?(f&&(f.removeAttribute("fs-cloak"),f.classList.remove("hide")),g.setAttribute("fs-cloak",""),g.classList.add("hide")):(f&&(f.setAttribute("fs-cloak",""),f.classList.add("hide")),g.removeAttribute("fs-cloak"),g.classList.remove("hide"),c.forEach(u=>{let k=d.cloneNode(!0);k.removeAttribute("data-fs-cs"),k.style.display="";let $=a("script-title",k),O=a("script-url",k),U=a("script-type",k),E=a("script-tag",k),S=a("icon",k);if($&&($.textContent=`${u.domain||`Unknown ${u.type}`}`),O&&(O.textContent=u.source?.slice(0,100)||"N/A"),U&&(U.textContent=u.type||"N/A"),E){let b=i.get(u.id);if(b){let M=r.get(b.providerId)||b.label||"Unknown";E.textContent=M,E.style.display="",E.style.backgroundColor="#363636",E.style.color="#ffffff"}else E.style.display="none";E.classList.remove("is-marketing","is-analytics","is-advertising","is-uncategorized")}if(S){let b=i.get(u.id);if(b){let M=b.category||"uncategorized",fe=$e(M);fe?(S.style.display="",S.style.filter=fe,S.title=Ne(M)):S.style.display="none"}else S.style.display="none"}g.appendChild(k)}))}let v=a("cookies-component"),x=a("cookie-list"),h=a("cookie-item"),I=a("cookie-list-empty");if(x&&h){if(v){let u=a("cookies-title",v);u&&(u.textContent=`Cookies & Storage Data (${l.length})`)}Array.from(x.children).forEach(u=>{u!==h&&u.remove()}),h.style.display="none",l.length===0?(I&&(I.removeAttribute("fs-cloak"),I.classList.remove("hide")),x.setAttribute("fs-cloak",""),x.classList.add("hide")):(I&&(I.setAttribute("fs-cloak",""),I.classList.add("hide")),x.removeAttribute("fs-cloak"),x.classList.remove("hide"),l.forEach(u=>{let k=h.cloneNode(!0);k.removeAttribute("data-fs-cs"),k.style.display="";let $=a("cookie-name",k),O=a("cookie-url",k),U=a("cookie-type",k),E=a("cookie-tag",k),S=a("icon",k);if($&&($.textContent=`${u.name||`Unknown ${u.type}`}`),O&&(O.textContent=u.domain||"N/A"),U&&(U.textContent=u.type||"N/A"),E){let b=u.category||"uncategorized";E.textContent=b,E.classList.remove("is-marketing","is-analytics","is-advertising","is-uncategorized"),E.classList.add(`is-${b}`),b==="uncategorized"&&(E.style.backgroundColor="#8f0c3d",E.style.color="#ffffff")}if(S){let b=u.category||"uncategorized",M=$e(b);M?(S.style.display="",S.style.filter=M,S.title=Ne(b)):S.style.display="none"}x.appendChild(k)}))}},Zt=t=>{let e=R.extractAttentionItems(t),o=a("attention-list"),n=a("attention-item"),s=a("attention-list-empty");if(!(!o||!n)){if(n.style.display="none",e.length===0){s&&(s.removeAttribute("fs-cloak"),s.classList.remove("hide")),o.setAttribute("fs-cloak",""),o.classList.add("hide");return}s&&(s.setAttribute("fs-cloak",""),s.classList.add("hide")),o.removeAttribute("fs-cloak"),o.classList.remove("hide"),e.forEach((r,i)=>{let m=n.cloneNode(!0);m.removeAttribute("data-fs-cs"),m.style.display="";let c=a("value",m);c&&(c.textContent=(i+1).toString());let l=a("text",m);l&&(l.textContent=r),o.appendChild(m)})}},Kt=t=>{let e=R.extractComplianceSummary(t),o=a("passed-items");if(o){let r=a("value",o);r&&(r.textContent=e.pass.toString())}let n=a("failed-items");if(n){let r=a("value",n);r&&(r.textContent=e.fail.toString())}let s=a("unverified-items");if(s){let r=a("value",s);r&&(r.textContent=e.unverified.toString())}},Xt=t=>{let e=R.extractFullCompliance(t),o=a("criteria-list"),n=a("criteria-item");if(!o||!n)return;Array.from(o.children).forEach(i=>{i!==n&&i.remove()}),n.style.display="none",e.criteria.filter(i=>i.status!=="not-verifiable").forEach(i=>{let m=n.cloneNode(!0);m.removeAttribute("data-fs-cs"),m.style.display="";let c=Pe[i.status]||Pe["not-verifiable"],l=a("icon",m);l&&N(l,c.icon,{color:c.color,size:24});let p=a("criteria-title",m),g=a("criteria-description",m);p&&(p.textContent=i.name),g&&(g.textContent=i.description);let d=a("criteria-status",m);d&&(d.textContent=c.label);let f=a("criteria-answer",m);f&&(f.textContent=i.details||"No additional details available."),o.appendChild(m)})},Qt=t=>{let e=R.extractStatistics(t),o=a("stat-duration");if(o){let c=a("value",o);c&&(c.textContent=e.scanDuration)}let n=a("stat-resources");if(n){let c=a("value",n);c&&(c.textContent=e.resourcesCount.toString())}let s=a("stat-storage");if(s){let c=a("value",s);c&&(c.textContent=e.storageCount.toString())}let r=a("stat-first-party");if(r){let c=a("value",r);c&&(c.textContent=e.firstParty.toString())}let i=a("stat-third-party");if(i){let c=a("value",i);c&&(c.textContent=e.thirdParty.toString())}let m=a("stat-categories");if(m){let c=a("value",m);c&&(c.textContent=e.categories.toString())}},Jt=[{name:"websiteInfo",updater:$t},{name:"complianceScore",updater:Ot,requiredElements:["compliance-score"]},{name:"primaryStats",updater:Vt},{name:"secondaryStats",updater:jt},{name:"complianceContainer",updater:Bt,requiredElements:["compliance-container"]},{name:"violationsList",updater:Wt,requiredElements:["violations-list"]},{name:"detectedItems",updater:Yt},{name:"attentionItems",updater:Zt,requiredElements:["attention-list"]},{name:"complianceSummary",updater:Kt},{name:"complianceCriteria",updater:Xt,requiredElements:["criteria-list"]},{name:"statistics",updater:Qt}],eo=t=>{Jt.forEach(({name:e,updater:o,requiredElements:n})=>{try{if(n&&n.find(r=>!a(r)))return;o(t)}catch(s){console.error(`[Results] Error in updater "${e}":`,s)}}),te()},to=async()=>{let t=Lt();if(!t){console.error("[Results] Cannot fetch results without tracking ID");return}let e;try{new URL(t.site),e=t.site}catch{e=`https://${t.site}`}Ut(e);try{await Ht(t.trackingId);let o=await Pt(t.trackingId);console.log("[Results] Fetched results:",o);let n=Nt(o);if(n){Q(n);return}eo(o),zt()}catch(o){console.error("[Results] Error during scan:",o);let n="An error occurred. Please try again.";o instanceof A&&o.response&&typeof o.response=="object"&&"error"in o.response?n=o.response.error:o instanceof Error&&(n=o.message),Q(n)}};window.Webflow||(window.Webflow=[]);window.Webflow.push(()=>{to()});})();
|
|
5
|
+
`),console.log("----------------------------------------"),console.log("CRITERIA BREAKDOWN:"),console.log("----------------------------------------");let m=[];for(let l of n){let p=1;l.id==="pre-consent-trackers"?p=3:s.includes(l.id)&&(p=2);let y=l.status==="pass"?1:0,d=y*p;m.push({id:l.id,status:l.status,weight:p,points:y,contribution:d}),r+=d,i+=p}for(let l of m){let p=l.status==="pass"?"\u2713":"\u2717",y=l.status==="pass"?"PASS":"FAIL";console.log(`${p} ${l.id.padEnd(25)} | ${y.padEnd(4)} | weight: ${l.weight} | points: ${l.points} | contribution: ${l.contribution}`)}console.log("----------------------------------------"),console.log(`TOTALS: ${r} points / ${i} weight`);let c=Math.round(r/i*100);return console.log(`CALCULATION: (${r} / ${i}) \xD7 100 = ${(r/i*100).toFixed(2)}%`),console.log(`FINAL SCORE: ${c}%`),console.log("----------------------------------------"),console.log(`SUMMARY: ${o.passed} passed, ${o.failed} failed, ${o.notVerifiable} not-verifiable`),console.log(`STATUS: ${o.failed===0?"COMPLIANT \u2713":"NOT COMPLIANT \u2717"}`),console.log(`========================================
|
|
6
|
+
`),{overallScore:c,hasViolations:o.failed>0,criteria:e,summary:o}}function G(t){if(!t.results)throw new Error("No results found in response for compliance evaluation");return Ce(t.results)}function ot(t){let e=t.trackersInfo?.trackers??[],o=t.trackersInfo?.providers??[],n=new Map;o.forEach(p=>n.set(p.id,p.name));let s=U(e),r=q(e).length,i=W(e).length,m=[...new Set(s.map(p=>n.get(p.providerId)||p.name||p.domain||p.providerId))];if(s.length===0)return{id:"pre-consent-trackers",name:"Pre-Consent Trackers",description:"Check for tracking scripts running before user consent",status:"pass",details:"No tracking scripts detected running before consent."};let c=[];r>0&&c.push(`${r} analytics`),i>0&&c.push(`${i} marketing`);let l=s.length-r-i;return l>0&&c.push(`${l} other`),{id:"pre-consent-trackers",name:"Pre-Consent Trackers",description:"Check for tracking scripts running before user consent",status:"fail",details:`Found ${s.length} tracker(s) running before consent (${c.join(", ")}). These should be blocked until user provides consent.`,affectedItems:m}}function nt(t){let e=t.detectedItems.filter(S).filter(s=>ye.test(s.domain)||ye.test(s.source)),o=e.map(s=>s.id);if(e.length===0)return{id:"video-embeds",name:"YouTube/Vimeo Detection",description:"Detect YouTube or Vimeo video embeds that may store cookies",status:"pass",details:"No YouTube or Vimeo embeds detected."};let n=e.filter(s=>s.isThirdParty);return{id:"video-embeds",name:"YouTube/Vimeo Detection",description:"Detect YouTube or Vimeo video embeds that may store cookies",status:"fail",details:`Found ${e.length} video embed(s) from YouTube/Vimeo. ${n.length} are third-party resources that may store cookies before consent.`,affectedItems:o}}function st(t){let e=t.detectedItems.filter(S).filter(n=>he.test(n.domain)||he.test(n.source)),o=e.map(n=>n.id);return e.length===0?{id:"google-maps",name:"Google Maps Detection",description:"Detect Google Maps embeds that may store cookies",status:"pass",details:"No Google Maps embeds detected."}:{id:"google-maps",name:"Google Maps Detection",description:"Detect Google Maps embeds that may store cookies",status:"fail",details:`Found ${e.length} Google Maps embed(s) that may store cookies before consent.`,affectedItems:o}}function rt(t){let e=t.detectedItems.filter(S).filter(n=>ke.test(n.domain)||ke.test(n.source)),o=e.map(n=>n.id);return e.length===0?{id:"external-fonts",name:"External Fonts Detection",description:"Detect external fonts (Google Fonts, Typekit, etc.) which transfer IP addresses without consent",status:"pass",details:"No external fonts detected. Website may be using self-hosted fonts."}:{id:"external-fonts",name:"External Fonts Detection",description:"Detect external fonts (Google Fonts, Typekit, etc.) which transfer IP addresses without consent",status:"fail",details:`Found ${e.length} external font resource(s). This transfers visitor IP addresses to third-party servers without consent, which may violate data privacy regulations (GDPR, CCPA, HIPAA, etc.). Fonts should be self-hosted or loaded only after consent.`,affectedItems:o}}function ue(t){if(t.detectedCmps&&t.detectedCmps.length>0)return{id:"consent-tool",name:"Consent Tool Detection",description:"Check if a cookie consent management tool is installed",status:"pass",details:`Detected consent tool(s): ${t.detectedCmps.map(r=>r.version?`${r.name} (v${r.version})`:r.name).join(", ")}`};let e=[],o=new Map;for(let s of et){let r=0;if(t.detectedItems&&Array.isArray(t.detectedItems)){for(let i of t.detectedItems)if(S(i)&&i.type==="script"){let{source:m}=i,c=i.element?.outerHTML||"";for(let l of s.patterns.scripts)if(l.test(m)||l.test(c)){r+=1,e.includes(i.id)||e.push(i.id);break}}}if(t.trackersInfo?.providers&&Array.isArray(t.trackersInfo.providers))for(let i of t.trackersInfo.providers){let m=i.name||"";for(let c of s.patterns.scripts)if(c.test(m)){r+=1,e.includes(i.id)||e.push(i.id);break}}if(t.detectedItems&&Array.isArray(t.detectedItems)){for(let i of t.detectedItems)if(T(i)&&i.type==="cookie"){let{name:m}=i;for(let c of s.patterns.cookies)if(c.test(m)){r+=1,e.includes(i.id)||e.push(i.id);break}}}if(t.detectedItems&&Array.isArray(t.detectedItems))for(let i of t.detectedItems){let c=S(i)&&i.element?.outerHTML||"";for(let l of s.patterns.dom)if(l.test(c)){r+=1,e.includes(i.id)||e.push(i.id);break}}if(t.detectedItems&&Array.isArray(t.detectedItems)){for(let i of t.detectedItems)if(oe(i)){let m=i.element||"",c=s.patterns.banners||s.patterns.dom;for(let l of c)if(l.test(m)){r+=3,e.includes(i.id)||e.push(i.id);break}}}r>0&&o.set(s.name,r)}let n=Array.from(o.entries()).sort((s,r)=>r[1]-s[1]).map(([s])=>s);return n.length===0?{id:"consent-tool",name:"No cookie consent tool detected",description:"Check if a cookie consent management tool is installed",status:"fail",details:"No cookie consent tool detected. A consent banner is required for compliance with data privacy regulations (GDPR, CCPA, etc.). Note: Not all CMP tools can be automatically detected. If you have a CMP installed that is not recognized, please verify manually."}:{id:"consent-tool",name:"Consent Tool Detection",description:"Check if a cookie consent management tool is installed",status:"pass",details:`Detected consent tool(s): ${n.join(", ")}. Note: Detection is based on known patterns and may not identify all CMP configurations.`,affectedItems:e}}function it(t){let o=(t.trackersInfo?.trackers??[]).filter(s=>ve.test(s.label)||ve.test(s.domain??"")?!1:!s.category||s.category==="uncategorized"),n=o.map(s=>s.id);return o.length===0?{id:"uncategorized-trackers",name:"Uncategorized Trackers",description:"Check for trackers without proper categorization",status:"pass",details:"All trackers are properly categorized."}:{id:"uncategorized-trackers",name:"Uncategorized Trackers",description:"Check for trackers without proper categorization",status:"fail",details:`Found ${o.length} uncategorized tracker(s). These should be categorized for proper consent management.`,affectedItems:n}}function at(t){let e=V(t.detectedItems),o=e.map(n=>n.id);return e.length===0?{id:"non-essential-cookies",name:"Non-Essential Cookies",description:"Check for non-essential cookies set before consent",status:"pass",details:"No non-essential cookies detected before consent."}:{id:"non-essential-cookies",name:"Non-Essential Cookies",description:"Check for non-essential cookies set before consent",status:"fail",details:`Found ${e.length} non-essential cookie(s) being set before consent. These should be blocked until user provides consent.`,affectedItems:o}}function ct(t){let e=j(t.detectedItems),o=e.map(n=>n.id);return e.length===0?{id:"uncategorized-cookies",name:"Uncategorized Cookies",description:"Check for cookies without proper categorization",status:"pass",details:"All cookies are properly categorized."}:{id:"uncategorized-cookies",name:"Uncategorized Cookies",description:"Check for cookies without proper categorization",status:"fail",details:`Found ${e.length} uncategorized cookie(s). These should be reviewed and assigned to appropriate consent categories.`,affectedItems:o}}function lt(t){let e=t.detectedItems??[];if(!e.some(c=>S(c)&&c.type==="script"&&tt.test(c.source)))return{id:"webflow-optimize",name:"Webflow Optimize Detection",description:"Detect Webflow Optimize and Analyze configurations",status:"pass",details:"Webflow Optimize/Analyze (Intellimize) not detected."};if(ue(t).status!=="pass")return{id:"webflow-optimize",name:"Webflow Optimize Detection",description:"Detect Webflow Optimize and Analyze configurations",status:"pass",details:"Webflow Optimize detected; no CMP\u2014consent-gating not applicable."};let s=e.filter(c=>T(c)&&c.type==="cookie"&&me.test(c.name)),r=e.filter(c=>T(c)&&c.type==="session-storage"&&me.test(c.name)),i=e.filter(c=>T(c)&&c.type==="local-storage"&&me.test(c.name)),m=[];if(s.length>0&&m.push(`${s.length} cookie(s)`),r.length>0&&m.push(`${r.length} session-storage key(s)`),i.length>0&&m.push(`${i.length} local-storage key(s)`),m.length>0){let c=[...s.map(l=>l.id),...r.map(l=>l.id),...i.map(l=>l.id)];return{id:"webflow-optimize",name:"Webflow Optimize Detection",description:"Detect Webflow Optimize and Analyze configurations",status:"fail",details:`Intellimize cookies/storage present despite CMP: ${m.join(", ")}.`,affectedItems:c}}return{id:"webflow-optimize",name:"Webflow Optimize Detection",description:"Detect Webflow Optimize and Analyze configurations",status:"pass",details:"Webflow Optimize detected; CMP present and no Intellimize cookies or storage detected."}}function pe(t){if(t.detectedCmps&&t.detectedCmps.length>0)return t.detectedCmps.map(n=>n.name).join(", ");let e=ue(t);return e.status!=="pass"||!e.details?null:e.details.match(/Detected consent tool\(s\): (.+)/)?.[1]?.trim()??null}function Ee(t){return Ce(t).criteria.filter(o=>o.status==="fail").map(o=>`${o.name}: ${o.details}`)}function be(t){let e=[],o=t.trackersInfo?.trackers??[],n=t.trackersInfo?.providers??[],s=t.detectedItems??[],r=H(s),i=new Map;n.forEach(k=>i.set(k.id,k.name));let m=U(o),c=q(o),l=W(o);if(c.length>0){let k=de(c,3,i);e.push(`${c.length} analytics tracker(s) running before consent: ${k}`)}if(l.length>0){let k=de(l,3,i);e.push(`${l.length} marketing tracker(s) firing before consent: ${k}`)}let p=m.filter(k=>k.category!=="analytics"&&k.category!=="marketing");if(p.length>0){let k=de(p,3,i);e.push(`${p.length} other tracker(s) need consent: ${k}`)}let y=V(r);y.length>0&&e.push(`${y.length} non-essential cookies set before consent`);let d=j(r);d.length>0&&e.push(`${d.length} uncategorized cookies detected - review and categorize`);let f=ae(r),v=ce(r),b=f.length+v.length;return b>0&&e.push(`${b} localStorage/sessionStorage items set pre-consent`),pe(t)||e.push("No consent management platform detected"),e}function de(t,e,o){let n=[...new Set(t.map(s=>o.get(s.providerId)||s.name||s.domain||"Unknown"))];return n.length<=e?n.join(", "):`${n.slice(0,e).join(", ")} +${n.length-e} more`}var mt=localStorage.getItem("cs-dev")==="true",_=mt?"https://fs-consentpro-api-dev.finsweet.workers.dev":"https://api.consentpro.com",ho=1440*60*1e3;var g={success:"#07601d",warning:"#bb5902",error:"#8F0C3D",info:"#598FFF",neutral:"#363636",white:"#ffffff","neutral-foreground":"#6f6f6f","success-foreground":"#25fc54","warning-foreground":"#FFAA00","error-foreground":"#FF265A","info-foreground":"#d5e8ff"};function xe(t){if(!t.results)throw new Error("No results found in response for scan summary extraction");let{results:e}=t;return{scanId:e.trackingId,scanDuration:e.scanDuration,pagesScanned:e.pagesScanned.length,totalPages:e.totalPagesFound,detectedItemsCount:e.detectedItems.length,scannedAt:e.scannedAt}}function Se(t){let e=G(t);return{compliant:!e.hasViolations,score:e.overallScore,violations:e.summary.failed}}function Ie(t){if(!t.results)throw new Error("No results found in response for actionable items extraction");let{results:e}=t,o=re(e.detectedItems).length,n=ie(e.detectedItems).length,s=pe(e);return{scripts:o,cookies:n,cmpInstalled:s??void 0}}function Te(t){if(!t.results)throw new Error("No results found in response for violations extraction");return Ee(t.results)}function we(t){if(!t.results)throw new Error("No results found in response for detected items extraction");let{results:e}=t,o=se(e.detectedItems),n=H(e.detectedItems);return{dom:o,storage:n}}function Re(t){let e=G(t);return{pass:e.summary.passed,fail:e.summary.failed,unverified:e.summary.notVerifiable}}function Le(t){if(!t.results)throw new Error("No results found in response for attention items extraction");return be(t.results)}function Ae(t){if(!t.results)throw new Error("No results found in response for statistics extraction");let{results:e}=t;return{scanDuration:pt(e.scanDuration),resourcesCount:e.detectedItems.length,storageCount:H(e.detectedItems).length,firstParty:e.statistics?.firstPartyResources??0,thirdParty:e.statistics?.thirdPartyResources??0,categories:Object.keys(e.statistics?.categoryCounts||{}).length}}function dt(t){return G(t)}function ut(t){return{scanSummary:xe(t),compliance:Se(t),actionableItems:Ie(t),violations:Te(t),detectedItems:we(t),complianceSummary:Re(t),attentionItems:Le(t),statistics:Ae(t)}}function pt(t){let e=Math.floor(t/1e3);if(e<60)return`${e}s`;let o=Math.floor(e/60),n=e%60;return`${o}m ${n}s`}var w={extractScanSummary:xe,extractCompliance:Se,extractActionableItems:Ie,extractViolations:Te,extractDetectedItems:we,extractComplianceSummary:Re,extractAttentionItems:Le,extractStatistics:Ae,extractFullCompliance:dt,extractAll:ut};var Me="data-fs-cs";var a=(t,e=document)=>e.querySelector(`[${Me}="${t}"]`),P=(t,e=document)=>e.querySelectorAll(`[${Me}="${t}"]`);var De={"X-Finsweet-ConsentPro-Version":"v2"},He={"X-Finsweet-ConsentPro-Version":"v2","Content-Type":"application/json"},A=class extends Error{constructor(o,n,s){super(o);J(this,"status");J(this,"response");this.name="ScannerApiError",this.status=n,this.response=s}};async function Y(t){if(!t.ok){let e=t.statusText,o;try{let n=await t.json();o=n,n&&typeof n.error=="string"&&(e=n.error)}catch{o=await t.text().catch(()=>"Unknown error")}throw new A(`Report request failed: ${e}`,t.status,o)}return t.json()}var Z={async startScan(t){let e=await fetch(`${_}/v2/scanner/public/scan`,{method:"POST",headers:He,body:JSON.stringify({url:t,acceptAll:!1})});if(e.status===409){let n=await e.json().catch(()=>({}));throw new A("A scan is already in progress for this website. Please wait for it to complete.",409,n)}if(e.status!==201){let n=await e.text().catch(()=>"Unknown error");throw new A(`Expected 201 Created but got ${e.status}`,e.status,n)}return await Y(e)},async getStatus(t){let e=await fetch(`${_}/v2/scanner/public/status/${t}`,{headers:De});return await Y(e)},async getResults(t){let e=await fetch(`${_}/v2/scanner/public/results/${t}`,{headers:De});return await Y(e)},async cancelScan(t){let e=await fetch(`${_}/v2/scanner/public/scan/${t}`,{method:"DELETE",headers:He});return await Y(e)}};var gt='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"/><path d="M12 9v4"/><path d="M12 17h.01"/></svg>',yt='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/></svg>',ht='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22 22" fill="currentColor"><path d="M11 0C17.0751 0 22 4.92487 22 11C22 17.0751 17.0751 22 11 22C4.92487 22 0 17.0751 0 11C0 4.92487 4.92487 0 11 0ZM11 2C6.02944 2 2 6.02944 2 11C2 15.9706 6.02944 20 11 20C15.9706 20 20 15.9706 20 11C20 6.02944 15.9706 2 11 2ZM13.293 7.29297C13.6835 6.90244 14.3165 6.90244 14.707 7.29297C15.0975 7.6835 15.0975 8.31653 14.707 8.70703L12.4141 11L14.707 13.293C15.0975 13.6835 15.0975 14.3165 14.707 14.707C14.3165 15.0975 13.6835 15.0975 13.293 14.707L11 12.4141L8.70703 14.707C8.31653 15.0975 7.6835 15.0975 7.29297 14.707C6.90244 14.3165 6.90244 13.6835 7.29297 13.293L9.58594 11L7.29297 8.70703C6.90244 8.31651 6.90244 7.68349 7.29297 7.29297C7.68349 6.90244 8.31651 6.90244 8.70703 7.29297L11 9.58594L13.293 7.29297Z"/></svg>',kt='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m2 2 20 20"/><path d="M8.35 2.69A10 10 0 0 1 21.3 15.65"/><path d="M19.08 19.08A10 10 0 1 1 4.92 4.92"/></svg>',vt='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 16h.01M12 8v4M7.86 2h8.28L22 7.86v8.28L16.14 22H7.86L2 16.14V7.86z"/></svg>',Ct='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m9 18 6-6-6-6"/></svg>',Et='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="12" x2="12" y1="8" y2="12"/><line x1="12" x2="12.01" y1="16" y2="16"/></svg>',bt='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/></svg>',xt='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"/><path d="M12 17h.01"/></svg>',St={"warning-triangle":gt,"check-circle":yt,"close-circle":ht,"circle-off":kt,"alert-octagon":vt,"chevron-right":Ct,"alert-circle":Et,clock:bt,"help-circle":xt},It=(t,e)=>{let o=St[t];return e?.color&&(o=o.replace(/currentColor/g,e.color)),e?.size&&(o=o.replace("<svg",`<svg width="${e.size}" height="${e.size}"`)),o},z=(t,e,o)=>{let n=It(e,o),s=document.createElement("template");s.innerHTML=n.trim();let r=s.content.firstElementChild;if(!r)return null;if(r.setAttribute("data-fs-icon",e),o?.size&&(r.style.setProperty("width",`${o.size}px`,"important"),r.style.setProperty("height",`${o.size}px`,"important")),t.className){let i=r.getAttribute("class")||"";r.setAttribute("class",`${i} ${t.className}`.trim())}return t.replaceWith(r),r};var Tt=1e3,K={compliant:"check-circle",notCompliant:"close-circle"},Pe={pass:{icon:"check-circle",color:g["success-foreground"],label:"pass"},fail:{icon:"alert-circle",color:g["error-foreground"],label:"fail"},"not-verifiable":{icon:"help-circle",color:g.info,label:"not verifiable"}},wt=()=>{let t=new URLSearchParams(window.location.search),e=t.get("trid"),o=t.get("site");return!e||!o?(console.error("[Results] Missing required query parameters:",{trid:e,site:o}),window.location.assign("/scan"),null):{trackingId:e,site:o}},Rt=t=>{let e=a("current-scan-activity");e&&(e.textContent=t,console.log(`[Results] Current scan activity: ${t}`))},Lt=(t,e)=>{let o=a("scan-progress");if(o){let n=e>0?Math.round(t/e*100):0;o.textContent=`${t} / ${e} pages (${n}%)`,console.log(`[Results] Scan progress: ${t} / ${e} pages (${n}%)`)}},At=()=>{let t=a("scan-progress-container"),e=a("scan-error-container");t&&(t.style.display="flex"),e&&(e.style.display="none")},X=t=>{let e=a("scan-progress-container"),o=a("scan-error-container"),n=a("current-scan-error");e&&(e.style.display="none"),o&&(o.style.display="flex"),n&&(n.innerHTML=t)},Mt=async t=>(At(),new Promise((e,o)=>{let n=setInterval(async()=>{try{let s=await Z.getStatus(t);if(console.log("[Results] Polled scan status:",s),s.currentActivity&&Rt(s.currentActivity),s.progress){let{pagesScanned:r,totalPages:i}=s.progress;Lt(r,i)}if(s.status==="completed")clearInterval(n),e();else if(s.status==="failed"){let r=s.error||"Scan failed unexpectedly";console.error("[Results] Scan failed:",r),X(`Scan failed: ${r}`),clearInterval(n),o(new Error(r))}}catch(s){console.error("[Results] Error polling status:",s),X("Unable to check scan status. Please try again."),clearInterval(n),o(s)}},Tt)})),Dt=()=>{let t=a("scan-status_style");t&&t.remove()},Ht=async t=>Z.getResults(t),Pt=t=>{if(!t.results)return null;let{pagesScanned:e,issues:o}=t.results;return e.length>0?null:o.siteInaccessible?o.siteInaccessible:o.notFound&&o.notFound.length>0?"<strong>No pages found</strong><br><br>We couldn't find any pages at the URL you provided. Please ensure you entered the correct URL and try scanning again.":"<strong>Scan completed with no pages</strong><br><br>No pages were scanned. Please verify the URL is correct and the site is publicly accessible, then try again."},zt=t=>{if(!t.results)return;let{pagesScanned:e,origin:o}=t.results,n=e.length>0?e[0]:o;P("target-website").forEach(i=>{i.textContent=n}),P("target-website-url").forEach(i=>{i instanceof HTMLAnchorElement?i.href=n:i.textContent=n})},Nt=t=>{let e=w.extractFullCompliance(t),o=a("compliance-score");if(o){let n=a("value",o);if(n){let s=Math.round(e.overallScore);n.textContent=`${s}%`;let r;s>=80?r=g["success-foreground"]:s>=50?r=g["warning-foreground"]:r=g["error-foreground"],n.style.color=r}}},$t=t=>{P("target-website").forEach(n=>{n.textContent=t}),P("target-website-url").forEach(n=>{n instanceof HTMLAnchorElement?n.href=t:n.textContent=t})},Ot=t=>{let e=Math.floor(t/1e3);if(e<60)return`${e}s`;let o=Math.floor(e/60),n=e%60;return`${o}m ${n}s`},Ut=t=>new Date(t).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),D=(t,e,o,n)=>{let s=a(t);if(!s)return;let r=a("value",s),i=a("text",s);r&&(r.textContent=e),i&&o&&(i.textContent=o),n&&(s.style.backgroundColor=g[n])},_t=t=>{if(!t.results)return;let{scanDuration:e,pagesScanned:o,detectedItems:n,scannedAt:s}=t.results;D("scan-duration-card",Ot(e)),D("pages-scanned-card",o.length.toString()),D("items-detected-card",n.length.toString()),D("scan-date-card",Ut(s))},Ft=t=>{if(!t.results)return;let{detectedItems:e,trackersInfo:o}=t.results,n=o?.trackers??[],s=M.affiliatedDOMResources(e,n).length,r=M.loadedStorageResources(e).length,m=w.extractFullCompliance(t).summary.failed,{cmpInstalled:c}=w.extractActionableItems(t);D("scripts-detected-card",s.toString(),void 0,s===0?"success":"error"),D("cookies-detected-card",r.toString(),void 0,r===0?"success":"warning"),D("action-items-card",m.toString(),"Violations",m===0?"success":"error"),Vt(!!c)},Vt=t=>{let e=a("cmp-status-card");if(!e)return;let o=a("icon",e),n=a("text",e),s=t?g["success-foreground"]:g["error-foreground"];o&&z(o,t?K.compliant:K.notCompliant,{color:s,size:24}),n&&(n.textContent=t?"CMP Detected":"CMP Not Found"),e.style.backgroundColor=t?g.success:g.error},jt=t=>{if(!t.results)return;let e=P("compliance-container");if(e.length===0)return;let o=w.extractFullCompliance(t),{summary:n}=o,s=n.failed,r=s===0?"compliant":"non-compliant",i=()=>{if(s===0)return"No compliance violations detected. Nice work!";let f=o.criteria.filter(v=>v.status==="fail").map(v=>v.name);return`Found ${s} issue${s>1?"s":""}: ${f.slice(0,3).join(", ")}${f.length>3?", ...":""}. Action needed.`},c={compliant:{label:"Compliant",message:i(),icon:K.compliant,color:g.success,iconColor:g["success-foreground"]},"non-compliant":{label:"Not Compliant",message:i(),icon:K.notCompliant,color:g.error,iconColor:g["error-foreground"]}}[r];e.forEach(f=>{f.setAttribute("fs-cloak",""),f.classList.add("hide")});let l=null;e.forEach(f=>{(r==="compliant"&&f.classList.contains("compliant")||r!=="compliant"&&!f.classList.contains("compliant"))&&(l=f)}),l||([l]=e),l.removeAttribute("fs-cloak"),l.classList.remove("hide");let p=a("compliance-status",l);if(p){let f=a("icon",p),v=a("text",p);f&&z(f,c.icon,{color:c.iconColor,size:30}),v&&(v.textContent=c.label)}let y=a("compliance-details",l);y&&(y.textContent=c.message);let d=a("violations-wrapper",l);if(d){let f=a("value",d);f&&(f.textContent=s.toString())}l.style.backgroundColor=c.color},qt=t=>{if(!t.results)return;let{trackersInfo:e}=t.results,o=a("violations-component"),n=a("violations-list"),s=a("violation-template");if(!n||!s)return;let r=M.violatingTrackers(e?.trackers??[]);if(o){let d=a("icon",o);d&&z(d,"alert-octagon",{color:g["error-foreground"],size:24})}Array.from(n.children).forEach(d=>{d!==s&&d.remove()}),s.style.display="none";let m=a("violations-list-empty");if(r.length===0){m&&(m.removeAttribute("fs-cloak"),m.classList.remove("hide")),n.setAttribute("fs-cloak",""),n.classList.add("hide");return}m&&(m.setAttribute("fs-cloak",""),m.classList.add("hide")),n.removeAttribute("fs-cloak"),n.classList.remove("hide");let c=e?.providers??[],l=new Map;c.forEach(d=>l.set(d.id,d.name));let p={analytics:"\u{1F4CA}",marketing:"\u{1F4E2}",advertising:"\u{1F4FA}",functional:"\u2699\uFE0F",uncategorized:"\u2753"},y=new Set;r.forEach(d=>{let v=l.get(d.providerId)||d.name||d.domain||d.providerId||"Unknown",b=`${d.category}-${v}`;if(y.has(b))return;y.add(b);let k=s.cloneNode(!0);k.removeAttribute("data-fs-cs"),k.style.display="";let I=a("icon",k);I&&z(I,"chevron-right",{color:g["error-foreground"],size:16});let C=a("text",k);if(C){let u=p[d.category]??"\u{1F534}",h=d.category||"uncategorized";C.textContent=`${u} ${v}: ${h} tracker running before consent`}n.appendChild(k)})},Wt=t=>{let e=t?.toLowerCase()||"uncategorized";return["uncategorized","unknown","marketing","advertising"].includes(e)?g["error-foreground"]:["analytics","performance","functional","personalization"].includes(e)?g["warning-foreground"]:["essential","necessary","strictly-necessary","strictly_necessary"].includes(e)?null:g["error-foreground"]},F=t=>{let e=t?.toLowerCase()||"uncategorized";return["uncategorized","unknown"].includes(e)?1:["marketing","advertising"].includes(e)?2:["analytics","performance"].includes(e)?3:["functional","personalization"].includes(e)?4:["essential","necessary","strictly-necessary","strictly_necessary"].includes(e)?5:1},Bt=t=>{switch(F(t)){case 1:return"Highest Violation Risk - Uncategorized resource requiring immediate attention";case 2:return"High Violation Risk - Marketing/Advertising tracker requiring consent";case 3:return"Medium Violation Risk - Analytics/Performance tracker requiring consent";case 4:return"Low Violation Risk - Functional resource that may require consent";case 5:return"No Violation Risk - Essential resource";default:return"Unknown risk level"}},Gt=t=>{let e=Wt(t);return e?e===g["error-foreground"]?"brightness(0) saturate(100%) invert(21%) sepia(100%) saturate(7000%) hue-rotate(336deg) brightness(100%) contrast(105%)":e===g["warning-foreground"]?"brightness(0) saturate(100%) invert(68%) sepia(78%) saturate(1000%) hue-rotate(4deg) brightness(103%) contrast(104%)":null:null},Yt=t=>{if(!t.results)return;let{detectedItems:e,trackersInfo:o}=t.results,n=o?.trackers??[],s=o?.providers??[],r=new Map;s.forEach(C=>r.set(C.id,C.name));let i=new Map;M.violatingTrackers(n).forEach(C=>{C.resources?.forEach(u=>{i.set(u.id,C)})});let c=M.domResources(e).sort((C,u)=>F(C.category)-F(u.category)),l=M.loadedStorageResources(e).sort((C,u)=>F(C.category)-F(u.category)),p=a("scripts-component"),y=a("script-list"),d=a("script-item"),f=a("script-list-empty");if(y&&d){if(p){let u=a("scripts-title",p);u&&(u.textContent=`Detected DOM Resources (${c.length})`)}Array.from(y.children).forEach(u=>{u!==d&&u.remove()}),d.style.display="none",c.length===0?(f&&(f.removeAttribute("fs-cloak"),f.classList.remove("hide")),y.setAttribute("fs-cloak",""),y.classList.add("hide")):(f&&(f.setAttribute("fs-cloak",""),f.classList.add("hide")),y.removeAttribute("fs-cloak"),y.classList.remove("hide"),c.forEach(u=>{let h=d.cloneNode(!0);h.removeAttribute("data-fs-cs"),h.style.display="";let N=a("script-title",h),$=a("script-url",h),O=a("script-type",h),E=a("script-tag",h),R=a("icon",h),x=i.get(u.id);if(x||(h.style.backgroundColor=g.neutral,h.style.borderColor=g["neutral-foreground"],h.style.borderWidth="1px",h.style.borderStyle="solid"),N&&(N.textContent=`${u.domain||`Unknown ${u.type}`}`),$&&($.textContent=u.source?.slice(0,100)||"N/A"),O&&(O.textContent=u.type||"N/A"),E){if(x){let ze=r.get(x.providerId)||x.label||"Unknown";E.textContent=ze,E.style.display="",E.style.backgroundColor=g.neutral,E.style.color=g.white}else E.style.display="none";E.classList.remove("is-marketing","is-analytics","is-advertising","is-uncategorized")}R&&(R.style.display="none"),y.appendChild(h)}))}let v=a("cookies-component"),b=a("cookie-list"),k=a("cookie-item"),I=a("cookie-list-empty");if(b&&k){if(v){let u=a("cookies-title",v);u&&(u.textContent=`Cookies & Storage Data (${l.length})`)}Array.from(b.children).forEach(u=>{u!==k&&u.remove()}),k.style.display="none",l.length===0?(I&&(I.removeAttribute("fs-cloak"),I.classList.remove("hide")),b.setAttribute("fs-cloak",""),b.classList.add("hide")):(I&&(I.setAttribute("fs-cloak",""),I.classList.add("hide")),b.removeAttribute("fs-cloak"),b.classList.remove("hide"),l.forEach(u=>{let h=k.cloneNode(!0);h.removeAttribute("data-fs-cs"),h.style.display="";let N=a("cookie-name",h),$=a("cookie-url",h),O=a("cookie-type",h),E=a("cookie-tag",h),R=a("icon",h);if(N&&(N.textContent=`${u.name||`Unknown ${u.type}`}`),$&&($.textContent=u.domain||"N/A"),O&&(O.textContent=u.type||"N/A"),E){let x=u.category||"uncategorized";E.textContent=x,E.classList.remove("is-marketing","is-analytics","is-advertising","is-uncategorized"),E.classList.add(`is-${x}`),x==="uncategorized"&&(E.style.backgroundColor=g.error,E.style.color=g.white)}if(R){let x=u.category||"uncategorized",Q=Gt(x);Q?(R.style.display="",R.style.filter=Q,R.title=Bt(x)):R.style.display="none"}b.appendChild(h)}))}},Zt=t=>{let e=w.extractAttentionItems(t),o=a("attention-list"),n=a("attention-item"),s=a("attention-list-empty");if(!(!o||!n)){if(n.style.display="none",e.length===0){s&&(s.removeAttribute("fs-cloak"),s.classList.remove("hide")),o.setAttribute("fs-cloak",""),o.classList.add("hide");return}s&&(s.setAttribute("fs-cloak",""),s.classList.add("hide")),o.removeAttribute("fs-cloak"),o.classList.remove("hide"),e.forEach((r,i)=>{let m=n.cloneNode(!0);m.removeAttribute("data-fs-cs"),m.style.display="";let c=a("value",m);c&&(c.textContent=(i+1).toString());let l=a("text",m);l&&(l.textContent=r),o.appendChild(m)})}},Kt=t=>{let e=w.extractComplianceSummary(t),o=a("passed-items");if(o){let r=a("value",o);r&&(r.textContent=e.pass.toString())}let n=a("failed-items");if(n){let r=a("value",n);r&&(r.textContent=e.fail.toString())}let s=a("unverified-items");if(s){let r=a("value",s);r&&(r.textContent=e.unverified.toString())}},Xt=t=>{let e=w.extractFullCompliance(t),o=a("criteria-list"),n=a("criteria-item");if(!o||!n)return;Array.from(o.children).forEach(i=>{i!==n&&i.remove()}),n.style.display="none",e.criteria.filter(i=>i.status!=="not-verifiable").forEach(i=>{let m=n.cloneNode(!0);m.removeAttribute("data-fs-cs"),m.style.display="";let c=Pe[i.status]||Pe["not-verifiable"],l=a("icon",m);l&&z(l,c.icon,{color:c.color,size:24});let p=a("criteria-title",m),y=a("criteria-description",m);p&&(p.textContent=i.name),y&&(y.textContent=i.description);let d=a("criteria-status",m);d&&(d.textContent=c.label);let f=a("criteria-answer",m);f&&(f.textContent=i.details||"No additional details available."),o.appendChild(m)})},Qt=t=>{let e=w.extractStatistics(t),o=a("stat-duration");if(o){let c=a("value",o);c&&(c.textContent=e.scanDuration)}let n=a("stat-resources");if(n){let c=a("value",n);c&&(c.textContent=e.resourcesCount.toString())}let s=a("stat-storage");if(s){let c=a("value",s);c&&(c.textContent=e.storageCount.toString())}let r=a("stat-first-party");if(r){let c=a("value",r);c&&(c.textContent=e.firstParty.toString())}let i=a("stat-third-party");if(i){let c=a("value",i);c&&(c.textContent=e.thirdParty.toString())}let m=a("stat-categories");if(m){let c=a("value",m);c&&(c.textContent=e.categories.toString())}},Jt=[{name:"websiteInfo",updater:zt},{name:"complianceScore",updater:Nt,requiredElements:["compliance-score"]},{name:"primaryStats",updater:_t},{name:"secondaryStats",updater:Ft},{name:"complianceContainer",updater:jt,requiredElements:["compliance-container"]},{name:"violationsList",updater:qt,requiredElements:["violations-list"]},{name:"detectedItems",updater:Yt},{name:"attentionItems",updater:Zt,requiredElements:["attention-list"]},{name:"complianceSummary",updater:Kt},{name:"complianceCriteria",updater:Xt,requiredElements:["criteria-list"]},{name:"statistics",updater:Qt}],eo=t=>{Jt.forEach(({name:e,updater:o,requiredElements:n})=>{try{if(n&&n.find(r=>!a(r)))return;o(t)}catch(s){console.error(`[Results] Error in updater "${e}":`,s)}}),te()},to=async()=>{let t=wt();if(!t){console.error("[Results] Cannot fetch results without tracking ID");return}let e;try{new URL(t.site),e=t.site}catch{e=`https://${t.site}`}$t(e);try{await Mt(t.trackingId);let o=await Ht(t.trackingId);console.log("[Results] Fetched results:",o);let n=Pt(o);if(n){X(n);return}eo(o),Dt()}catch(o){console.error("[Results] Error during scan:",o);let n="An error occurred. Please try again.";o instanceof A&&o.response&&typeof o.response=="object"&&"error"in o.response?n=o.response.error:o instanceof Error&&(n=o.message),X(n)}};window.Webflow||(window.Webflow=[]);window.Webflow.push(()=>{to()});})();
|
package/dist/scan.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(()=>{var b=Object.defineProperty;var E=(t,e,n)=>e in t?b(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var m=(t,e,n)=>E(t,typeof e!="symbol"?e+"":e,n);var v=localStorage.getItem("cs-dev")==="true",a=v?"https://fs-consentpro-api-dev.finsweet.workers.dev":"https://api.consentpro.com",Z=1440*60*1e3;var C="data-fs-cs";var i=(t,e=document)=>e.querySelector(`[${C}="${t}"]`);var y=t=>{let e=t.trim();if(!e||!/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//.test(e)&&e.includes("@"))return null;try{let o=p(e),s=new URL(o);return s.protocol!=="http:"&&s.protocol!=="https:"||!s.hostname||!s.hostname.includes(".")?null:s}catch{return null}};var k={"X-Finsweet-ConsentPro-Version":"v2"},h={"X-Finsweet-ConsentPro-Version":"v2","Content-Type":"application/json"},r=class extends Error{constructor(n,o,s){super(n);m(this,"status");m(this,"response");this.name="ScannerApiError",this.status=o,this.response=s}};async function c(t){if(!t.ok){let e=t.statusText,n;try{let o=await t.json();n=o,o&&typeof o.error=="string"&&(e=o.error)}catch{n=await t.text().catch(()=>"Unknown error")}throw new r(`Report request failed: ${e}`,t.status,n)}return t.json()}var u={async startScan(t){let e=await fetch(`${a}/v2/scanner/public/scan`,{method:"POST",headers:h,body:JSON.stringify({url:t,acceptAll:!1})});if(e.status===409){let o=await e.json().catch(()=>({}));throw new r("A scan is already in progress for this website. Please wait for it to complete.",409,o)}if(e.status!==201){let o=await e.text().catch(()=>"Unknown error");throw new r(`Expected 201 Created but got ${e.status}`,e.status,o)}return await c(e)},async getStatus(t){let e=await fetch(`${a}/v2/scanner/public/status/${t}`,{headers:k});return await c(e)},async getResults(t){let e=await fetch(`${a}/v2/scanner/public/results/${t}`,{headers:k});return await c(e)},async cancelScan(t){let e=await fetch(`${a}/v2/scanner/public/scan/${t}`,{method:"DELETE",headers:h});return await c(e)}},p=t=>{let e=t.trim();return!e.startsWith("http://")&&!e.startsWith("https://")&&(e="https://"+e),e};var S="[Scan]",T="Please enter a valid URL (e.g. https://example.com).",R="Failed to start scan. Please try again.",I="/result",w=()=>{let t=i("scan-form"),e=i("scan-url-input"),n=i("scan-submit"),o=i("form-error"),s=i("form-error-text");return!t||!e||!n||!o||!s?(console.error(`${S} Missing elements:`,{form:!!t,urlInput:!!e,submitButton:!!n,errorDiv:!!o,errorText:!!s}),null):{form:t,urlInput:e,submitButton:n,errorDiv:o,errorText:s}},
|
|
1
|
+
"use strict";(()=>{var b=Object.defineProperty;var E=(t,e,n)=>e in t?b(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var m=(t,e,n)=>E(t,typeof e!="symbol"?e+"":e,n);var v=localStorage.getItem("cs-dev")==="true",a=v?"https://fs-consentpro-api-dev.finsweet.workers.dev":"https://api.consentpro.com",Z=1440*60*1e3;var C="data-fs-cs";var i=(t,e=document)=>e.querySelector(`[${C}="${t}"]`);var y=t=>{let e=t.trim();if(!e||!/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//.test(e)&&e.includes("@"))return null;try{let o=p(e),s=new URL(o);return s.protocol!=="http:"&&s.protocol!=="https:"||!s.hostname||!s.hostname.includes(".")?null:s}catch{return null}};var k={"X-Finsweet-ConsentPro-Version":"v2"},h={"X-Finsweet-ConsentPro-Version":"v2","Content-Type":"application/json"},r=class extends Error{constructor(n,o,s){super(n);m(this,"status");m(this,"response");this.name="ScannerApiError",this.status=o,this.response=s}};async function c(t){if(!t.ok){let e=t.statusText,n;try{let o=await t.json();n=o,o&&typeof o.error=="string"&&(e=o.error)}catch{n=await t.text().catch(()=>"Unknown error")}throw new r(`Report request failed: ${e}`,t.status,n)}return t.json()}var u={async startScan(t){let e=await fetch(`${a}/v2/scanner/public/scan`,{method:"POST",headers:h,body:JSON.stringify({url:t,acceptAll:!1})});if(e.status===409){let o=await e.json().catch(()=>({}));throw new r("A scan is already in progress for this website. Please wait for it to complete.",409,o)}if(e.status!==201){let o=await e.text().catch(()=>"Unknown error");throw new r(`Expected 201 Created but got ${e.status}`,e.status,o)}return await c(e)},async getStatus(t){let e=await fetch(`${a}/v2/scanner/public/status/${t}`,{headers:k});return await c(e)},async getResults(t){let e=await fetch(`${a}/v2/scanner/public/results/${t}`,{headers:k});return await c(e)},async cancelScan(t){let e=await fetch(`${a}/v2/scanner/public/scan/${t}`,{method:"DELETE",headers:h});return await c(e)}},p=t=>{let e=t.trim();return!e.startsWith("http://")&&!e.startsWith("https://")&&(e="https://"+e),e};var S="[Scan]",T="Please enter a valid URL (e.g. https://example.com).",R="Failed to start scan. Please try again.",I="/result",w=()=>{let t=i("scan-form"),e=i("scan-url-input"),n=i("scan-submit"),o=i("form-error"),s=i("form-error-text");return!t||!e||!n||!o||!s?(console.error(`${S} Missing elements:`,{form:!!t,urlInput:!!e,submitButton:!!n,errorDiv:!!o,errorText:!!s}),null):{form:t,urlInput:e,submitButton:n,errorDiv:o,errorText:s}},f=(t,e)=>{t.errorText.innerHTML=e,t.errorDiv.style.display="flex"},D=t=>{t.errorDiv.style.display="none",t.errorText.innerHTML=""},L=(t,e)=>{let n=t.value.trim();if(!n)return f(e,T),null;let o=y(n);return o||(f(e,T),null)},M=t=>{let e=t.dataset.wait;e&&(t.value=e)},A=(t,e)=>{t.value=e,t.disabled=!1},d=t=>`${t.origin}${t.pathname}`,H=async(t,e,n)=>{try{let o=await u.startScan(d(t));if(!o.trackingId)throw new Error("No tracking ID returned");let s=new URL(I,window.location.origin);s.searchParams.set("trid",o.trackingId),s.searchParams.set("site",d(t)),window.location.href=s.href}catch(o){if(console.error(`${S} Scan failed:`,o),o instanceof r&&o.status===409){let g=o.response?.trackingId;if(g){let l=new URL(I,window.location.origin);l.searchParams.set("trid",g),l.searchParams.set("site",d(t)),window.location.href=l.href;return}}let s=o instanceof r?`Scan failed: ${o.message}`:R;f(e,s),A(e.submitButton,n)}},P=async(t,e)=>{t.preventDefault(),t.stopPropagation(),D(e);let n=L(e.urlInput,e);if(!n)return;e.urlInput.value=n.href;let o=e.submitButton.value||"Scan";M(e.submitButton),e.submitButton.disabled=!0,await H(n,e,o)},z=()=>{let t=w();t&&t.form.addEventListener("submit",e=>P(e,t),{capture:!0})};window.Webflow||(window.Webflow=[]);window.Webflow.push(z);})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@finsweet/consentpro-scan",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.19",
|
|
4
4
|
"description": "A frontend scanner for ConsentPro, a cookie consent management platform by Finsweet.",
|
|
5
5
|
"homepage": "https://github.com/finsweet/consentpro-scan#readme",
|
|
6
6
|
"license": "ISC",
|