@justai/core 0.42.0 → 0.43.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.
package/dist/analytics.js CHANGED
@@ -128,6 +128,8 @@ export function measurementIdFor(host) {
128
128
  * shared shell does not put anything in the global scope it did not mean to. `window.gtag` is still
129
129
  * assigned explicitly on window, which is the one thing that MUST escape.
130
130
  */
131
+ // THE STORED ANSWER is the apex's (2026-10-14, see ./consent): the `justai-consent` cookie on the
132
+ // registrable domain first, this origin's localStorage only as the pre-apex fallback.
131
133
  export function analyticsJs(gaId) {
132
134
  return `(function(){
133
135
  window.gtag=window.gtag||function(){(window.dataLayer=window.dataLayer||[]).push(arguments)};
@@ -140,7 +142,7 @@ window.gtag=window.gtag||function(){window.dataLayer.push(arguments)};
140
142
  gtag("js",new Date());
141
143
  gtag("consent","default",{ad_storage:"granted",ad_user_data:"granted",ad_personalization:"denied",analytics_storage:"granted"});
142
144
  gtag("consent","default",{region:["AT","BE","BG","HR","CY","CZ","DK","EE","FI","FR","DE","GR","HU","IE","IT","LV","LT","LU","MT","NL","PL","PT","RO","SK","SI","ES","SE","IS","LI","NO","GB","CH"],ad_storage:"denied",ad_user_data:"denied",ad_personalization:"denied",analytics_storage:"denied"});
143
- try{var __c=localStorage.getItem("consent");
145
+ try{var __m=document.cookie.match(/(?:^|; )justai-consent=([^;]*)/),__c=__m?decodeURIComponent(__m[1]):localStorage.getItem("consent");
144
146
  if(__c==="granted+ads")gtag("consent","update",{analytics_storage:"granted",ad_storage:"granted",ad_user_data:"granted"});
145
147
  else if(__c==="granted")gtag("consent","update",{analytics_storage:"granted"});
146
148
  else if(__c==="denied")gtag("consent","update",{analytics_storage:"denied",ad_storage:"denied",ad_user_data:"denied"})}catch(e){}
package/dist/consent.d.ts CHANGED
@@ -73,9 +73,29 @@ export declare function consentCopy(lang: string | null | undefined): ConsentStr
73
73
  *
74
74
  * The consent dialog's behaviour — one copy, for every surface on a persona's origin.
75
75
  *
76
- * CONSENT IS SCOPED TO THE ORIGIN, NOT TO A PAGE. Whichever page a visitor enters by, if this origin
77
- * has never asked, it asks — once. That is what a consent flow IS, and it is worth stating because
78
- * ours was accidentally page-scoped for three weeks: the script used to bail on
76
+ * CONSENT IS SCOPED TO THE APEX — every persona under app.zone, pin.games, justai.pro, cityinmotion.nl
77
+ * answers to one question (2026-10-14). It was scoped to the ORIGIN, on purpose: each persona honest
78
+ * with its own visitor, so somebody arriving from search straight at qr was asked by qr. The founder,
79
+ * from what visitors told him: *"app.zone'a giriyorum, count me. app.zone'daki bir app'e giriyorum,
80
+ * count me… kullanıcıya gına geliyor"* — by the third or fourth persona people answer "stay invisible"
81
+ * to make the asking stop, which is the question working against itself. So: an answer given on ANY
82
+ * persona of an apex — either answer — is that apex's answer, and no sibling asks again. Nobody on the
83
+ * apex has answered yet? The first persona visited asks, and its answer becomes everyone's. Another
84
+ * apex is another household and asks for itself.
85
+ *
86
+ * HOW: a cookie on the registrable domain (`justai-consent`, Domain=<apex>), because localStorage is
87
+ * per origin and every subdomain is its own origin — that is the whole reason each one asked. It
88
+ * lives 13 months (foundations/15: a label must not outlive what it labels; the choice is re-asked
89
+ * once a year, the usual ceiling for a stored consent in Europe). `localStorage["consent"]` is still
90
+ * written, for shells on older cores, and an answer found only there is PROMOTED to the apex cookie on
91
+ * the next visit — so everybody who answered any persona before this change is not asked by its
92
+ * siblings after it. The "not now" (Escape) flag is an apex SESSION cookie for the same reason: one
93
+ * dodge keeps the whole apex quiet for this visit, not just one persona. /me's erase must expire the
94
+ * cookie on every plausible domain (it cannot read the Domain attribute back).
95
+ *
96
+ * Whichever page a visitor enters by, if the apex has never been answered, it asks — once. That is
97
+ * what a consent flow IS, and it is worth stating because ours was accidentally page-scoped for three
98
+ * weeks: the script used to bail on
79
99
  * `!document.getElementById("kernel")`, a DOM sniff added to avoid asking on a 404. Feed pages have
80
100
  * no kernel either, so on every /feed/* page in the fleet the question was never asked — silently,
81
101
  * with nothing to notice it. A trust decision must never be inferred from an unrelated layout
@@ -102,4 +122,4 @@ export declare function consentCopy(lang: string | null | undefined): ConsentStr
102
122
  * the sheet ships no attribute, and the opener places focus by the genre's law: the ask genre puts
103
123
  * it on the invitation (here), the destructive genre on the cancel (that consumer's own open).
104
124
  */
105
- export declare const CONSENT_JS = "(function(){try{\nvar h=location.hostname;\nif(h===\"localhost\"||h===\"127.0.0.1\"||h===\"::1\"||h===\"[::1]\"||h.indexOf(\"dev-\")===0)return;\nvar el=document.getElementById(\"consent\");if(!el||!el.showModal)return;\nvar open=function(){if(!el.open){el.returnValue=\"\";el.showModal();var p=el.querySelector(\".preferred\");if(p)p.focus()}};\nel.addEventListener(\"close\",function(){\nvar rv=el.returnValue;\nvar v=rv===\"confirm\"?\"granted+ads\":rv===\"denied\"?\"denied\":null;\nif(v){var g=v===\"denied\"?\"denied\":\"granted\";\ngtag(\"consent\",\"update\",{analytics_storage:g,ad_storage:g,ad_user_data:g});\ntry{localStorage.setItem(\"consent\",v)}catch(_){}}\nelse{try{sessionStorage.setItem(\"consent-later\",\"1\")}catch(_){}}\n});\nvar doors=document.querySelectorAll(\"[data-consent-open]\");\nfor(var i=0;i<doors.length;i++){var a=doors[i];\nif(!a.textContent)a.textContent=el.getAttribute(\"data-choice-label\")||\"privacy choice\";\na.hidden=false;var w=a.closest(\"[data-consent-door]\");if(w)w.hidden=false;\na.addEventListener(\"click\",function(ev){ev.preventDefault();open()})}\nif(localStorage.getItem(\"consent\"))return;\ntry{if(sessionStorage.getItem(\"consent-later\"))return}catch(_){}\nvar tz=Intl.DateTimeFormat().resolvedOptions().timeZone||\"\";\nvar asked=tz.indexOf(\"Europe/\")===0||[\n\"Asia/Nicosia\",\"Asia/Famagusta\",\n\"Atlantic/Canary\",\"Atlantic/Azores\",\"Atlantic/Madeira\",\"Atlantic/Reykjavik\",\n\"Arctic/Longyearbyen\",\n\"America/Guadeloupe\",\"America/Martinique\",\"America/Cayenne\",\n\"Indian/Reunion\",\"Indian/Mayotte\"].indexOf(tz)>=0;\nif(!asked)return;\nsetTimeout(open,700);\n}catch(_){}})();";
125
+ export declare const CONSENT_JS = "(function(){try{\nvar h=location.hostname;\nif(h===\"localhost\"||h===\"127.0.0.1\"||h===\"::1\"||h===\"[::1]\"||h.indexOf(\"dev-\")===0)return;\nvar el=document.getElementById(\"consent\");if(!el||!el.showModal)return;\nvar hp=h.split(\".\"),ap=(hp.length>2&&!/^[0-9.]+$/.test(h))?hp.slice(-2).join(\".\"):h;\nvar AGE=34128000;\nvar rd=function(n){var m=document.cookie.match(new RegExp(\"(?:^|; )\"+n+\"=([^;]*)\"));return m?decodeURIComponent(m[1]):null};\nvar wr=function(n,v,age){document.cookie=n+\"=\"+encodeURIComponent(v)+\"; Domain=\"+ap+\"; Path=/\"+(age?\"; Max-Age=\"+age:\"\")+\"; SameSite=Lax; Secure\"};\nvar stored=function(){var c=rd(\"justai-consent\");if(c)return c;var l=null;try{l=localStorage.getItem(\"consent\")}catch(_){}if(l)wr(\"justai-consent\",l,AGE);return l};\nvar open=function(){if(!el.open){el.returnValue=\"\";el.showModal();var p=el.querySelector(\".preferred\");if(p)p.focus()}};\nel.addEventListener(\"close\",function(){\nvar rv=el.returnValue;\nvar v=rv===\"confirm\"?\"granted+ads\":rv===\"denied\"?\"denied\":null;\nif(v){var g=v===\"denied\"?\"denied\":\"granted\";\ngtag(\"consent\",\"update\",{analytics_storage:g,ad_storage:g,ad_user_data:g});\ntry{localStorage.setItem(\"consent\",v)}catch(_){}\nwr(\"justai-consent\",v,AGE)}\nelse{wr(\"justai-consent-later\",\"1\",0);try{sessionStorage.setItem(\"consent-later\",\"1\")}catch(_){}}\n});\nvar doors=document.querySelectorAll(\"[data-consent-open]\");\nfor(var i=0;i<doors.length;i++){var a=doors[i];\nif(!a.textContent)a.textContent=el.getAttribute(\"data-choice-label\")||\"privacy choice\";\na.hidden=false;var w=a.closest(\"[data-consent-door]\");if(w)w.hidden=false;\na.addEventListener(\"click\",function(ev){ev.preventDefault();open()})}\nif(stored())return;\nif(rd(\"justai-consent-later\"))return;\ntry{if(sessionStorage.getItem(\"consent-later\"))return}catch(_){}\nvar tz=Intl.DateTimeFormat().resolvedOptions().timeZone||\"\";\nvar asked=tz.indexOf(\"Europe/\")===0||[\n\"Asia/Nicosia\",\"Asia/Famagusta\",\n\"Atlantic/Canary\",\"Atlantic/Azores\",\"Atlantic/Madeira\",\"Atlantic/Reykjavik\",\n\"Arctic/Longyearbyen\",\n\"America/Guadeloupe\",\"America/Martinique\",\"America/Cayenne\",\n\"Indian/Reunion\",\"Indian/Mayotte\"].indexOf(tz)>=0;\nif(!asked)return;\nsetTimeout(open,700);\n}catch(_){}})();";
package/dist/consent.js CHANGED
@@ -95,9 +95,29 @@ export function consentCopy(lang) {
95
95
  *
96
96
  * The consent dialog's behaviour — one copy, for every surface on a persona's origin.
97
97
  *
98
- * CONSENT IS SCOPED TO THE ORIGIN, NOT TO A PAGE. Whichever page a visitor enters by, if this origin
99
- * has never asked, it asks — once. That is what a consent flow IS, and it is worth stating because
100
- * ours was accidentally page-scoped for three weeks: the script used to bail on
98
+ * CONSENT IS SCOPED TO THE APEX — every persona under app.zone, pin.games, justai.pro, cityinmotion.nl
99
+ * answers to one question (2026-10-14). It was scoped to the ORIGIN, on purpose: each persona honest
100
+ * with its own visitor, so somebody arriving from search straight at qr was asked by qr. The founder,
101
+ * from what visitors told him: *"app.zone'a giriyorum, count me. app.zone'daki bir app'e giriyorum,
102
+ * count me… kullanıcıya gına geliyor"* — by the third or fourth persona people answer "stay invisible"
103
+ * to make the asking stop, which is the question working against itself. So: an answer given on ANY
104
+ * persona of an apex — either answer — is that apex's answer, and no sibling asks again. Nobody on the
105
+ * apex has answered yet? The first persona visited asks, and its answer becomes everyone's. Another
106
+ * apex is another household and asks for itself.
107
+ *
108
+ * HOW: a cookie on the registrable domain (`justai-consent`, Domain=<apex>), because localStorage is
109
+ * per origin and every subdomain is its own origin — that is the whole reason each one asked. It
110
+ * lives 13 months (foundations/15: a label must not outlive what it labels; the choice is re-asked
111
+ * once a year, the usual ceiling for a stored consent in Europe). `localStorage["consent"]` is still
112
+ * written, for shells on older cores, and an answer found only there is PROMOTED to the apex cookie on
113
+ * the next visit — so everybody who answered any persona before this change is not asked by its
114
+ * siblings after it. The "not now" (Escape) flag is an apex SESSION cookie for the same reason: one
115
+ * dodge keeps the whole apex quiet for this visit, not just one persona. /me's erase must expire the
116
+ * cookie on every plausible domain (it cannot read the Domain attribute back).
117
+ *
118
+ * Whichever page a visitor enters by, if the apex has never been answered, it asks — once. That is
119
+ * what a consent flow IS, and it is worth stating because ours was accidentally page-scoped for three
120
+ * weeks: the script used to bail on
101
121
  * `!document.getElementById("kernel")`, a DOM sniff added to avoid asking on a 404. Feed pages have
102
122
  * no kernel either, so on every /feed/* page in the fleet the question was never asked — silently,
103
123
  * with nothing to notice it. A trust decision must never be inferred from an unrelated layout
@@ -128,21 +148,28 @@ export const CONSENT_JS = `(function(){try{
128
148
  var h=location.hostname;
129
149
  if(h==="localhost"||h==="127.0.0.1"||h==="::1"||h==="[::1]"||h.indexOf("dev-")===0)return;
130
150
  var el=document.getElementById("consent");if(!el||!el.showModal)return;
151
+ var hp=h.split("."),ap=(hp.length>2&&!/^[0-9.]+$/.test(h))?hp.slice(-2).join("."):h;
152
+ var AGE=34128000;
153
+ var rd=function(n){var m=document.cookie.match(new RegExp("(?:^|; )"+n+"=([^;]*)"));return m?decodeURIComponent(m[1]):null};
154
+ var wr=function(n,v,age){document.cookie=n+"="+encodeURIComponent(v)+"; Domain="+ap+"; Path=/"+(age?"; Max-Age="+age:"")+"; SameSite=Lax; Secure"};
155
+ var stored=function(){var c=rd("justai-consent");if(c)return c;var l=null;try{l=localStorage.getItem("consent")}catch(_){}if(l)wr("justai-consent",l,AGE);return l};
131
156
  var open=function(){if(!el.open){el.returnValue="";el.showModal();var p=el.querySelector(".preferred");if(p)p.focus()}};
132
157
  el.addEventListener("close",function(){
133
158
  var rv=el.returnValue;
134
159
  var v=rv==="confirm"?"granted+ads":rv==="denied"?"denied":null;
135
160
  if(v){var g=v==="denied"?"denied":"granted";
136
161
  gtag("consent","update",{analytics_storage:g,ad_storage:g,ad_user_data:g});
137
- try{localStorage.setItem("consent",v)}catch(_){}}
138
- else{try{sessionStorage.setItem("consent-later","1")}catch(_){}}
162
+ try{localStorage.setItem("consent",v)}catch(_){}
163
+ wr("justai-consent",v,AGE)}
164
+ else{wr("justai-consent-later","1",0);try{sessionStorage.setItem("consent-later","1")}catch(_){}}
139
165
  });
140
166
  var doors=document.querySelectorAll("[data-consent-open]");
141
167
  for(var i=0;i<doors.length;i++){var a=doors[i];
142
168
  if(!a.textContent)a.textContent=el.getAttribute("data-choice-label")||"privacy choice";
143
169
  a.hidden=false;var w=a.closest("[data-consent-door]");if(w)w.hidden=false;
144
170
  a.addEventListener("click",function(ev){ev.preventDefault();open()})}
145
- if(localStorage.getItem("consent"))return;
171
+ if(stored())return;
172
+ if(rd("justai-consent-later"))return;
146
173
  try{if(sessionStorage.getItem("consent-later"))return}catch(_){}
147
174
  var tz=Intl.DateTimeFormat().resolvedOptions().timeZone||"";
148
175
  var asked=tz.indexOf("Europe/")===0||[
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@justai/core",
3
- "version": "0.42.0",
3
+ "version": "0.43.0",
4
4
  "description": "The framework-free heart of the persona shell — the load-bearing behaviour (auth capture, reveal, ready) as plain strings, so Astro and Next inject the SAME logic instead of each re-writing it.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {