@blakfy/cookie 2.1.2 → 2.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.
@@ -1,191 +1,199 @@
1
- # Blakfy Cookie — Compliance Reference
2
-
3
- > Hangi yasa/motor/standart için ne yapıyoruz, hangi modül karşılıyor.
4
-
5
- ---
6
-
7
- ## 1. Compliance Matrisi
8
-
9
- | Yasa / Standart | Yetki Alanı | Modül | Durum (v2.0.0) |
10
- |---|---|---|---|
11
- | **GDPR** | AB | core + ui (eşit prominence butonlar, pre-tick yok) | ✅ |
12
- | **ePrivacy Directive** | AB | core (consent öncesi cookie konmaz) | ✅ |
13
- | **KVKK** | Türkiye | core/audit.js (Md.12 kanıt yükümlülüğü) | ✅ |
14
- | **CCPA / CPRA** | Kaliforniya, ABD | compliance/ccpa.js | ✅ |
15
- | **LGPD** | Brezilya | i18n/translations/pt.js + jurisdiction | ⚠️ (v2.1) |
16
- | **Google Consent Mode v2** | Google ekosistemi | compliance/google-cmv2.js | ✅ |
17
- | **Microsoft UET Consent Mode** | Bing Ads + Clarity | compliance/microsoft-uet.js | ✅ |
18
- | **Yandex Metrica Consent** | Yandex ekosistemi | compliance/yandex-metrica.js | ✅ |
19
- | **IAB TCF v2.2** | AB AdTech (AdSense/Ad Manager) | compliance/tcf-v2.js | ✅ kod + ⏳ sertifikasyon |
20
- | **GPC** (Global Privacy Control) | Tarayıcı standardı, CA yasal | compliance/gpc.js | ✅ |
21
- | **DNT** (Do Not Track) | Tarayıcı standardı | compliance/dnt.js | ✅ |
22
-
23
- ---
24
-
25
- ## 2. Google Consent Mode v2
26
-
27
- **Sinyal:**
28
- ```js
29
- gtag('consent', 'update', {
30
- ad_storage: marketing ? 'granted' : 'denied',
31
- ad_user_data: marketing ? 'granted' : 'denied',
32
- ad_personalization: marketing ? 'granted' : 'denied',
33
- analytics_storage: analytics ? 'granted' : 'denied',
34
- functionality_storage: functional ? 'granted' : 'denied',
35
- personalization_storage: functional ? 'granted' : 'denied',
36
- security_storage: 'granted'
37
- });
38
- ```
39
-
40
- **Bootstrap (cookie-defaults.min.js):**
41
- - Tüm sinyaller default `denied`
42
- - `wait_for_update: 500` ile GTM/GA4 cevap bekler
43
- - `gtag` global fonksiyonu yoksa stub kurulur
44
-
45
- ---
46
-
47
- ## 3. Microsoft UET Consent Mode
48
-
49
- **Sinyal:**
50
- ```js
51
- window.uetq = window.uetq || [];
52
- window.uetq.push('consent', 'update', {
53
- ad_storage: marketing ? 'granted' : 'denied'
54
- });
55
- ```
56
-
57
- Bing Ads (UET tag) ve Microsoft Clarity bunu okur. v2.0.0 itibariyle Clarity zaten bu sinyali destekliyor.
58
-
59
- **Bootstrap:** `uetq` push queue stub kurulur, default `denied`.
60
-
61
- ---
62
-
63
- ## 4. Yandex Metrica Consent
64
-
65
- Yandex'in Google gibi standart bir consent API'si yok. Yaklaşımımız:
66
-
67
- - Onay yokken Metrica script'leri **engellenir** (gating layer).
68
- - Onay verilince `ym(counterId, 'init', {...})` çağrılır.
69
- - **Webvisor (session replay)** ekstra kategori — `marketing` değil, ayrı `recording` kategorisi olarak işaretlenir (KVKK/GDPR yorum farkı).
70
- - Cookie temizliği: `_ym_*`, `_ym_uid`, `_ym_d`, `_ym_isad`, `yabs-frequency`, `yandexuid`.
71
-
72
- ---
73
-
74
- ## 5. IAB TCF v2.2
75
-
76
- **Teknik kapsam (v2.0.0 ile gelen kod):**
77
-
78
- - `window.__tcfapi(command, version, callback, parameter)` global fonksiyonu (IAB standardı)
79
- - TC string encoding (Base64URL, vendor segments dahil)
80
- - Global Vendor List (GVL) fetch — `vendor-list.consensu.org/v3/vendor-list.json`
81
- - `getTCData`, `addEventListener`, `removeEventListener` komutları
82
- - `data-blakfy-cmp-id="0"` preview/test mode
83
-
84
- **Sertifikasyon süreci (kullanıcı tarafı):**
85
-
86
- 1. https://iabeurope.eu/cmp-list/ üzerinden başvuru
87
- 2. Audit (kod + UI + DSAR/data subject request akışı incelenir)
88
- 3. Annual fee (~€2.000)
89
- 4. CMP ID atanır → `data-blakfy-cmp-id="123"` ile yazılır
90
- 5. Onay öncesi widget "preview mode"da çalışır, onay sonrası prod
91
-
92
- Süreç 2-3 ay. Detay: [TCF-CERTIFICATION.md](./TCF-CERTIFICATION.md)
93
-
94
- ---
95
-
96
- ## 6. CCPA / CPRA
97
-
98
- **Kapsam:** Kaliforniya sakinleri için.
99
-
100
- **Tetiklenme:** `src/geo/jurisdiction.js` ABD/CA tespit ederse:
101
- - Banner "Reddet" yerine **"Do Not Sell or Share My Personal Information"** olarak değiştirilir.
102
- - Footer'a kalıcı `<a class="blakfy-ccpa-link">` eklenir (yasal zorunluluk).
103
- - `Sec-GPC: 1` header otomatik opt-out say.
104
- - USP string `1YYY` formatında set edilir (versiyon, opt-out, sale, third-party).
105
-
106
- **API:**
107
- ```js
108
- BlakfyCookie.ccpa.optOut()
109
- BlakfyCookie.ccpa.isOptedOut()
110
- ```
111
-
112
- ---
113
-
114
- ## 7. GPC (Global Privacy Control)
115
-
116
- `navigator.globalPrivacyControl === true` ise:
117
- - `marketing` ve `analytics` kategorileri **otomatik denied** (kullanıcı açık onay vermediyse)
118
- - CCPA jurisdiction'da yasal olarak zorunlu opt-out
119
- - GDPR jurisdiction'da rehberlik niteliğinde, biz default'ta saygı gösteriyoruz
120
-
121
- Override: `data-blakfy-gpc="ignore"` ile kapatılabilir (önerilmez).
122
-
123
- ---
124
-
125
- ## 8. DNT (Do Not Track)
126
-
127
- `navigator.doNotTrack === "1"` ise:
128
- - Default'ta **sadece UI'da işaret** (kullanıcı görsün, "GPC veya DNT etkin" yazısı)
129
- - `data-blakfy-dnt="auto-deny"` ile auto-deny opsiyonel
130
-
131
- DNT eski/zayıf bir standart, GPC tercih edilir.
132
-
133
- ---
134
-
135
- ## 9. Jurisdiction Tespiti
136
-
137
- `src/geo/jurisdiction.js` 3 strateji dener:
138
-
139
- 1. **Cloudflare** `CF-IPCountry` header (server-rendered sites)
140
- 2. **Server endpoint** `data-blakfy-geo-endpoint="/api/geo"` (opt-in)
141
- 3. **Client-side fallback:** `Intl.DateTimeFormat().resolvedOptions().timeZone` → kaba bölge tahmini
142
-
143
- Sonuç: `"GDPR"` | `"CCPA"` | `"LGPD"` | `"default"`
144
-
145
- ---
146
-
147
- ## 10. Audit Log (KVKK Md.12 + GDPR Art.7(1))
148
-
149
- Her consent değişikliği `data-blakfy-audit-endpoint`'e POST edilir:
150
-
151
- ```json
152
- {
153
- "id": "uuid-v4-anonim-id",
154
- "timestamp": "2026-04-30T12:00:00Z",
155
- "action": "accept_all" | "reject_all" | "save_preferences",
156
- "state": { ... },
157
- "jurisdiction": "GDPR",
158
- "userAgent": "...",
159
- "url": "...",
160
- "policyVersion": "1.0",
161
- "blakfy": "2.0.0",
162
- "tcString": "...",
163
- "uspString": "..."
164
- }
165
- ```
166
-
167
- **Anonim ID:** `crypto.randomUUID()` — fingerprint **değil** (v1'deki `makeHash()` kaldırıldı).
168
-
169
- ---
170
-
171
- ## 11. Kategori → Yasal Temel Eşlemesi
172
-
173
- | Kategori | GDPR Yasal Temel | KVKK | CCPA |
174
- |---|---|---|---|
175
- | `essential` | Art. 6(1)(b) — sözleşme/zorunluluk | Md.5(2)(c) | exempt |
176
- | `analytics` | Art. 6(1)(a) — açık rıza | Md.5(1) | optable |
177
- | `marketing` | Art. 6(1)(a) — açık rıza | Md.5(1) | optable + GPC saygısı |
178
- | `functional` | Art. 6(1)(a) açık rıza | Md.5(1) | optable |
179
- | `recording` (Webvisor) | Art. 6(1)(a) — ek granular onay | Md.5(1) açık rıza | optable |
180
-
181
- ---
182
-
183
- ## 12. Test Kapsamı
184
-
185
- `tests/compliance/` altında her modül için ayrı test:
186
- - `google-cmv2.test.js` — gtag stub kurulumu, update sinyalleri
187
- - `microsoft-uet.test.js` — uetq queue, consent push
188
- - `yandex-metrica.test.js` — cookie engelleme, Webvisor ayrı kategori
189
- - `tcf-v2.test.js` — `__tcfapi` komut yüzeyi, TC string format
190
- - `ccpa.test.js` USP string, DNT/GPC saygısı
191
- - `gpc.test.js` — auto-deny davranışı
1
+ # Blakfy Cookie — Compliance Reference
2
+
3
+ > Hangi yasa/motor/standart için ne yapıyoruz, hangi modül karşılıyor.
4
+
5
+ ---
6
+
7
+ ## 1. Compliance Matrisi
8
+
9
+ | Yasa / Standart | Yetki Alanı | Modül | Durum (v2.0.0) |
10
+ | -------------------------------- | ------------------------------ | -------------------------------------------------- | ------------------------- |
11
+ | **GDPR** | AB | core + ui (eşit prominence butonlar, pre-tick yok) | ✅ |
12
+ | **ePrivacy Directive** | AB | core (consent öncesi cookie konmaz) | ✅ |
13
+ | **KVKK** | Türkiye | core/audit.js (Md.12 kanıt yükümlülüğü) | ✅ |
14
+ | **CCPA / CPRA** | Kaliforniya, ABD | compliance/ccpa.js | ✅ |
15
+ | **LGPD** | Brezilya | i18n/translations/pt.js + jurisdiction | ⚠️ (v2.1) |
16
+ | **Google Consent Mode v2** | Google ekosistemi | compliance/google-cmv2.js | ✅ |
17
+ | **Microsoft UET Consent Mode** | Bing Ads + Clarity | compliance/microsoft-uet.js | ✅ |
18
+ | **Yandex Metrica Consent** | Yandex ekosistemi | compliance/yandex-metrica.js | ✅ |
19
+ | **IAB TCF v2.2** | AB AdTech (AdSense/Ad Manager) | compliance/tcf-v2.js | ✅ kod + ⏳ sertifikasyon |
20
+ | **GPC** (Global Privacy Control) | Tarayıcı standardı, CA yasal | compliance/gpc.js | ✅ |
21
+ | **DNT** (Do Not Track) | Tarayıcı standardı | compliance/dnt.js | ✅ |
22
+
23
+ ---
24
+
25
+ ## 2. Google Consent Mode v2
26
+
27
+ **Sinyal:**
28
+
29
+ ```js
30
+ gtag("consent", "update", {
31
+ ad_storage: marketing ? "granted" : "denied",
32
+ ad_user_data: marketing ? "granted" : "denied",
33
+ ad_personalization: marketing ? "granted" : "denied",
34
+ analytics_storage: analytics ? "granted" : "denied",
35
+ functionality_storage: functional ? "granted" : "denied",
36
+ personalization_storage: functional ? "granted" : "denied",
37
+ security_storage: "granted",
38
+ });
39
+ ```
40
+
41
+ **Bootstrap (cookie-defaults.min.js):**
42
+
43
+ - Tüm sinyaller default `denied`
44
+ - `wait_for_update: 500` ile GTM/GA4 cevap bekler
45
+ - `gtag` global fonksiyonu yoksa stub kurulur
46
+
47
+ ---
48
+
49
+ ## 3. Microsoft UET Consent Mode
50
+
51
+ **Sinyal:**
52
+
53
+ ```js
54
+ window.uetq = window.uetq || [];
55
+ window.uetq.push("consent", "update", {
56
+ ad_storage: marketing ? "granted" : "denied",
57
+ });
58
+ ```
59
+
60
+ Bing Ads (UET tag) ve Microsoft Clarity bunu okur. v2.0.0 itibariyle Clarity zaten bu sinyali destekliyor.
61
+
62
+ **Bootstrap:** `uetq` push queue stub kurulur, default `denied`.
63
+
64
+ ---
65
+
66
+ ## 4. Yandex Metrica Consent
67
+
68
+ Yandex'in Google gibi standart bir consent API'si yok. Yaklaşımımız:
69
+
70
+ - Onay yokken Metrica script'leri **engellenir** (gating layer).
71
+ - Onay verilince `ym(counterId, 'init', {...})` çağrılır.
72
+ - **Webvisor (session replay)** ekstra kategori — `marketing` değil, ayrı `recording` kategorisi olarak işaretlenir (KVKK/GDPR yorum farkı).
73
+ - Cookie temizliği: `_ym_*`, `_ym_uid`, `_ym_d`, `_ym_isad`, `yabs-frequency`, `yandexuid`.
74
+
75
+ ---
76
+
77
+ ## 5. IAB TCF v2.2
78
+
79
+ **Teknik kapsam (v2.0.0 ile gelen kod):**
80
+
81
+ - `window.__tcfapi(command, version, callback, parameter)` global fonksiyonu (IAB standardı)
82
+ - TC string encoding (Base64URL, vendor segments dahil)
83
+ - Global Vendor List (GVL) fetch — `vendor-list.consensu.org/v3/vendor-list.json`
84
+ - `getTCData`, `addEventListener`, `removeEventListener` komutları
85
+ - `data-blakfy-cmp-id="0"` → preview/test mode
86
+
87
+ **Sertifikasyon süreci (kullanıcı tarafı):**
88
+
89
+ 1. https://iabeurope.eu/cmp-list/ üzerinden başvuru
90
+ 2. Audit (kod + UI + DSAR/data subject request akışı incelenir)
91
+ 3. Annual fee (~€2.000)
92
+ 4. CMP ID atanır `data-blakfy-cmp-id="123"` ile yazılır
93
+ 5. Onay öncesi widget "preview mode"da çalışır, onay sonrası prod
94
+
95
+ ⏱ Süreç 2-3 ay. Detay: [tcf-certification.md](./tcf-certification.md)
96
+
97
+ ---
98
+
99
+ ## 6. CCPA / CPRA
100
+
101
+ **Kapsam:** Kaliforniya sakinleri için.
102
+
103
+ **Tetiklenme:** `src/geo/jurisdiction.js` ABD/CA tespit ederse:
104
+
105
+ - Banner "Reddet" yerine **"Do Not Sell or Share My Personal Information"** olarak değiştirilir.
106
+ - Footer'a kalıcı `<a class="blakfy-ccpa-link">` eklenir (yasal zorunluluk).
107
+ - `Sec-GPC: 1` header otomatik opt-out say.
108
+ - USP string `1YYY` formatında set edilir (versiyon, opt-out, sale, third-party).
109
+
110
+ **API:**
111
+
112
+ ```js
113
+ BlakfyCookie.ccpa.optOut();
114
+ BlakfyCookie.ccpa.isOptedOut();
115
+ ```
116
+
117
+ ---
118
+
119
+ ## 7. GPC (Global Privacy Control)
120
+
121
+ `navigator.globalPrivacyControl === true` ise:
122
+
123
+ - `marketing` ve `analytics` kategorileri **otomatik denied** (kullanıcı açık onay vermediyse)
124
+ - CCPA jurisdiction'da yasal olarak zorunlu opt-out
125
+ - GDPR jurisdiction'da rehberlik niteliğinde, biz default'ta saygı gösteriyoruz
126
+
127
+ Override: `data-blakfy-gpc="ignore"` ile kapatılabilir (önerilmez).
128
+
129
+ ---
130
+
131
+ ## 8. DNT (Do Not Track)
132
+
133
+ `navigator.doNotTrack === "1"` ise:
134
+
135
+ - Default'ta **sadece UI'da işaret** (kullanıcı görsün, "GPC veya DNT etkin" yazısı)
136
+ - `data-blakfy-dnt="auto-deny"` ile auto-deny opsiyonel
137
+
138
+ DNT eski/zayıf bir standart, GPC tercih edilir.
139
+
140
+ ---
141
+
142
+ ## 9. Jurisdiction Tespiti
143
+
144
+ `src/geo/jurisdiction.js` 3 strateji dener:
145
+
146
+ 1. **Cloudflare** `CF-IPCountry` header (server-rendered sites)
147
+ 2. **Server endpoint** `data-blakfy-geo-endpoint="/api/geo"` (opt-in)
148
+ 3. **Client-side fallback:** `Intl.DateTimeFormat().resolvedOptions().timeZone` → kaba bölge tahmini
149
+
150
+ Sonuç: `"GDPR"` | `"CCPA"` | `"LGPD"` | `"default"`
151
+
152
+ ---
153
+
154
+ ## 10. Audit Log (KVKK Md.12 + GDPR Art.7(1))
155
+
156
+ Her consent değişikliği `data-blakfy-audit-endpoint`'e POST edilir:
157
+
158
+ ```json
159
+ {
160
+ "id": "uuid-v4-anonim-id",
161
+ "timestamp": "2026-04-30T12:00:00Z",
162
+ "action": "accept_all" | "reject_all" | "save_preferences",
163
+ "state": { ... },
164
+ "jurisdiction": "GDPR",
165
+ "userAgent": "...",
166
+ "url": "...",
167
+ "policyVersion": "1.0",
168
+ "blakfy": "2.0.0",
169
+ "tcString": "...",
170
+ "uspString": "..."
171
+ }
172
+ ```
173
+
174
+ **Anonim ID:** `crypto.randomUUID()` — fingerprint **değil** (v1'deki `makeHash()` kaldırıldı).
175
+
176
+ ---
177
+
178
+ ## 11. Kategori Yasal Temel Eşlemesi
179
+
180
+ | Kategori | GDPR Yasal Temel | KVKK | CCPA |
181
+ | ---------------------- | ---------------------------------- | ----------------- | --------------------- |
182
+ | `essential` | Art. 6(1)(b) — sözleşme/zorunluluk | Md.5(2)(c) | exempt |
183
+ | `analytics` | Art. 6(1)(a) — açık rıza | Md.5(1) | optable |
184
+ | `marketing` | Art. 6(1)(a) — açık rıza | Md.5(1) | optable + GPC saygısı |
185
+ | `functional` | Art. 6(1)(a) açık rıza | Md.5(1) | optable |
186
+ | `recording` (Webvisor) | Art. 6(1)(a) ek granular onay | Md.5(1) açık rıza | optable |
187
+
188
+ ---
189
+
190
+ ## 12. Test Kapsamı
191
+
192
+ `tests/compliance/` altında her modül için ayrı test:
193
+
194
+ - `google-cmv2.test.js` — gtag stub kurulumu, update sinyalleri
195
+ - `microsoft-uet.test.js` — uetq queue, consent push
196
+ - `yandex-metrica.test.js` — cookie engelleme, Webvisor ayrı kategori
197
+ - `tcf-v2.test.js` — `__tcfapi` komut yüzeyi, TC string format
198
+ - `ccpa.test.js` — USP string, DNT/GPC saygısı
199
+ - `gpc.test.js` — auto-deny davranışı