shugoi 0.1.8 → 0.2.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a95a6d87eac5f0b295df85b60dd3a42c661679e13a3601feb853f90b5368ff7c
4
- data.tar.gz: 9d9e3d624f9663428af2092e05929e0422e1a512da193aafb423a6f32c610aeb
3
+ metadata.gz: bb399ab3d75413beea51021d09dba771d642cdeae0b6ebd08dee8cb9f43ebec9
4
+ data.tar.gz: 39a2adb0773270d1bf1712a2626b8875c95758dee55eaeb7d179353a32518d50
5
5
  SHA512:
6
- metadata.gz: d4e9be4694e3578ee13b88de8e7f2b9e1277327366011e9c988427905adacf9f0b56178737a018d4e1ba79ea2b47d0619e0e19a3501d466640e947be4992fb1e
7
- data.tar.gz: 40baae0aae435f7303eb04591521be7862fd5683fd1cbd1502ba814b3c6e77cac57a8499a2d67882408de9c9408ae24ff6a6024a3d5b06163e2b2cb1f005895f
6
+ metadata.gz: 6c9cd4918e288e14437d0c5c5bc5b7068fb63b84a9d4a56989525d45dbbcce8e10d1a9fd08d4d013d6ed0ff670d12acd679133e3b4b43a9b04147bcb3f53e616
7
+ data.tar.gz: de83aeafd3d23b27cc4d60a5ff23325c81940c2fe8102a8d6c54e9f688c683876940bb0fbef001ddbc63b52c1c27a5af4ba3672df91bbdc6d97e767d5c6a8f7d
data/lib/shugoi/notice.rb CHANGED
@@ -6,9 +6,15 @@ module Shugoi
6
6
  # dans le HTML APRÈS le split-render (elle ne disparaît pas quand le render remplace
7
7
  # le document). L'ack est décidé côté SERVEUR via /notice (machineId), pas de cookie.
8
8
  class Notice
9
- # Le script est identique au module Node (NOTICE_SCRIPT). Les placeholders `mid` et
10
- # `sk` sont remplacés à l'injection (le guard n'a pas encore défini window.__sg_mid
11
- # quand le HTML est rendu).
9
+ # Script renforcé (parité avec guard.src.js du site Node, audit §8.5.3) :
10
+ # - overlay bloquant z-index max
11
+ # - verrouillage scroll/wheel/touchmove tant que la notice est affichée
12
+ # - MutationObserver anti-bypass COMPLET : ré-affiche la notice si elle est retirée
13
+ # du DOM, et RESTAURE intégralement son style ET son innerHTML s'ils sont modifiés
14
+ # (devtools / manipulation JS du style, des attributs, du texte, du contenu).
15
+ # L'overlay est reconstruit à partir du template si un élément clé manque.
16
+ # - obligation d'accepter (bouton OK) pour déverrouiller — l'ack est serveur (mid).
17
+ # Les placeholders `mid` et `sk` sont remplacés à l'injection.
12
18
  SCRIPT = <<~'JS'
13
19
  <script>
