@graffico/legal 0.3.0 → 0.3.2

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/next.cjs ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";var m=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var y=(e,t)=>{for(var r in t)m(e,r,{get:t[r],enumerable:!0})},C=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of f(t))!d.call(e,s)&&s!==r&&m(e,s,{get:()=>t[s],enumerable:!(o=u(t,s))||o.enumerable});return e};var w=e=>C(m({},"__esModule",{value:!0}),e);var R={};y(R,{buildCspFromConfig:()=>p,buildLegalHeaders:()=>a,emitNetlifyHeaders:()=>h,mergeCsp:()=>i,serializeCsp:()=>n,withLegal:()=>g});module.exports=w(R);var k={"default-src":["'self'"],"script-src":["'self'","'unsafe-inline'"],"style-src":["'self'","'unsafe-inline'"],"img-src":["'self'","data:","blob:","https:"],"font-src":["'self'","data:"],"connect-src":["'self'"],"frame-src":["'self'"],"frame-ancestors":["'self'"],"base-uri":["'self'"],"form-action":["'self'"],"object-src":["'none'"],"upgrade-insecure-requests":[]},v={"google-analytics":{"script-src":["https://www.googletagmanager.com"],"connect-src":["https://www.google-analytics.com","https://analytics.google.com","https://region1.google-analytics.com","https://stats.g.doubleclick.net"],"img-src":["https://www.google-analytics.com"]},"google-ads":{"script-src":["https://www.googletagmanager.com"],"connect-src":["https://www.google.com","https://googleads.g.doubleclick.net"],"img-src":["https://www.google.com","https://googleads.g.doubleclick.net"],"frame-src":["https://td.doubleclick.net"]},"google-tag-manager":{"script-src":["https://www.googletagmanager.com"],"connect-src":["https://www.googletagmanager.com"]},"facebook-pixel":{"script-src":["https://connect.facebook.net"],"connect-src":["https://*.facebook.com","https://*.facebook.net"],"img-src":["https://www.facebook.com"]},"google-fonts":{"style-src":["https://fonts.googleapis.com"],"font-src":["https://fonts.gstatic.com"]},"contact-form":{"connect-src":["https://api.emailjs.com"]},youtube:{"frame-src":["https://www.youtube.com","https://www.youtube-nocookie.com"],"img-src":["https://i.ytimg.com"]},"google-maps":{"script-src":["https://maps.googleapis.com"],"frame-src":["https://www.google.com"],"img-src":["https://maps.googleapis.com","https://maps.gstatic.com"]},hotjar:{"script-src":["https://static.hotjar.com","https://script.hotjar.com"],"connect-src":["https://*.hotjar.com","https://*.hotjar.io","wss://*.hotjar.com"],"img-src":["https://static.hotjar.com"],"font-src":["https://script.hotjar.com"],"frame-src":["https://vars.hotjar.com"]},"microsoft-clarity":{"script-src":["https://www.clarity.ms"],"connect-src":["https://*.clarity.ms"]},"tiktok-pixel":{"script-src":["https://analytics.tiktok.com","https://*.tiktok.com"],"connect-src":["https://analytics.tiktok.com","https://*.tiktok.com"],"img-src":["https://analytics.tiktok.com"]},"linkedin-insight":{"script-src":["https://snap.licdn.com"],"connect-src":["https://px.ads.linkedin.com","https://snap.licdn.com"],"img-src":["https://px.ads.linkedin.com","https://*.linkedin.com"]},mailchimp:{"script-src":["https://chimpstatic.com","https://*.list-manage.com"],"connect-src":["https://*.list-manage.com"],"img-src":["https://*.list-manage.com"],"form-action":["https://*.list-manage.com"]},stripe:{"script-src":["https://js.stripe.com"],"frame-src":["https://js.stripe.com","https://hooks.stripe.com"],"connect-src":["https://api.stripe.com"]}};function b(e){let t=e.name.toLowerCase();return t.includes("contentful")?{"connect-src":["https://graphql.contentful.com","https://cdn.contentful.com","https://preview.contentful.com"],"img-src":["https://images.ctfassets.net"]}:t.includes("netlify")?{"img-src":["https://*.netlifyusercontent.com"]}:t.includes("vercel")?{"img-src":["https://*.vercel-storage.com"]}:t.includes("stripe")?{"script-src":["https://js.stripe.com"],"frame-src":["https://js.stripe.com","https://hooks.stripe.com"],"connect-src":["https://api.stripe.com"]}:{}}function i(...e){let t={};for(let r of e)if(r)for(let[o,s]of Object.entries(r)){if(!s)continue;let c=new Set([...t[o]??[],...s]);t[o]=Array.from(c)}return t}function x(e){return/[;,\r\n]/.test(e)?null:e.trim()}function n(e){return Object.entries(e).filter(([,t])=>t!==void 0).map(([t,r])=>{if(!r||r.length===0)return`${t}`;let o=r.map(x).filter(s=>s!==null&&s.length>0);return o.length>0?`${t} ${o.join(" ")}`:`${t}`}).join("; ")}function p(e,t){let r=(e.services??[]).map(s=>typeof s=="string"?s:s.id).map(s=>v[s]).filter(Boolean),o=(e.processors??[]).map(b);return i(k,...r,...o,t)}var j={camera:[],microphone:[],geolocation:[],payment:[],"interest-cohort":[],"browsing-topics":[]};function D(e){return Object.entries(e).map(([t,r])=>r.length===0?`${t}=()`:`${t}=(${r.map(o=>`"${o}"`).join(" ")})`).join(", ")}function a(e,t={}){let r=p(e,t.extraCsp),o=t.cspReportOnly?{...r,"upgrade-insecure-requests":void 0}:r,s=t.cspReportUri?i(o,{"report-uri":[t.cspReportUri]}):o,c=[];return c.push({key:t.cspReportOnly?"Content-Security-Policy-Report-Only":"Content-Security-Policy",value:n(s)}),t.skipHsts||c.push({key:"Strict-Transport-Security",value:"max-age=63072000; includeSubDomains; preload"}),c.push({key:"X-Frame-Options",value:"SAMEORIGIN"}),c.push({key:"X-Content-Type-Options",value:"nosniff"}),c.push({key:"Referrer-Policy",value:"strict-origin-when-cross-origin"}),c.push({key:"Permissions-Policy",value:D({...j,...t.permissionsPolicy??{}})}),c.push({key:"Cross-Origin-Opener-Policy",value:"same-origin"}),c}function g(e,t,r={}){let o=r.source??"/:path*",s=a(t,r),c=e.headers;return{...e,async headers(){return[...c?await c():[],{source:o,headers:s}]}}}function h(e,t={}){let r=a(e,t),o=" ",s=[];s.push("[[headers]]"),s.push(`${o}for = "${t.source??"/*"}"`),s.push(`${o}[headers.values]`);for(let c of r){let l=c.value.replace(/"/g,'\\"');s.push(`${o}${o}${c.key} = "${l}"`)}return s.join(`
2
+ `)}0&&(module.exports={buildCspFromConfig,buildLegalHeaders,emitNetlifyHeaders,mergeCsp,serializeCsp,withLegal});
@@ -0,0 +1,153 @@
1
+ /**
2
+ * Tracker o servizio terzo dichiarato in cookie/privacy policy.
3
+ */
4
+ interface LegalService {
5
+ id: string;
6
+ name: string;
7
+ category: "automatic" | "provided" | "marketing";
8
+ logo?: string;
9
+ purposes: string[];
10
+ dataCollected: string[];
11
+ }
12
+ /**
13
+ * Riferimento a un servizio: id di un preset oppure servizio inline.
14
+ */
15
+ type ServiceReference = string | LegalService;
16
+ /**
17
+ * Posizione del toggle floating per riaprire le preferenze.
18
+ */
19
+ type TogglePosition = "bottom-right" | "bottom-left" | "top-right" | "top-left";
20
+ /**
21
+ * Responsabile esterno / destinatario dei dati personali da dichiarare in policy
22
+ * ex art. 13.1.e GDPR.
23
+ */
24
+ interface Processor {
25
+ name: string;
26
+ purpose: string;
27
+ country: string;
28
+ /** Base giuridica del trasferimento extra-UE (es. "DPF", "SCC 2021/914"). */
29
+ transferBasis?: string;
30
+ privacyUrl?: string;
31
+ }
32
+ /**
33
+ * Mappa retention per categoria/finalità. Valori liberi (es. "90d", "14m", "2y").
34
+ */
35
+ interface RetentionMap {
36
+ contactForms?: string;
37
+ analytics?: string;
38
+ marketing?: string;
39
+ [key: string]: string | undefined;
40
+ }
41
+ /**
42
+ * Recapiti del DPO, renderizzati in policy solo se presenti.
43
+ */
44
+ interface DpoInfo {
45
+ name: string;
46
+ email: string;
47
+ phone?: string;
48
+ }
49
+ /**
50
+ * Configurazione del titolare e branding mostrati nelle policy.
51
+ */
52
+ interface CompanyConfig {
53
+ name: string;
54
+ domain: string;
55
+ owners: string;
56
+ addresses: string | string[];
57
+ vatNumbers: string | string[];
58
+ email: string;
59
+ services?: ServiceReference[];
60
+ togglePosition?: TogglePosition;
61
+ lastUpdated?: string;
62
+ theme?: "light" | "dark";
63
+ primaryColor?: string;
64
+ language?: "it" | "en";
65
+ /**
66
+ * Versione dichiarata delle policy. Variare questa stringa invalida i
67
+ * consensi precedenti e ripropone il banner (art. 7.1 GDPR — consenso
68
+ * "informato" rispetto alla nuova finalità).
69
+ */
70
+ policyVersion?: string;
71
+ /**
72
+ * Destinatari/responsabili esterni dichiarati nella privacy policy.
73
+ * Render automatico nella sezione "Trasferimenti e destinatari".
74
+ */
75
+ processors?: Processor[];
76
+ /**
77
+ * Retention per categoria di dato. Render automatico in policy.
78
+ */
79
+ retention?: RetentionMap;
80
+ /**
81
+ * Dati di contatto del DPO, se nominato (art. 37 GDPR).
82
+ */
83
+ dpo?: DpoInfo;
84
+ }
85
+
86
+ type CspDirective = "default-src" | "script-src" | "style-src" | "img-src" | "font-src" | "connect-src" | "frame-src" | "frame-ancestors" | "base-uri" | "form-action" | "media-src" | "object-src" | "worker-src" | "upgrade-insecure-requests" | "report-uri" | "report-to";
87
+ type CspDirectives = Partial<Record<CspDirective, string[]>>;
88
+ declare function mergeCsp(...parts: (CspDirectives | undefined)[]): CspDirectives;
89
+ declare function serializeCsp(d: CspDirectives): string;
90
+ /**
91
+ * Costruisce le direttive CSP partendo dalla config legale: i `services[]`
92
+ * dichiarati contribuiscono allowlist note (GA, Ads, Pixel, Fonts, ecc.), i
93
+ * `processors[]` aggiungono allowlist derivate dal nome (Contentful, Stripe…).
94
+ */
95
+ declare function buildCspFromConfig(config: CompanyConfig, extras?: CspDirectives): CspDirectives;
96
+
97
+ interface HeaderEntry {
98
+ key: string;
99
+ value: string;
100
+ }
101
+ interface HeaderRoute {
102
+ source: string;
103
+ headers: HeaderEntry[];
104
+ has?: unknown[];
105
+ missing?: unknown[];
106
+ locale?: false;
107
+ basePath?: false;
108
+ }
109
+ /**
110
+ * Forma minima di `NextConfig` consumata dal plugin. Niente index signature
111
+ * per restare compatibile con `NextConfig` di next (che non la dichiara).
112
+ */
113
+ interface NextConfigLike {
114
+ headers?: () => Promise<HeaderRoute[]> | HeaderRoute[];
115
+ }
116
+ interface LegalNextOptions {
117
+ /**
118
+ * Emette `Content-Security-Policy-Report-Only` invece dell'header enforce.
119
+ * Utile per rollout graduale: 7 giorni in monitor → poi enforce.
120
+ */
121
+ cspReportOnly?: boolean;
122
+ /** Endpoint a cui far recapitare le violazioni CSP (`report-uri` directive). */
123
+ cspReportUri?: string;
124
+ /** Direttive CSP da unire a quelle derivate (override puntuali). */
125
+ extraCsp?: CspDirectives;
126
+ /** Permissions-Policy custom (mappa feature → allowlist). */
127
+ permissionsPolicy?: Record<string, string[]>;
128
+ /** Disattiva l'HSTS (utile su deploy preview senza TLS forzato). */
129
+ skipHsts?: boolean;
130
+ /**
131
+ * Route a cui applicare gli header. Default `:path*` (ovunque). Se passi
132
+ * un array, vengono prodotti più blocchi `[[headers]]`.
133
+ */
134
+ source?: string;
135
+ }
136
+ /**
137
+ * Costruisce l'array di header da applicare. Esposto per riuso lato Netlify
138
+ * (`emitNetlifyHeaders`).
139
+ */
140
+ declare function buildLegalHeaders(config: CompanyConfig, options?: LegalNextOptions): HeaderEntry[];
141
+ /**
142
+ * HOF che avvolge un `nextConfig` aggiungendo gli header di sicurezza derivati
143
+ * da `legalConfig`. Preserva eventuali `headers()` già definiti dal consumer:
144
+ * il route legale viene aggiunto in coda all'array restituito dall'esistente.
145
+ */
146
+ declare function withLegal<T extends NextConfigLike>(nextConfig: T, legalConfig: CompanyConfig, options?: LegalNextOptions): T;
147
+ /**
148
+ * Genera lo snippet `[[headers]]` per `netlify.toml` allineato ai medesimi
149
+ * header del plugin. Da copiare manualmente nel file Netlify del consumer.
150
+ */
151
+ declare function emitNetlifyHeaders(config: CompanyConfig, options?: LegalNextOptions): string;
152
+
153
+ export { type CspDirective, type CspDirectives, type LegalNextOptions, type NextConfigLike, buildCspFromConfig, buildLegalHeaders, emitNetlifyHeaders, mergeCsp, serializeCsp, withLegal };
package/dist/next.d.ts CHANGED
@@ -107,12 +107,11 @@ interface HeaderRoute {
107
107
  basePath?: false;
108
108
  }
109
109
  /**
110
- * Forma minima di `NextConfig` consumata dal plugin. Evita la dipendenza
111
- * diretta dal type `NextConfig` di next.
110
+ * Forma minima di `NextConfig` consumata dal plugin. Niente index signature
111
+ * per restare compatibile con `NextConfig` di next (che non la dichiara).
112
112
  */
113
113
  interface NextConfigLike {
114
114
  headers?: () => Promise<HeaderRoute[]> | HeaderRoute[];
115
- [key: string]: unknown;
116
115
  }
117
116
  interface LegalNextOptions {
118
117
  /**
package/dist/next.js CHANGED
@@ -1,2 +1,2 @@
1
- var l={"default-src":["'self'"],"script-src":["'self'","'unsafe-inline'"],"style-src":["'self'","'unsafe-inline'"],"img-src":["'self'","data:","blob:","https:"],"font-src":["'self'","data:"],"connect-src":["'self'"],"frame-src":["'self'"],"frame-ancestors":["'self'"],"base-uri":["'self'"],"form-action":["'self'"],"object-src":["'none'"],"upgrade-insecure-requests":[]},g={"google-analytics":{"script-src":["https://www.googletagmanager.com"],"connect-src":["https://www.google-analytics.com","https://analytics.google.com","https://region1.google-analytics.com","https://stats.g.doubleclick.net"],"img-src":["https://www.google-analytics.com"]},"google-ads":{"script-src":["https://www.googletagmanager.com"],"connect-src":["https://www.google.com","https://googleads.g.doubleclick.net"],"img-src":["https://www.google.com","https://googleads.g.doubleclick.net"],"frame-src":["https://td.doubleclick.net"]},"google-tag-manager":{"script-src":["https://www.googletagmanager.com"],"connect-src":["https://www.googletagmanager.com"]},"facebook-pixel":{"script-src":["https://connect.facebook.net"],"connect-src":["https://*.facebook.com","https://*.facebook.net"],"img-src":["https://www.facebook.com"]},"google-fonts":{"style-src":["https://fonts.googleapis.com"],"font-src":["https://fonts.gstatic.com"]},"contact-form":{"connect-src":["https://api.emailjs.com"]},youtube:{"frame-src":["https://www.youtube.com","https://www.youtube-nocookie.com"],"img-src":["https://i.ytimg.com"]},"google-maps":{"script-src":["https://maps.googleapis.com"],"frame-src":["https://www.google.com"],"img-src":["https://maps.googleapis.com","https://maps.gstatic.com"]},hotjar:{"script-src":["https://static.hotjar.com","https://script.hotjar.com"],"connect-src":["https://*.hotjar.com","https://*.hotjar.io","wss://*.hotjar.com"],"img-src":["https://static.hotjar.com"],"font-src":["https://script.hotjar.com"],"frame-src":["https://vars.hotjar.com"]},"microsoft-clarity":{"script-src":["https://www.clarity.ms"],"connect-src":["https://*.clarity.ms"]},"tiktok-pixel":{"script-src":["https://analytics.tiktok.com","https://*.tiktok.com"],"connect-src":["https://analytics.tiktok.com","https://*.tiktok.com"],"img-src":["https://analytics.tiktok.com"]},"linkedin-insight":{"script-src":["https://snap.licdn.com"],"connect-src":["https://px.ads.linkedin.com","https://snap.licdn.com"],"img-src":["https://px.ads.linkedin.com","https://*.linkedin.com"]},mailchimp:{"script-src":["https://chimpstatic.com","https://*.list-manage.com"],"connect-src":["https://*.list-manage.com"],"img-src":["https://*.list-manage.com"],"form-action":["https://*.list-manage.com"]},stripe:{"script-src":["https://js.stripe.com"],"frame-src":["https://js.stripe.com","https://hooks.stripe.com"],"connect-src":["https://api.stripe.com"]}};function h(s){let t=s.name.toLowerCase();return t.includes("contentful")?{"connect-src":["https://graphql.contentful.com","https://cdn.contentful.com","https://preview.contentful.com"],"img-src":["https://images.ctfassets.net"]}:t.includes("netlify")?{"img-src":["https://*.netlifyusercontent.com"]}:t.includes("vercel")?{"img-src":["https://*.vercel-storage.com"]}:t.includes("stripe")?{"script-src":["https://js.stripe.com"],"frame-src":["https://js.stripe.com","https://hooks.stripe.com"],"connect-src":["https://api.stripe.com"]}:{}}function i(...s){let t={};for(let r of s)if(r)for(let[o,e]of Object.entries(r)){if(!e)continue;let c=new Set([...t[o]??[],...e]);t[o]=Array.from(c)}return t}function f(s){return/[;,\r\n]/.test(s)?null:s.trim()}function n(s){return Object.entries(s).filter(([,t])=>t!==void 0).map(([t,r])=>{if(!r||r.length===0)return`${t}`;let o=r.map(f).filter(e=>e!==null&&e.length>0);return o.length>0?`${t} ${o.join(" ")}`:`${t}`}).join("; ")}function p(s,t){let r=(s.services??[]).map(e=>typeof e=="string"?e:e.id).map(e=>g[e]).filter(Boolean),o=(s.processors??[]).map(h);return i(l,...r,...o,t)}var u={camera:[],microphone:[],geolocation:[],payment:[],"interest-cohort":[],"browsing-topics":[]};function d(s){return Object.entries(s).map(([t,r])=>r.length===0?`${t}=()`:`${t}=(${r.map(o=>`"${o}"`).join(" ")})`).join(", ")}function a(s,t={}){let r=p(s,t.extraCsp),o=t.cspReportUri?i(r,{"report-uri":[t.cspReportUri]}):r,e=[];return e.push({key:t.cspReportOnly?"Content-Security-Policy-Report-Only":"Content-Security-Policy",value:n(o)}),t.skipHsts||e.push({key:"Strict-Transport-Security",value:"max-age=63072000; includeSubDomains; preload"}),e.push({key:"X-Frame-Options",value:"SAMEORIGIN"}),e.push({key:"X-Content-Type-Options",value:"nosniff"}),e.push({key:"Referrer-Policy",value:"strict-origin-when-cross-origin"}),e.push({key:"Permissions-Policy",value:d({...u,...t.permissionsPolicy??{}})}),e.push({key:"Cross-Origin-Opener-Policy",value:"same-origin"}),e}function y(s,t,r={}){let o=r.source??"/:path*",e=a(t,r),c=s.headers;return{...s,async headers(){return[...c?await c():[],{source:o,headers:e}]}}}function C(s,t={}){let r=a(s,t),o=" ",e=[];e.push("[[headers]]"),e.push(`${o}for = "${t.source??"/*"}"`),e.push(`${o}[headers.values]`);for(let c of r){let m=c.value.replace(/"/g,'\\"');e.push(`${o}${o}${c.key} = "${m}"`)}return e.join(`
1
+ var l={"default-src":["'self'"],"script-src":["'self'","'unsafe-inline'"],"style-src":["'self'","'unsafe-inline'"],"img-src":["'self'","data:","blob:","https:"],"font-src":["'self'","data:"],"connect-src":["'self'"],"frame-src":["'self'"],"frame-ancestors":["'self'"],"base-uri":["'self'"],"form-action":["'self'"],"object-src":["'none'"],"upgrade-insecure-requests":[]},g={"google-analytics":{"script-src":["https://www.googletagmanager.com"],"connect-src":["https://www.google-analytics.com","https://analytics.google.com","https://region1.google-analytics.com","https://stats.g.doubleclick.net"],"img-src":["https://www.google-analytics.com"]},"google-ads":{"script-src":["https://www.googletagmanager.com"],"connect-src":["https://www.google.com","https://googleads.g.doubleclick.net"],"img-src":["https://www.google.com","https://googleads.g.doubleclick.net"],"frame-src":["https://td.doubleclick.net"]},"google-tag-manager":{"script-src":["https://www.googletagmanager.com"],"connect-src":["https://www.googletagmanager.com"]},"facebook-pixel":{"script-src":["https://connect.facebook.net"],"connect-src":["https://*.facebook.com","https://*.facebook.net"],"img-src":["https://www.facebook.com"]},"google-fonts":{"style-src":["https://fonts.googleapis.com"],"font-src":["https://fonts.gstatic.com"]},"contact-form":{"connect-src":["https://api.emailjs.com"]},youtube:{"frame-src":["https://www.youtube.com","https://www.youtube-nocookie.com"],"img-src":["https://i.ytimg.com"]},"google-maps":{"script-src":["https://maps.googleapis.com"],"frame-src":["https://www.google.com"],"img-src":["https://maps.googleapis.com","https://maps.gstatic.com"]},hotjar:{"script-src":["https://static.hotjar.com","https://script.hotjar.com"],"connect-src":["https://*.hotjar.com","https://*.hotjar.io","wss://*.hotjar.com"],"img-src":["https://static.hotjar.com"],"font-src":["https://script.hotjar.com"],"frame-src":["https://vars.hotjar.com"]},"microsoft-clarity":{"script-src":["https://www.clarity.ms"],"connect-src":["https://*.clarity.ms"]},"tiktok-pixel":{"script-src":["https://analytics.tiktok.com","https://*.tiktok.com"],"connect-src":["https://analytics.tiktok.com","https://*.tiktok.com"],"img-src":["https://analytics.tiktok.com"]},"linkedin-insight":{"script-src":["https://snap.licdn.com"],"connect-src":["https://px.ads.linkedin.com","https://snap.licdn.com"],"img-src":["https://px.ads.linkedin.com","https://*.linkedin.com"]},mailchimp:{"script-src":["https://chimpstatic.com","https://*.list-manage.com"],"connect-src":["https://*.list-manage.com"],"img-src":["https://*.list-manage.com"],"form-action":["https://*.list-manage.com"]},stripe:{"script-src":["https://js.stripe.com"],"frame-src":["https://js.stripe.com","https://hooks.stripe.com"],"connect-src":["https://api.stripe.com"]}};function h(s){let t=s.name.toLowerCase();return t.includes("contentful")?{"connect-src":["https://graphql.contentful.com","https://cdn.contentful.com","https://preview.contentful.com"],"img-src":["https://images.ctfassets.net"]}:t.includes("netlify")?{"img-src":["https://*.netlifyusercontent.com"]}:t.includes("vercel")?{"img-src":["https://*.vercel-storage.com"]}:t.includes("stripe")?{"script-src":["https://js.stripe.com"],"frame-src":["https://js.stripe.com","https://hooks.stripe.com"],"connect-src":["https://api.stripe.com"]}:{}}function i(...s){let t={};for(let r of s)if(r)for(let[o,e]of Object.entries(r)){if(!e)continue;let c=new Set([...t[o]??[],...e]);t[o]=Array.from(c)}return t}function u(s){return/[;,\r\n]/.test(s)?null:s.trim()}function n(s){return Object.entries(s).filter(([,t])=>t!==void 0).map(([t,r])=>{if(!r||r.length===0)return`${t}`;let o=r.map(u).filter(e=>e!==null&&e.length>0);return o.length>0?`${t} ${o.join(" ")}`:`${t}`}).join("; ")}function p(s,t){let r=(s.services??[]).map(e=>typeof e=="string"?e:e.id).map(e=>g[e]).filter(Boolean),o=(s.processors??[]).map(h);return i(l,...r,...o,t)}var f={camera:[],microphone:[],geolocation:[],payment:[],"interest-cohort":[],"browsing-topics":[]};function d(s){return Object.entries(s).map(([t,r])=>r.length===0?`${t}=()`:`${t}=(${r.map(o=>`"${o}"`).join(" ")})`).join(", ")}function a(s,t={}){let r=p(s,t.extraCsp),o=t.cspReportOnly?{...r,"upgrade-insecure-requests":void 0}:r,e=t.cspReportUri?i(o,{"report-uri":[t.cspReportUri]}):o,c=[];return c.push({key:t.cspReportOnly?"Content-Security-Policy-Report-Only":"Content-Security-Policy",value:n(e)}),t.skipHsts||c.push({key:"Strict-Transport-Security",value:"max-age=63072000; includeSubDomains; preload"}),c.push({key:"X-Frame-Options",value:"SAMEORIGIN"}),c.push({key:"X-Content-Type-Options",value:"nosniff"}),c.push({key:"Referrer-Policy",value:"strict-origin-when-cross-origin"}),c.push({key:"Permissions-Policy",value:d({...f,...t.permissionsPolicy??{}})}),c.push({key:"Cross-Origin-Opener-Policy",value:"same-origin"}),c}function y(s,t,r={}){let o=r.source??"/:path*",e=a(t,r),c=s.headers;return{...s,async headers(){return[...c?await c():[],{source:o,headers:e}]}}}function C(s,t={}){let r=a(s,t),o=" ",e=[];e.push("[[headers]]"),e.push(`${o}for = "${t.source??"/*"}"`),e.push(`${o}[headers.values]`);for(let c of r){let m=c.value.replace(/"/g,'\\"');e.push(`${o}${o}${c.key} = "${m}"`)}return e.join(`
2
2
  `)}export{p as buildCspFromConfig,a as buildLegalHeaders,C as emitNetlifyHeaders,i as mergeCsp,n as serializeCsp,y as withLegal};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graffico/legal",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "GDPR compliance solution for React/Next.js",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "repository": {
@@ -25,7 +25,8 @@
25
25
  },
26
26
  "./next": {
27
27
  "types": "./dist/next.d.ts",
28
- "import": "./dist/next.js"
28
+ "import": "./dist/next.js",
29
+ "require": "./dist/next.cjs"
29
30
  },
30
31
  "./style.css": "./dist/index.css"
31
32
  },