@blakfy/cookie 2.1.1 → 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,156 +1,172 @@
1
- # Migration: v1 → v2
2
-
3
- > Kısa cevap: **Değişiklik yapmana gerek yok.** v1 kullanıcıları `@1` etiketinde kalır, çalışmaya devam eder. v2 yeni features için opt-in.
4
-
5
- ---
6
-
7
- ## v1'de kal — hiçbir şey değişmez
8
-
9
- ```html
10
- <!-- Bu çalışmaya devam ediyor, kırılmıyor -->
11
- <script src="https://cdn.jsdelivr.net/gh/tariktunc/blakfy-cookie@1/cookie.js"
12
- data-blakfy-locale="auto"
13
- data-blakfy-policy-url="/cerez-politikasi"></script>
14
- ```
15
-
16
- v1 son sürümü `1.2.0`'da donduruldu. Critical security patch çıkarsa `1.2.x` patch sürümleri devam edebilir.
17
-
18
- ---
19
-
20
- ## v2'ye geç — 1 satır değişiklik
21
-
22
- ```diff
23
- - <script src="https://cdn.jsdelivr.net/gh/tariktunc/blakfy-cookie@1/cookie.js"
24
- + <script src="https://cdn.jsdelivr.net/gh/tariktunc/blakfy-cookie@v2/dist/cookie.min.js"
25
- data-blakfy-locale="auto"
26
- data-blakfy-policy-url="/cerez-politikasi"></script>
27
- ```
28
-
29
- Tüm v1 attribute'ları çalışmaya devam eder, kullanıcı consent'i korunur (cookie formatı uyumlu).
30
-
31
- ---
32
-
33
- ## Yeni Özellikleri Aktif Et (opsiyonel)
34
-
35
- ### Tag-gating
36
- ```html
37
- <!-- 3rd-party script'leri sar -->
38
- <script type="text/plain"
39
- data-blakfy-category="marketing"
40
- data-blakfy-src="https://connect.facebook.net/en_US/fbevents.js"></script>
41
- ```
42
-
43
- ### Preset kullan
44
- ```diff
45
- <script src="...@2/dist/cookie.min.js"
46
- data-blakfy-locale="auto"
47
- + data-blakfy-presets="ga4,gtm,facebook,clarity"></script>
48
- ```
49
-
50
- ### TCF v2.2
51
- ```diff
52
- + <script ... data-blakfy-tcf="true" data-blakfy-cmp-id="0"></script>
53
- ```
54
- (CMP ID `0` preview mode, sertifikasyon onayı sonrası gerçek ID girilir.)
55
-
56
- ### CCPA
57
- ```diff
58
- + <script ... data-blakfy-ccpa="auto"></script>
59
- ```
60
- (Otomatik jurisdiction tespitiyle Kaliforniya kullanıcılarına "Do Not Sell" linki gösterilir.)
61
-
62
- ---
63
-
64
- ## Next.js (cookie-next) Migration
65
-
66
- ### v1 (npm paketi yoktu, sadece GitHub'tan import)
67
-
68
- ```tsx
69
- // Eski
70
- import { BlakfyCookieProvider } from "@blakfy/cookie-next"; // ham .tsx
71
- ```
72
-
73
- ### v2 (npm public paketi)
74
-
75
- ```bash
76
- npm install @blakfy/cookie-next@2
77
- ```
78
-
79
- ```tsx
80
- // Yeni TypeScript tipler genişledi (23 dil), yeni hook'lar var
81
- import {
82
- BlakfyCookieProvider,
83
- ConsentModeDefault,
84
- useBlakfyConsent,
85
- useGating, // YENİ
86
- useTcf, // YENİ
87
- } from "@blakfy/cookie-next";
88
- ```
89
-
90
- ### Yeni hook örnekleri
91
-
92
- ```tsx
93
- // Kategori-tabanlı koşullu render
94
- function YouTubeEmbed({ id }: { id: string }) {
95
- const allowed = useGating("marketing");
96
- if (!allowed) return <Placeholder />;
97
- return <iframe src={`https://www.youtube.com/embed/${id}`} />;
98
- }
99
- ```
100
-
101
- ---
102
-
103
- ## API Değişiklikleri
104
-
105
- | API | v1 | v2 | Not |
106
- |---|---|---|---|
107
- | `acceptAll/rejectAll/open` | ✅ | ✅ | aynı |
108
- | `getConsent/getState` | | | aynı |
109
- | `onChange` | ✅ | ✅ | aynı |
110
- | `setLocale` | 9 dil | 23 dil | TS tipi genişletildi |
111
- | `onConsent(cat, fn)` | ❌ | ✅ | YENİ |
112
- | `registerCleanup` | ❌ | ✅ | YENİ |
113
- | `unblock/scan/usePreset` | ❌ | ✅ | YENİ |
114
- | `tcf.*` | ❌ | ✅ | YENİ |
115
- | `ccpa.*` | ❌ | ✅ | YENİ |
116
- | `getJurisdiction` | ❌ | ✅ | YENİ |
117
- | `getMainLang` | ✅ | ✅ | aynı |
118
-
119
- ---
120
-
121
- ## Cookie Formatı
122
-
123
- v2 cookie formatı v1 ile **geriye uyumlu**. v1 cookie'si v2 tarafından okunur, eksik alanlar default değerlerle doldurulur.
124
-
125
- ```js
126
- // v1 cookie örneği
127
- { essential, analytics, marketing, functional, timestamp, version, blakfy, locale, hash }
128
-
129
- // v2 cookie örneği (eklemeler)
130
- { ..., id (uuid), jurisdiction, tcString?, uspString?, mainLang? }
131
- ```
132
-
133
- Eski `hash` alanı v2'de okunmaz ama silinmez (geri dönüş güvenliği).
134
-
135
- ---
136
-
137
- ## Re-consent Davranışı
138
-
139
- ### v1 (BUG)
140
- `cookie.js` her sürüm güncellendiğinde **tüm kullanıcılar yeniden onay vermek zorundaydı**. Bu KVKK/GDPR uyumlu davranış değildi.
141
-
142
- ### v2 (DÜZELDİ)
143
- Sadece `data-blakfy-version` (politika versiyonu) değişimi re-consent tetikler. `cookie.js` patch/minor güncellemeleri kullanıcıyı etkilemez.
144
-
145
- ```js
146
- // v1
147
- if (s.version !== config.policyVersion || s.blakfy !== VERSION) return null;
148
- // v2
149
- if (s.version !== config.policyVersion) return null;
150
- ```
151
-
152
- ---
153
-
154
- ## Soru / Sorun?
155
-
156
- GitHub Issues → https://github.com/tariktunc/blakfy-cookie/issues
1
+ # Migration: v1 → v2
2
+
3
+ > Kısa cevap: **Değişiklik yapmana gerek yok.** v1 kullanıcıları `@1` etiketinde kalır, çalışmaya devam eder. v2 yeni features için opt-in.
4
+
5
+ ---
6
+
7
+ ## v1'de kal — hiçbir şey değişmez
8
+
9
+ ```html
10
+ <!-- Bu çalışmaya devam ediyor, kırılmıyor -->
11
+ <script
12
+ src="https://cdn.jsdelivr.net/gh/tariktunc/blakfy-cookie@1/cookie.js"
13
+ data-blakfy-locale="auto"
14
+ data-blakfy-policy-url="/cerez-politikasi"
15
+ ></script>
16
+ ```
17
+
18
+ v1 son sürümü `1.2.0`'da donduruldu. Critical security patch çıkarsa `1.2.x` patch sürümleri devam edebilir.
19
+
20
+ ---
21
+
22
+ ## v2'ye geç — 1 satır değişiklik
23
+
24
+ CDN URL'i jsDelivr GitHub'dan jsDelivr npm'e geçti (npm registry kaynağı, immutable, versionlu):
25
+
26
+ ```diff
27
+ - <script src="https://cdn.jsdelivr.net/gh/tariktunc/blakfy-cookie@1/cookie.js"
28
+ + <script src="https://cdn.jsdelivr.net/npm/@blakfy/cookie@2/dist/cookie.min.js"
29
+ data-blakfy-locale="auto"
30
+ data-blakfy-policy-url="/cerez-politikasi"></script>
31
+ ```
32
+
33
+ Bundler kullanıyorsan: `npm i @blakfy/cookie` ve `import "@blakfy/cookie"`.
34
+
35
+ Tüm v1 attribute'ları çalışmaya devam eder, kullanıcı consent'i korunur (cookie formatı uyumlu).
36
+
37
+ ---
38
+
39
+ ## Yeni Özellikleri Aktif Et (opsiyonel)
40
+
41
+ ### Tag-gating
42
+
43
+ ```html
44
+ <!-- 3rd-party script'leri sar -->
45
+ <script
46
+ type="text/plain"
47
+ data-blakfy-category="marketing"
48
+ data-blakfy-src="https://connect.facebook.net/en_US/fbevents.js"
49
+ ></script>
50
+ ```
51
+
52
+ ### Preset kullan
53
+
54
+ ```diff
55
+ <script src="...@2/dist/cookie.min.js"
56
+ data-blakfy-locale="auto"
57
+ + data-blakfy-presets="ga4,gtm,facebook,clarity"></script>
58
+ ```
59
+
60
+ ### TCF v2.2
61
+
62
+ ```diff
63
+ + <script ... data-blakfy-tcf="true" data-blakfy-cmp-id="0"></script>
64
+ ```
65
+
66
+ (CMP ID `0` preview mode, sertifikasyon onayı sonrası gerçek ID girilir.)
67
+
68
+ ### CCPA
69
+
70
+ ```diff
71
+ + <script ... data-blakfy-ccpa="auto"></script>
72
+ ```
73
+
74
+ (Otomatik jurisdiction tespitiyle Kaliforniya kullanıcılarına "Do Not Sell" linki gösterilir.)
75
+
76
+ ---
77
+
78
+ ## Next.js (cookie-next) Migration
79
+
80
+ ### v1 (npm paketi yoktu, sadece GitHub'tan import)
81
+
82
+ ```tsx
83
+ // Eski
84
+ import { BlakfyCookieProvider } from "@blakfy/cookie-next"; // ham .tsx
85
+ ```
86
+
87
+ ### v2 (npm public paketi)
88
+
89
+ ```bash
90
+ npm install @blakfy/cookie-next@2
91
+ ```
92
+
93
+ ```tsx
94
+ // Yeni TypeScript tipler genişledi (23 dil), yeni hook'lar var
95
+ import {
96
+ BlakfyCookieProvider,
97
+ ConsentModeDefault,
98
+ useBlakfyConsent,
99
+ useGating, // YENİ
100
+ useTcf, // YENİ
101
+ } from "@blakfy/cookie-next";
102
+ ```
103
+
104
+ ### Yeni hook örnekleri
105
+
106
+ ```tsx
107
+ // Kategori-tabanlı koşullu render
108
+ function YouTubeEmbed({ id }: { id: string }) {
109
+ const allowed = useGating("marketing");
110
+ if (!allowed) return <Placeholder />;
111
+ return <iframe src={`https://www.youtube.com/embed/${id}`} />;
112
+ }
113
+ ```
114
+
115
+ ---
116
+
117
+ ## API Değişiklikleri
118
+
119
+ | API | v1 | v2 | Not |
120
+ | -------------------------- | ----- | ------ | -------------------- |
121
+ | `acceptAll/rejectAll/open` | ✅ | ✅ | aynı |
122
+ | `getConsent/getState` | ✅ | ✅ | aynı |
123
+ | `onChange` | ✅ | ✅ | aynı |
124
+ | `setLocale` | 9 dil | 23 dil | TS tipi genişletildi |
125
+ | `onConsent(cat, fn)` | ❌ | ✅ | YENİ |
126
+ | `registerCleanup` | ❌ | ✅ | YENİ |
127
+ | `unblock/scan/usePreset` | ❌ | ✅ | YENİ |
128
+ | `tcf.*` | ❌ | ✅ | YENİ |
129
+ | `ccpa.*` | ❌ | ✅ | YENİ |
130
+ | `getJurisdiction` | ❌ | ✅ | YENİ |
131
+ | `getMainLang` | ✅ | ✅ | aynı |
132
+
133
+ ---
134
+
135
+ ## Cookie Formatı
136
+
137
+ v2 cookie formatı v1 ile **geriye uyumlu**. v1 cookie'si v2 tarafından okunur, eksik alanlar default değerlerle doldurulur.
138
+
139
+ ```js
140
+ // v1 cookie örneği
141
+ { essential, analytics, marketing, functional, timestamp, version, blakfy, locale, hash }
142
+
143
+ // v2 cookie örneği (eklemeler)
144
+ { ..., id (uuid), jurisdiction, tcString?, uspString?, mainLang? }
145
+ ```
146
+
147
+ Eski `hash` alanı v2'de okunmaz ama silinmez (geri dönüş güvenliği).
148
+
149
+ ---
150
+
151
+ ## Re-consent Davranışı
152
+
153
+ ### v1 (BUG)
154
+
155
+ `cookie.js` her sürüm güncellendiğinde **tüm kullanıcılar yeniden onay vermek zorundaydı**. Bu KVKK/GDPR uyumlu davranış değildi.
156
+
157
+ ### v2 (DÜZELDİ)
158
+
159
+ Sadece `data-blakfy-version` (politika versiyonu) değişimi re-consent tetikler. `cookie.js` patch/minor güncellemeleri kullanıcıyı etkilemez.
160
+
161
+ ```js
162
+ // v1
163
+ if (s.version !== config.policyVersion || s.blakfy !== VERSION) return null;
164
+ // v2
165
+ if (s.version !== config.policyVersion) return null;
166
+ ```
167
+
168
+ ---
169
+
170
+ ## Soru / Sorun?
171
+
172
+ GitHub Issues → https://github.com/tariktunc/blakfy-cookie/issues
@@ -0,0 +1,176 @@
1
+ # Release Runbook
2
+
3
+ Operator-facing guide for cutting a Blakfy Cookie release. Bu repository iki npm paketi yayınlar (`@blakfy/cookie` ve `@blakfy/cookie-next`). Yayın akışı **tag-driven** — tag push'tan sonra GitHub Actions (`.github/workflows/release.yml`) GitHub Release oluşturur ve jsDelivr cache purge eder.
4
+
5
+ > **Not:** Şu anki workflow npm publish için sadece `@blakfy/cookie-next`'i yayınlıyor. Manuel yayın akışını kullanıyoruz — aşağıda her iki paketi de elle yayınlamayı içeren güncel akış var. Workflow'u iki paket yayınına genişletmek ayrı bir iş (TODO).
6
+
7
+ ## Pre-release checklist
8
+
9
+ - [ ] Tüm PR'lar `main`'e merge edildi
10
+ - [ ] `CHANGELOG.md` yeni `[x.y.z]` bölümü ile güncellendi
11
+ - [ ] Sürüm bump'lı:
12
+ - [ ] `package.json` (`version`)
13
+ - [ ] `packages/cookie-next/package.json` (`version`)
14
+ - [ ] `src/api.js` `VERSION` constant
15
+ - [ ] README header (badge + `Versiyon:` satırı + örnek CDN URL'leri)
16
+ - [ ] `examples/` içindeki HTML/PHP CDN URL'leri (önemliyse)
17
+ - [ ] Build çalışıyor: `npm run build:all` (esbuild + tsup)
18
+ - [ ] Test green: `npm test`
19
+ - [ ] Boyut bütçesi: `npm run size` (core ≤ 32 KB)
20
+ - [ ] `npm pack --dry-run` (kök) ve `cd packages/cookie-next && npm pack --dry-run` ile tarball içeriği doğrulandı
21
+ - Kök paket için: `dist/`, `status.json`, README, ARCHITECTURE.md, COMPLIANCE.md, TCF-CERTIFICATION.md, MIGRATION.md, CHANGELOG.md, LICENSE
22
+ - cookie-next için: `dist/index.{js,mjs,d.ts,d.mts}`, README
23
+
24
+ ## npm authentication setup (one-time)
25
+
26
+ Yayın için npm token gerekiyor. **Granular Access Token** öneriliyor (Classic Automation Token yerine):
27
+
28
+ 1. https://www.npmjs.com/settings/<USER>/tokens/granular-access-tokens/new
29
+ 2. **Token name:** `blakfy-publish-bypass2fa` (veya tercih ettiğin)
30
+ 3. **Expiration:** 30-90 gün (uzun süreli token önerilmez)
31
+ 4. **Permissions:**
32
+ - **Packages and scopes:** "Read and write" + scope `@blakfy`
33
+ - **Organizations:** "Read and write" + `blakfy`
34
+ 5. **Bypass two-factor authentication:** ✅ (otomasyon için)
35
+ 6. Generate → token'ı kopyala (sadece bir kez gösterilir)
36
+ 7. Yerel yayın için: `~/.npmrc` dosyasına ekle:
37
+ ```
38
+ //registry.npmjs.org/:_authToken=npm_xxxxxxxxxxxx
39
+ ```
40
+ veya CI için GitHub repo Secrets'a `NPM_TOKEN` adıyla ekle.
41
+
42
+ Doğrulama: `npm whoami` → kullanıcı adın görünmeli.
43
+
44
+ ## Releasing v2.x.y (current — manual two-package publish)
45
+
46
+ ### Step 1 — Source güncellemeleri
47
+
48
+ ```bash
49
+ # Sürümü her yerde bump et
50
+ # package.json, packages/cookie-next/package.json, src/api.js VERSION
51
+ # CHANGELOG.md'ye yeni bölüm ekle
52
+ # README'deki sabit CDN URL örneklerini güncelle (@2.x.y)
53
+ ```
54
+
55
+ ### Step 2 — Build + dry-run
56
+
57
+ ```bash
58
+ npm install # ilk kurulum veya lockfile değiştiyse
59
+ npm run build:all # esbuild + tsup
60
+ npm test
61
+ npm pack --dry-run # ana paket içeriği
62
+ cd packages/cookie-next
63
+ npm pack --dry-run # cookie-next içeriği
64
+ cd ../..
65
+ ```
66
+
67
+ ### Step 3 — Publish
68
+
69
+ ```bash
70
+ # Ana paket
71
+ npm publish --access public
72
+
73
+ # Wrapper paket
74
+ cd packages/cookie-next
75
+ npm publish --access public
76
+ cd ../..
77
+ ```
78
+
79
+ Token bypass-2FA ise OTP istenmez. Aksi takdirde `--otp=123456` ekle.
80
+
81
+ ### Step 4 — Commit + tag + push
82
+
83
+ ```bash
84
+ git add -u
85
+ git commit -m "chore(release): v2.x.y — <ana değişiklik>"
86
+ git tag -a v2.x.y -m "Release v2.x.y"
87
+ git push origin main
88
+ git push origin v2.x.y
89
+ ```
90
+
91
+ Pre-release tag'leri (örn. `v2.0.0-alpha.1`) workflow tarafından otomatik prerelease işaretlenir (`-` içerirse).
92
+
93
+ ### Step 5 — GitHub Release
94
+
95
+ Workflow tag push'tan sonra otomatik release oluşturur (build + body + asset'ler). İçerik genellikle güzel olmaz (CHANGELOG'un tamamını body olarak çeker). Manuel düzeltme:
96
+
97
+ ```bash
98
+ gh release edit v2.x.y --title "v2.x.y — <başlık>" --notes-file <(cat <<'EOF'
99
+ ## Summary
100
+ ...
101
+
102
+ ## Changed
103
+ ...
104
+
105
+ ## Notes
106
+ ...
107
+ EOF
108
+ )
109
+ ```
110
+
111
+ Veya release yoksa oluştur:
112
+
113
+ ```bash
114
+ gh release create v2.x.y --title "..." --notes-file ...
115
+ ```
116
+
117
+ ### Step 6 — Verify
118
+
119
+ ```bash
120
+ # npm registry (CLI cache 1-2 dakika gecikebilir)
121
+ npm view @blakfy/cookie version
122
+ npm view @blakfy/cookie-next version
123
+
124
+ # CDN
125
+ curl -I https://cdn.jsdelivr.net/npm/@blakfy/cookie@2.x.y/dist/cookie.min.js
126
+ curl -I https://cdn.jsdelivr.net/npm/@blakfy/cookie@2/dist/cookie.min.js
127
+ ```
128
+
129
+ - npm sayfaları:
130
+ - https://www.npmjs.com/package/@blakfy/cookie
131
+ - https://www.npmjs.com/package/@blakfy/cookie-next
132
+ - GitHub Release: https://github.com/tariktunc/blakfy-cookie/releases
133
+ - Smoke test: `examples/vanilla-html.html` veya `examples/nextjs/` ile real-world test.
134
+
135
+ ### Step 7 — Communicate
136
+
137
+ - README zaten yayında olan version'ı yansıtmalı (Step 1'de güncellendi).
138
+ - Major/minor için duyuru (Twitter / LinkedIn).
139
+ - Breaking change varsa `MIGRATION.md` linkle.
140
+
141
+ ## Hotfix / patch process
142
+
143
+ 1. `main`'den fix branch: `git checkout -b fix/<topic>`
144
+ 2. PR → `main`, CI green sonrası merge
145
+ 3. Patch version bump (`v2.x.(y+1)`), `CHANGELOG.md` güncel, commit
146
+ 4. Yukarıdaki Step 2-6 akışını izle (build, publish, tag, release)
147
+ 5. jsDelivr `@2` semver tag'i yeni patch'i otomatik servise alır (~5-10 dakika cache propagasyon)
148
+
149
+ ## Rolling back
150
+
151
+ **Tag veya GitHub Release silme** — CDN tüketicilerinin cache'i bozulur, reproducibility kaybedilir.
152
+
153
+ Bunun yerine:
154
+
155
+ 1. Düzeltmeyi `main`'e land et
156
+ 2. Yeni patch tag (`v2.x.(y+1)`) at + yayınla
157
+ 3. `@2` major-pinned jsDelivr URL'i otomatik yeni patch'e geçer
158
+
159
+ npm üzerinde **`npm unpublish` yapma** — 72 saat içinde mümkün ama topluluk uyarır. Bunun yerine yeni patch'le düzelt. Acil durumda `npm deprecate @blakfy/cookie@2.x.y "<reason>"` ile eskisini deprecate et — kullanıcı hâlâ kurabilir ama uyarı görür.
160
+
161
+ ## TCF v2.2 sertifikasyon
162
+
163
+ Bkz. [tcf-certification.md](./tcf-certification.md). Sertifikasyon öncesi: `cmpId=0` (preview mode). Sonrası: atanan CMP ID'yi source'a yaz ve site'larda `data-blakfy-cmp-id` attribute'ını güncelle.
164
+
165
+ ## Troubleshooting
166
+
167
+ - **`npm publish` E403 / 401**: Token yok, scope yetersiz veya 2FA OTP gerekiyor. Granular token'ın `@blakfy` scope read+write olmalı, "Bypass 2FA" işaretli.
168
+ - **`npm publish` E409 (conflict)**: Aynı sürüm zaten yayında. Patch bump et, yeniden dene.
169
+ - **`npm view` E404 sonra publish**: Registry CDN propagasyonu, 1-2 dakika bekle.
170
+ - **jsDelivr eski dosyayı serve ediyor**: jsDelivr CDN cache TTL ~12 saat semver tag'lerde. Force purge:
171
+ ```bash
172
+ curl https://purge.jsdelivr.net/npm/@blakfy/cookie@<version>/dist/cookie.min.js
173
+ ```
174
+ - **Release notes boş gözüküyor**: Workflow `body_path: CHANGELOG.md` kullanır → tüm CHANGELOG body'ye düşer. Manuel `gh release edit` ile sürüme özgü içeriği yaz.
175
+ - **Pre-release latest olarak işaretlendi**: Tag adında `-` olmalı (`v2.0.0-alpha.1`). Workflow `prerelease: true`'yu otomatik flagler.
176
+ - **Workflow `publish-npm` skipped**: `NPM_TOKEN` secret yoksa skip — manuel publish ile kapatılabilir (current default).