14
20
  (function(){
@@ -17,10 +23,51 @@ module Shugoi
17
23
  if(!mid||!sk||window.__sg_noticeEnabled===false)return;
18
24
  var base=window.__sg_baseUrl||'';
19
25
  var origin=base.replace(/\/api\/v1\/?$/,'');
26
+ var _OVERLAY_CSS='position:fixed!important;inset:0!important;z-index:2147483647!important;background:rgba(0,0,0,.6)!important;display:flex!important;align-items:center!important;justify-content:center!important;padding:1.2rem!important';
27
+ var _CARD_CSS='background:#fff!important;border:4px solid #000!important;border-radius:28px 6px 32px 10px!important;box-shadow:14px 14px 0 #000!important;padding:0!important;max-width:720px!important;width:100%!important;text-align:center!important;font-family:Arial,sans-serif!important;display:flex!important;overflow:hidden!important';
28
+ var _CARD_HTML='<div style="flex:0 0 320px;display:flex;align-items:center;justify-content:center;padding:1.5rem 1rem 1.5rem 3rem;overflow:hidden"><img src="'+origin+'/favicon.png" alt="" style="width:100%;height:auto;max-width:220px;pointer-events:none"></div><div style="flex:1;padding:1.6rem 1.8rem;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center"><img src="'+origin+'/brand-block.png" alt="Shugoi" style="display:block;margin:0 0 .3rem;pointer-events:none;max-width:100%;height:auto;max-height:40px"><div style="border:2px solid #000;display:inline-block;border-radius:8px 2px 12px 4px;padding:.2rem .6rem;font-size:.5rem;font-weight:700;text-transform:uppercase;letter-spacing:.1em;color:#E87090;margin-bottom:.6rem">Protection anti-abus</div><p style="font-size:.8rem;color:#555;line-height:1.7;margin:0 .4rem .6rem;max-width:280px">Ce site utilise Shugoi pour se protéger contre les abus et la fraude. Des caractéristiques techniques de votre navigateur sont analysées pour détecter les scripts automatisés, Tor, les VPN et les environnements virtuels. Aucune donnée personnelle n\\'est collectée.</p><button id="__sg_ok" style="background:#E87090;color:#fff;border:3px solid #000;border-radius:12px 3px 14px 5px;padding:.35rem 1.4rem;font-size:.8rem;font-weight:700;cursor:pointer">OK</button><div style="margin-top:.5rem;font-size:.5rem;color:#ccc"><a href="'+origin+'/legal/shugoi-notice" target="_blank" style="color:#E87090;text-decoration:underline">En savoir plus · shugoi.com</a></div></div>';
20
29
  function ack(){try{fetch(base+'/notice',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({machineId:mid,siteKey:sk}),keepalive:true,signal:AbortSignal.timeout(4000)}).catch(function(){})}catch(e){}}
21
- function build(){var o=document.createElement('div');o.id='__sg_o';o.style.cssText='position:fixed!important;inset:0!important;z-index:2147483647!important;background:rgba(0,0,0,.6)!important;display:flex!important;align-items:center!important;justify-content:center!important;padding:1.2rem!important';var c=document.createElement('div');c.id='__sg_cd';c.style.cssText='background:#fff!important;border:4px solid #000!important;border-radius:28px 6px 32px 10px!important;box-shadow:14px 14px 0 #000!important;padding:0!important;max-width:720px!important;width:100%!important;text-align:center!important;font-family:Arial,sans-serif!important;display:flex!important;overflow:hidden!important';c.innerHTML='<div style="flex:0 0 320px;display:flex;align-items:center;justify-content:center;padding:1.5rem 1rem 1.5rem 3rem;overflow:hidden"><img src="'+origin+'/favicon.png" alt="" style="width:100%;height:auto;max-width:220px;pointer-events:none"></div><div style="flex:1;padding:1.6rem 1.8rem;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center"><img src="'+origin+'/brand-block.png" alt="Shugoi" style="display:block;margin:0 0 .3rem;pointer-events:none;max-width:100%;height:auto;max-height:40px"><div style="border:2px solid #000;display:inline-block;border-radius:8px 2px 12px 4px;padding:.2rem .6rem;font-size:.5rem;font-weight:700;text-transform:uppercase;letter-spacing:.1em;color:#E87090;margin-bottom:.6rem">Protection anti-abus</div><p style="font-size:.8rem;color:#555;line-height:1.7;margin:0 .4rem .6rem;max-width:280px">Ce site utilise Shugoi pour se protéger contre les abus et la fraude. Des caractéristiques techniques de votre navigateur sont analysées pour détecter les scripts automatisés, Tor, les VPN et les environnements virtuels. Aucune donnée personnelle n\\'est collectée.</p><button id="__sg_ok" style="background:#E87090;color:#fff;border:3px solid #000;border-radius:12px 3px 14px 5px;padding:.35rem 1.4rem;font-size:.8rem;font-weight:700;cursor:pointer">OK</button><div style="margin-top:.5rem;font-size:.5rem;color:#ccc"><a href="'+origin+'/legal/shugoi-notice" target="_blank" style="color:#E87090;text-decoration:underline">En savoir plus · shugoi.com</a></div></div>';o.appendChild(c);document.documentElement.appendChild(o);document.body.style.overflow='hidden';document.documentElement.style.overflow='hidden';var ok=document.getElementById('__sg_ok');if(ok)ok.onclick=function(){ack();var el=document.getElementById('__sg_o');if(el&&el.parentNode)el.parentNode.removeChild(el);document.body.style.overflow='';document.documentElement.style.overflow=''};}
22
- function show(){if(document.body)build();else if(document.addEventListener)document.addEventListener('DOMContentLoaded',build);else setTimeout(show,50)}
23
- fetch(base+'/notice?machineId='+encodeURIComponent(mid)+'&siteKey='+encodeURIComponent(sk),{signal:AbortSignal.timeout(4000)}).then(function(r){return r.json()}).then(function(d){if(!d.acknowledged)show()}).catch(function(){show()});
30
+ function buildOverlay(){
31
+ var o=document.createElement('div');o.id='__sg_o';o.style.cssText=_OVERLAY_CSS;
32
+ var c=document.createElement('div');c.id='__sg_cd';c.style.cssText=_CARD_CSS;
33
+ c.innerHTML=_CARD_HTML;
34
+ o.appendChild(c);return o;
35
+ }
36
+ function okHandler(keepMo){ack();var el=document.getElementById('__sg_o');if(el&&el.parentNode)el.parentNode.removeChild(el);document.body.style.overflow='';document.documentElement.style.overflow='';if(keepMo===true){try{mo.disconnect()}catch(e){}}}
37
+ function rebindOk(){var b=document.getElementById('__sg_ok');if(b)b.onclick=function(){okHandler(true)};}
38
+ function enforce(){
39
+ var o=document.getElementById('__sg_o');
40
+ if(!o){
41
+ document.documentElement.appendChild(buildOverlay());
42
+ document.body.style.overflow='hidden';document.documentElement.style.overflow='hidden';
43
+ rebindOk();return;
44
+ }
45
+ if(o.style.cssText!==_OVERLAY_CSS)o.style.cssText=_OVERLAY_CSS;
46
+ var c=document.getElementById('__sg_cd');
47
+ if(!c){
48
+ // card supprimée → reconstruit l'overlay entier
49
+ var fresh=buildOverlay();o.innerHTML='';o.appendChild(fresh.childNodes[0]);
50
+ document.body.style.overflow='hidden';document.documentElement.style.overflow='hidden';rebindOk();return;
51
+ }
52
+ if(c.style.cssText!==_CARD_CSS)c.style.cssText=_CARD_CSS;
53
+ if(c.innerHTML!==_CARD_HTML){c.innerHTML=_CARD_HTML;rebindOk();}
54
+ if(document.body.style.overflow!=='hidden')document.body.style.overflow='hidden';
55
+ if(document.documentElement.style.overflow!=='hidden')document.documentElement.style.overflow='hidden';
56
+ }
57
+ var mo=null;
58
+ function show(){
59
+ document.documentElement.appendChild(buildOverlay());
60
+ var sp=window.scrollY||window.pageYOffset||0;
61
+ document.body.style.overflow='hidden';document.documentElement.style.overflow='hidden';
62
+ window.addEventListener('scroll',function(){window.scrollTo(0,sp)}, {passive:false});
63
+ window.addEventListener('touchmove',function(e){e.preventDefault()},{passive:false});
64
+ window.addEventListener('wheel',function(e){e.preventDefault()},{passive:false});
65
+ rebindOk();
66
+ mo=new MutationObserver(function(){enforce();});
67
+ mo.observe(document.documentElement,{childList:true,subtree:true,attributes:true,characterData:true,attributeFilter:['style','class','id']});
68
+ }
69
+ function init(){if(document.body)show();else if(document.addEventListener)document.addEventListener('DOMContentLoaded',show);else setTimeout(init,50)}
70
+ fetch(base+'/notice?machineId='+encodeURIComponent(mid)+'&siteKey='+encodeURIComponent(sk),{signal:AbortSignal.timeout(4000)}).then(function(r){return r.json()}).then(function(d){if(!d.acknowledged)init()}).catch(function(){init()});
24
71
  })();
25
72
  </script>
26
73
  JS
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Shugoi
4
- VERSION = "0.1.8"
4
+ VERSION = "0.2.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shugoi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shugoi