@coinbase/cookie-manager
Advanced tools
Comparing version 1.1.3 to 1.1.4
# Changelog | ||
## 1.1.4 (06/11/2024) | ||
- Updated next version from 14.0.0 to 14.1.1 | ||
- Updated braces from 3.0.2 to 3.0.3 | ||
- Removed call to Buffer | ||
- Ensure navigator is defined before referencing | ||
## 1.1.3 (05/03/2024) | ||
@@ -4,0 +11,0 @@ |
@@ -10,4 +10,7 @@ "use strict"; | ||
} | ||
if (typeof window === 'undefined' || typeof window.navigator === 'undefined') { | ||
return preference; | ||
} | ||
// If we lack GPC or it's set ot false we are done | ||
if (!navigator.globalPrivacyControl) { | ||
if (!window.navigator.globalPrivacyControl) { | ||
return preference; | ||
@@ -14,0 +17,0 @@ } |
@@ -11,5 +11,10 @@ "use strict"; | ||
} | ||
if (!navigator.globalPrivacyControl) { | ||
// TODO: We want to support server side render flows | ||
// where the user can set an initial value and indicate that gpc has been enabled | ||
if (typeof window === 'undefined' || typeof window.navigator === 'undefined') { | ||
return preference; | ||
} | ||
if (!window.navigator.globalPrivacyControl) { | ||
return preference; | ||
} | ||
// If the user had opted in to GPC we want to honor it | ||
@@ -16,0 +21,0 @@ const categories = preference.consent.filter((cat) => cat !== types_1.TrackingCategory.TARGETING); |
@@ -5,4 +5,6 @@ "use strict"; | ||
const isMaxKBSize = (str, max) => { | ||
return Buffer.from(str).length / constants_1.KB > max; | ||
// length value contains the length of the string in UTF-16 code units. | ||
// each code unit is 2 bytes wide | ||
return (str.length * 2) / constants_1.KB > max; | ||
}; | ||
exports.default = isMaxKBSize; |
{ | ||
"name": "@coinbase/cookie-manager", | ||
"version": "1.1.3", | ||
"version": "1.1.4", | ||
"description": "Coinbase Cookie Manager", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -11,4 +11,9 @@ import { AdTrackingPreference, Region } from '../types'; | ||
} | ||
if (typeof window === 'undefined' || typeof window.navigator === 'undefined') { | ||
return preference; | ||
} | ||
// If we lack GPC or it's set ot false we are done | ||
if (!(navigator as any).globalPrivacyControl) { | ||
if (!(window.navigator as any).globalPrivacyControl) { | ||
return preference; | ||
@@ -15,0 +20,0 @@ } |
import { Region, TrackingCategory, TrackingPreference } from '../types'; | ||
// { region: Region.DEFAULT, consent: ['necessary', 'performance', 'functional', 'targeting'] } | ||
@@ -10,5 +9,11 @@ const applyGpcToCookiePref = (preference: TrackingPreference): TrackingPreference => { | ||
if (!(navigator as any).globalPrivacyControl) { | ||
// TODO: We want to support server side render flows | ||
// where the user can set an initial value and indicate that gpc has been enabled | ||
if (typeof window === 'undefined' || typeof window.navigator === 'undefined') { | ||
return preference; | ||
} | ||
if (!(window.navigator as any).globalPrivacyControl) { | ||
return preference; | ||
} | ||
// If the user had opted in to GPC we want to honor it | ||
@@ -15,0 +20,0 @@ const categories = preference.consent.filter((cat) => cat !== TrackingCategory.TARGETING); |
import { KB } from '../constants'; | ||
const isMaxKBSize = (str: string, max: number) => { | ||
return Buffer.from(str).length / KB > max; | ||
// length value contains the length of the string in UTF-16 code units. | ||
// each code unit is 2 bytes wide | ||
return (str.length * 2) / KB > max; | ||
}; | ||
export default isMaxKBSize; |
138174
2853