{"_id":"@convective/gdpr-consent","_rev":"4-51f58e58bf33f85b4b0d6f89b17a3674","name":"@convective/gdpr-consent","dist-tags":{"latest":"1.2.1"},"versions":{"1.1.0":{"name":"@convective/gdpr-consent","version":"1.1.0","keywords":["gdpr","cookie-consent","nextjs","react","privacy","analytics","cloudfront","aws-amplify"],"author":{"name":"Convective Inc."},"license":"MIT","_id":"@convective/gdpr-consent@1.1.0","maintainers":[{"name":"convective","email":"joe.bernard@convective.com"}],"homepage":"https://github.com/convective/gdpr-consent#readme","bugs":{"url":"https://github.com/convective/gdpr-consent/issues"},"dist":{"shasum":"4c156abdb58bc6b3ccb23c3b9aa065c76cac6c08","tarball":"https://registry.npmjs.org/@convective/gdpr-consent/-/gdpr-consent-1.1.0.tgz","fileCount":8,"integrity":"sha512-1aO3ia+Mvqxp8zt8Zlw5UVGyfqE1Q5M3hklSaja1MpLN9toPx8HSBfFK9kD6e16QRChYPdJ3qNt9cHHxgFSo+Q==","signatures":[{"sig":"MEQCIB+Y9O4vzLr52pJsJPE7ZsCrkEAxlc7ZcSN7L0fOoYqgAiAM+GyfBP+05Kl9PYR7UlWiZY9YoW01yFCbA4rHAtkHLA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":57250},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"},"./styles.css":"./dist/styles.css"},"gitHead":"53344f09239e52ba0cc8616131df46ab9fee715b","private":false,"scripts":{"dev":"tsup --watch","lint":"eslint src/","build":"tsup","typecheck":"tsc --noEmit","prepublishOnly":"npm run build"},"_npmUser":{"name":"convective","email":"joe.bernard@convective.com"},"repository":{"url":"git+https://github.com/convective/gdpr-consent.git","type":"git"},"_npmVersion":"11.4.2","description":"GDPR-compliant geo-targeted cookie consent for Next.js applications","directories":{},"_nodeVersion":"24.3.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","typescript":"^5.0.0","@types/node":"^20.0.0","@types/react":"^18.0.0","@types/react-dom":"^18.0.0"},"peerDependencies":{"next":">=14.0.0","react":">=18.0.0","react-dom":">=18.0.0"},"_npmOperationalInternal":{"tmp":"tmp/gdpr-consent_1.1.0_1764462469953_0.37405111149916137","host":"s3://npm-registry-packages-npm-production"}},"1.2.0":{"name":"@convective/gdpr-consent","version":"1.2.0","keywords":["gdpr","cookie-consent","nextjs","react","privacy","analytics","cloudfront","aws-amplify"],"author":{"name":"Convective Inc."},"license":"MIT","_id":"@convective/gdpr-consent@1.2.0","maintainers":[{"name":"convective","email":"joe.bernard@convective.com"}],"homepage":"https://github.com/convective/gdpr-consent#readme","bugs":{"url":"https://github.com/convective/gdpr-consent/issues"},"dist":{"shasum":"1ad49430a6846dfe7225d0f56d890bfd024bf7fc","tarball":"https://registry.npmjs.org/@convective/gdpr-consent/-/gdpr-consent-1.2.0.tgz","fileCount":8,"integrity":"sha512-wO3Qah1FD8wnHDQiz6AFqwYLc1JmbTrFmkyxevxFMKzQh3z+cw6kfzIT6cH5TGMXLZ0YcrZL9WG5MDZnW2F8sQ==","signatures":[{"sig":"MEUCIQDovV72jUTN+mluUAgVdwWNcLzRZkTDL/+GQ2aegwRo7wIgSYpRCi8UMThYFsWoZdnCRGmbOpt62IUQdok+XnM831E=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":65057},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"},"./styles.css":"./dist/styles.css"},"gitHead":"59bcf94cbdc5dba3879b84d21d4670bf38662e3d","private":false,"scripts":{"dev":"tsup --watch","lint":"eslint src/","build":"tsup","typecheck":"tsc --noEmit","prepublishOnly":"npm run build"},"_npmUser":{"name":"convective","email":"joe.bernard@convective.com"},"repository":{"url":"git+https://github.com/convective/gdpr-consent.git","type":"git"},"_npmVersion":"10.8.2","description":"GDPR-compliant geo-targeted cookie consent for Next.js applications","directories":{},"_nodeVersion":"20.19.6","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","typescript":"^5.0.0","@types/node":"^20.0.0","@types/react":"^18.0.0","@types/react-dom":"^18.0.0"},"peerDependencies":{"next":">=14.0.0","react":">=18.0.0","react-dom":">=18.0.0"},"_npmOperationalInternal":{"tmp":"tmp/gdpr-consent_1.2.0_1765070893090_0.07947292270504502","host":"s3://npm-registry-packages-npm-production"}},"1.2.1":{"name":"@convective/gdpr-consent","version":"1.2.1","keywords":["gdpr","cookie-consent","nextjs","react","privacy","analytics","cloudfront","aws-amplify"],"author":{"name":"Convective Inc."},"license":"MIT","_id":"@convective/gdpr-consent@1.2.1","maintainers":[{"name":"convective","email":"joe.bernard@convective.com"}],"homepage":"https://github.com/convective/gdpr-consent#readme","bugs":{"url":"https://github.com/convective/gdpr-consent/issues"},"dist":{"shasum":"3bd26a63112399a86595a74aeef181664208ee7d","tarball":"https://registry.npmjs.org/@convective/gdpr-consent/-/gdpr-consent-1.2.1.tgz","fileCount":8,"integrity":"sha512-Z7jXFKR8SmyUGvRCv1X29bZpqxHGFcebeA8p+hEAtbofSgC8DD6hD6AZvIY/ukxa57R3/RpclnkMf7SkpTaAiA==","signatures":[{"sig":"MEQCIAvI/FFb9WNHXMCTgQPLjBByt59RtfjZINRtwYp/aFK+AiBWzsWWNhtBNqkTmtyKifUm3jbYrgp2q1QTwUpqtSBRtQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@convective%2fgdpr-consent@1.2.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":65057},"main":"dist/index.js","types":"dist/index.d.ts","module":"dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"},"./styles.css":"./dist/styles.css"},"gitHead":"d359524c0fea882453cdfe9e443cead62652a80e","private":false,"scripts":{"dev":"tsup --watch","lint":"eslint src/","build":"tsup","typecheck":"tsc --noEmit","prepublishOnly":"npm run build"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:b5a3eb13-7f08-4592-8bff-ed93f5f7311c"}},"repository":{"url":"git+https://github.com/convective/gdpr-consent.git","type":"git"},"_npmVersion":"11.7.0","description":"GDPR-compliant geo-targeted cookie consent for Next.js applications","directories":{},"_nodeVersion":"22.21.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","typescript":"^5.0.0","@types/node":"^20.0.0","@types/react":"^18.0.0","@types/react-dom":"^18.0.0"},"peerDependencies":{"next":">=14.0.0","react":">=18.0.0","react-dom":">=18.0.0"},"_npmOperationalInternal":{"tmp":"tmp/gdpr-consent_1.2.1_1766607742597_0.38582534501736765","host":"s3://npm-registry-packages-npm-production"}}},"time":{"created":"2025-11-30T00:27:49.692Z","modified":"2025-12-24T20:30:49.847Z","1.1.0":"2025-11-30T00:27:50.176Z","1.2.0":"2025-12-07T01:28:13.240Z","1.2.1":"2025-12-24T20:22:22.743Z"},"bugs":{"url":"https://github.com/convective/gdpr-consent/issues"},"author":{"name":"Convective Inc."},"license":"MIT","homepage":"https://github.com/convective/gdpr-consent#readme","keywords":["gdpr","cookie-consent","nextjs","react","privacy","analytics","cloudfront","aws-amplify"],"repository":{"url":"git+https://github.com/convective/gdpr-consent.git","type":"git"},"description":"GDPR-compliant geo-targeted cookie consent for Next.js applications","maintainers":[{"email":"joe.bernard@convective.com","name":"joebernard"}],"readme":"# @convective/gdpr-consent\n\nGDPR-compliant geo-targeted cookie consent for Next.js applications.\n\n[![npm version](https://img.shields.io/npm/v/@convective/gdpr-consent.svg)](https://www.npmjs.com/package/@convective/gdpr-consent)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n## Features\n\n- Geo-targeted consent (EU/EEA users only see banner)\n- CloudFront header support (AWS Amplify, CloudFront)\n- Equal Accept/Reject buttons (GDPR 2025 compliant)\n- 12-month consent expiration with audit trail\n- Privacy-first: configurable default when location unknown\n- Fully customizable styling and text\n- TypeScript support\n\n## Installation\n\n```bash\nnpm install @convective/gdpr-consent\n```\n\n## Quick Start\n\n### 1. Wrap your app with ConsentProvider\n\n```tsx\n// app/layout.tsx\nimport { headers } from \"next/headers\";\nimport { ConsentProvider, CookieBanner } from \"@convective/gdpr-consent\";\n\nexport default async function RootLayout({ children }) {\n  const headersList = await headers();\n\n  // Support env var override for testing, fallback to CloudFront header\n  const countryCode = process.env.NEXT_PUBLIC_TEST_COUNTRY\n    || headersList.get(\"cloudfront-viewer-country\");\n\n  return (\n    <html>\n      <body>\n        <ConsentProvider\n          countryCode={countryCode}\n          config={{ defaultIsEU: process.env.NODE_ENV === \"production\" }}\n        >\n          <CookieBanner privacyPolicyUrl=\"/privacy\" />\n          {children}\n        </ConsentProvider>\n      </body>\n    </html>\n  );\n}\n```\n\n### 2. Conditionally load analytics\n\n```tsx\n\"use client\";\n\nimport Script from \"next/script\";\nimport { useConsent, shouldLoadAnalytics } from \"@convective/gdpr-consent\";\n\nexport function GoogleAnalytics() {\n  const { isEU, consentStatus, isLoading } = useConsent();\n\n  if (isLoading) return null;\n  if (!shouldLoadAnalytics(isEU, consentStatus)) return null;\n\n  return (\n    <Script src=\"https://www.googletagmanager.com/gtag/js?id=G-XXXXX\" />\n  );\n}\n```\n\n### 3. Add Cookie Preferences button (footer)\n\n```tsx\nimport { CookiePreferencesButton } from \"@convective/gdpr-consent\";\n\n// Only shows for EU users\n<CookiePreferencesButton className={styles.footerLink} />\n```\n\n## Configuration\n\n### ConsentProvider Props\n\n| Prop | Type | Required | Description |\n|------|------|----------|-------------|\n| `countryCode` | `string \\| null` | Yes | ISO 3166-1 alpha-2 country code |\n| `config` | `ConsentConfig` | No | Configuration options |\n\n### ConsentConfig Options\n\n```tsx\n<ConsentProvider\n  countryCode={countryCode}\n  config={{\n    // List of country codes requiring consent (default: EU/EEA + UK)\n    euCountries: [\"DE\", \"FR\", \"GB\", ...],\n\n    // localStorage key (default: \"gdpr_cookie_consent\")\n    storageKey: \"my_cookie_consent\",\n\n    // Consent expiry in months (default: 12)\n    expiryMonths: 6,\n\n    // Default EU status when country code unavailable (default: true)\n    // Set to false in development to hide banner during local testing\n    defaultIsEU: process.env.NODE_ENV === \"production\",\n  }}\n>\n```\n\n### CookieBanner Props\n\n| Prop | Type | Default |\n|------|------|---------|\n| `message` | string | \"We use cookies to analyze...\" |\n| `privacyPolicyUrl` | string | \"/privacy\" |\n| `privacyPolicyText` | string | \"Privacy Policy\" |\n| `acceptText` | string | \"Accept\" |\n| `rejectText` | string | \"Reject\" |\n| `className` | string | - |\n| `style` | CSSProperties | - |\n| `children` | render function | - |\n\n### Custom Banner Rendering\n\n```tsx\n<CookieBanner>\n  {({ onAccept, onReject, privacyUrl }) => (\n    <div className=\"my-custom-banner\">\n      <p>Custom message <a href={privacyUrl}>Privacy</a></p>\n      <button onClick={onReject}>No thanks</button>\n      <button onClick={onAccept}>OK</button>\n    </div>\n  )}\n</CookieBanner>\n```\n\n## useConsent Hook\n\n```tsx\nconst {\n  isEU,           // boolean - is user in EU/EEA\n  consentStatus,  // \"pending\" | \"accepted\" | \"rejected\"\n  isLoading,      // boolean - still loading from localStorage\n  grantConsent,   // () => void - accept cookies\n  denyConsent,    // () => void - reject cookies\n  resetConsent,   // () => void - show banner again\n} = useConsent();\n```\n\n## Geo-detection\n\nThis package reads the `cloudfront-viewer-country` header, available in:\n- AWS Amplify (since August 2024)\n- CloudFront distributions with geo headers enabled\n\n### Behavior by Environment\n\n| Environment | Country Code | defaultIsEU | Banner Shown |\n|-------------|--------------|-------------|--------------|\n| Development | Not available | `false` | No |\n| Development | `DE` (via env var) | `false` | Yes |\n| Production | `US` (CloudFront) | `true` | No |\n| Production | `DE` (CloudFront) | `true` | Yes |\n| Production | Not available | `true` | Yes (privacy-first) |\n\n## Local Development Testing\n\nTo test the EU cookie banner in local development, add to `.env.local`:\n\n```bash\n# Simulate EU location for testing\nNEXT_PUBLIC_TEST_COUNTRY=DE\n```\n\nRestart the dev server after changing. Remove or set to `US` to hide the banner.\n\n## GDPR 2025 Compliance\n\n- Prior consent required before loading analytics cookies\n- Equal prominence Accept/Reject buttons\n- Easy consent withdrawal (Cookie Preferences button)\n- Consent logging with timestamp\n- 12-month expiration (configurable)\n- No dark patterns\n\n## License\n\nMIT\n","readmeFilename":"README.md"}