@cookiemunch/next 0.0.0-stage → 0.1.1
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/CHANGELOG.md +11 -0
- package/LICENSE +21 -0
- package/README.md +31 -2
- package/dist/csp.d.ts +39 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +82 -0
- package/dist/index.js.map +1 -0
- package/dist/script.d.ts +14 -0
- package/package.json +47 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Changelog: @cookiemunch/next
|
|
2
|
+
|
|
3
|
+
Every published release, newest first. Dates are the day the version was cut.
|
|
4
|
+
|
|
5
|
+
## 0.1.1 (2026-10-30)
|
|
6
|
+
|
|
7
|
+
- Fixed: `cookieMunchCsp` keeps a manifest's `'sha256-…'` / `'sha384-…'` / `'sha512-…'` hash sources as written instead of treating them as origins.
|
|
8
|
+
|
|
9
|
+
## 0.1.0 (2026-10-24)
|
|
10
|
+
|
|
11
|
+
- Added: `<CookieMunchScript cbid culture? blockingMode? env? />`, `cookieMunchCsp({ cbid, extra? })` and `cookieMunchHeaders()` for `next.config`, and the `@cookiemunch/react` hooks re-exported.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Cookie Munch
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,32 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @cookiemunch/next
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Cookie Munch for the Next.js App Router: the tag, the Content-Security-Policy, and the React hooks.
|
|
4
|
+
|
|
5
|
+
```tsx
|
|
6
|
+
// app/layout.tsx
|
|
7
|
+
import { CookieMunchScript } from '@cookiemunch/next';
|
|
8
|
+
|
|
9
|
+
export default function RootLayout({ children }: { children: React.ReactNode }) {
|
|
10
|
+
return (
|
|
11
|
+
<html lang="en">
|
|
12
|
+
<head>
|
|
13
|
+
<CookieMunchScript cbid="your-site-id" />
|
|
14
|
+
</head>
|
|
15
|
+
<body>{children}</body>
|
|
16
|
+
</html>
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
```js
|
|
22
|
+
// next.config.mjs
|
|
23
|
+
import { cookieMunchHeaders } from '@cookiemunch/next';
|
|
24
|
+
|
|
25
|
+
export default {
|
|
26
|
+
headers: () => cookieMunchHeaders({ cbid: 'your-site-id', extra: { 'script-src': ['https://js.stripe.com'] } }),
|
|
27
|
+
};
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
`useConsent()`, `useBannerInset()`, `<ConsentGate>` and `<CookieSettingsLink>` are re-exported from
|
|
31
|
+
[`@cookiemunch/react`](https://www.npmjs.com/package/@cookiemunch/react). `useConsent()` tells "not decided
|
|
32
|
+
yet" apart from "refused". Docs: [cookiemunch.net/docs/nextjs](https://cookiemunch.net/docs/nextjs).
|
package/dist/csp.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Content-Security-Policy a Next.js site needs for Cookie Munch, from the site's own embed manifest
|
|
3
|
+
* (`GET /v1/embed?cbid=`, public): every origin the banner, the API and anything the site's config adds
|
|
4
|
+
* are served from. Merged with your own directives, `'self'` first.
|
|
5
|
+
*
|
|
6
|
+
* // next.config.mjs
|
|
7
|
+
* import { cookieMunchHeaders } from '@cookiemunch/next';
|
|
8
|
+
* export default { headers: () => cookieMunchHeaders({ cbid: 'your-site-id', extra: { 'img-src': ['https://images.example.com'] } }) };
|
|
9
|
+
*/
|
|
10
|
+
export interface CspOptions {
|
|
11
|
+
cbid: string;
|
|
12
|
+
/** Your own directives, merged in (e.g. `{ 'script-src': ['https://js.stripe.com'] }`). */
|
|
13
|
+
extra?: Record<string, string[]>;
|
|
14
|
+
/** The API origin. Default `https://api.cookiemunch.net`. */
|
|
15
|
+
apiBase?: string;
|
|
16
|
+
fetch?: typeof fetch;
|
|
17
|
+
}
|
|
18
|
+
interface Manifest {
|
|
19
|
+
surfaces?: Record<string, {
|
|
20
|
+
csp?: Record<string, unknown>;
|
|
21
|
+
requires?: Record<string, unknown>;
|
|
22
|
+
}>;
|
|
23
|
+
}
|
|
24
|
+
/** The policy as a map, directive → sources (`'self'` first); exported for tests and custom headers. */
|
|
25
|
+
export declare function mergePolicy(manifest: Manifest, extra?: Record<string, string[]>): Map<string, string[]>;
|
|
26
|
+
export declare function policyString(policy: Map<string, string[]>): string;
|
|
27
|
+
/** The `Content-Security-Policy` value for the site. Throws when the manifest cannot be read (a build should fail loudly). */
|
|
28
|
+
export declare function cookieMunchCsp(o: CspOptions): Promise<string>;
|
|
29
|
+
/** `next.config` `headers()`: the policy on every path. */
|
|
30
|
+
export declare function cookieMunchHeaders(o: CspOptions & {
|
|
31
|
+
source?: string;
|
|
32
|
+
}): Promise<Array<{
|
|
33
|
+
source: string;
|
|
34
|
+
headers: Array<{
|
|
35
|
+
key: string;
|
|
36
|
+
value: string;
|
|
37
|
+
}>;
|
|
38
|
+
}>>;
|
|
39
|
+
export {};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { CookieMunchScript, type CookieMunchScriptProps } from './script.js';
|
|
2
|
+
export { cookieMunchCsp, cookieMunchHeaders, mergePolicy, policyString, type CspOptions } from './csp.js';
|
|
3
|
+
export { ConsentProvider, type ConsentProviderProps, useConsent, useBannerInset, ConsentGate, type ConsentGateProps, CookieSettingsLink, type CookieSettingsLinkProps, isGranted, consentCookie, parseConsentCookie, CONSENT_COOKIE_NAME, } from '@cookiemunch/react';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// src/script.tsx
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
function CookieMunchScript({ cbid, culture, blockingMode = "auto", env, src = "https://cdn.cookiemunch.net" }) {
|
|
4
|
+
return /* @__PURE__ */ jsx(
|
|
5
|
+
"script",
|
|
6
|
+
{
|
|
7
|
+
id: "CookieMunch",
|
|
8
|
+
src: `${src.replace(/\/+$/, "")}/consent.js`,
|
|
9
|
+
"data-cbid": cbid,
|
|
10
|
+
"data-blockingmode": blockingMode,
|
|
11
|
+
...culture ? { "data-culture": culture } : {},
|
|
12
|
+
...env ? { "data-env": env } : {}
|
|
13
|
+
}
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// src/csp.ts
|
|
18
|
+
var ORIGIN = /^(https|wss):\/\/[^\s*'"{]+$/;
|
|
19
|
+
var KEYWORD = /^('self'|'unsafe-inline'|'unsafe-eval'|'wasm-unsafe-eval'|'unsafe-hashes'|data:|blob:|'sha(256|384|512)-[A-Za-z0-9+/_-]+={0,2}')$/;
|
|
20
|
+
var DIRECTIVE = /^[a-z-]+-src$|^form-action$/;
|
|
21
|
+
function mergePolicy(manifest, extra = {}) {
|
|
22
|
+
const by = /* @__PURE__ */ new Map();
|
|
23
|
+
const add = (d, list, keywords) => {
|
|
24
|
+
if (!DIRECTIVE.test(d) || !Array.isArray(list)) return;
|
|
25
|
+
const set = by.get(d) ?? /* @__PURE__ */ new Set();
|
|
26
|
+
by.set(d, set);
|
|
27
|
+
for (const s of list) if (typeof s === "string" && (ORIGIN.test(s) || keywords && KEYWORD.test(s))) set.add(s);
|
|
28
|
+
};
|
|
29
|
+
for (const s of Object.values(manifest.surfaces ?? {})) {
|
|
30
|
+
for (const [d, l] of Object.entries(s.csp ?? {})) add(d, l, false);
|
|
31
|
+
for (const [d, l] of Object.entries(s.requires ?? {})) add(d, l, true);
|
|
32
|
+
}
|
|
33
|
+
for (const [d, l] of Object.entries(extra)) add(d, l, true);
|
|
34
|
+
const out = /* @__PURE__ */ new Map([["default-src", ["'self'"]]]);
|
|
35
|
+
for (const [d, set] of [...by.entries()].sort(([a], [b]) => a.localeCompare(b))) {
|
|
36
|
+
const rest = [...set].filter((s) => s !== "'self'");
|
|
37
|
+
out.set(d, ["'self'", ...rest.filter((s) => !ORIGIN.test(s)).sort(), ...rest.filter((s) => ORIGIN.test(s)).sort()]);
|
|
38
|
+
}
|
|
39
|
+
return out;
|
|
40
|
+
}
|
|
41
|
+
function policyString(policy) {
|
|
42
|
+
return [...policy.entries()].map(([d, l]) => `${d} ${l.join(" ")}`).join("; ");
|
|
43
|
+
}
|
|
44
|
+
async function cookieMunchCsp(o) {
|
|
45
|
+
const base = (o.apiBase ?? "https://api.cookiemunch.net").replace(/\/+$/, "");
|
|
46
|
+
const res = await (o.fetch ?? fetch)(`${base}/v1/embed?cbid=${encodeURIComponent(o.cbid)}`, { headers: { Accept: "application/json", "User-Agent": "cookiemunch-next/0.1.0" } });
|
|
47
|
+
if (!res.ok) throw new Error(`Cookie Munch: the embed manifest for ${o.cbid} answered ${res.status}`);
|
|
48
|
+
return policyString(mergePolicy(await res.json(), o.extra));
|
|
49
|
+
}
|
|
50
|
+
async function cookieMunchHeaders(o) {
|
|
51
|
+
return [{ source: o.source ?? "/(.*)", headers: [{ key: "Content-Security-Policy", value: await cookieMunchCsp(o) }] }];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// src/index.ts
|
|
55
|
+
import {
|
|
56
|
+
ConsentProvider,
|
|
57
|
+
useConsent,
|
|
58
|
+
useBannerInset,
|
|
59
|
+
ConsentGate,
|
|
60
|
+
CookieSettingsLink,
|
|
61
|
+
isGranted,
|
|
62
|
+
consentCookie,
|
|
63
|
+
parseConsentCookie,
|
|
64
|
+
CONSENT_COOKIE_NAME
|
|
65
|
+
} from "@cookiemunch/react";
|
|
66
|
+
export {
|
|
67
|
+
CONSENT_COOKIE_NAME,
|
|
68
|
+
ConsentGate,
|
|
69
|
+
ConsentProvider,
|
|
70
|
+
CookieMunchScript,
|
|
71
|
+
CookieSettingsLink,
|
|
72
|
+
consentCookie,
|
|
73
|
+
cookieMunchCsp,
|
|
74
|
+
cookieMunchHeaders,
|
|
75
|
+
isGranted,
|
|
76
|
+
mergePolicy,
|
|
77
|
+
parseConsentCookie,
|
|
78
|
+
policyString,
|
|
79
|
+
useBannerInset,
|
|
80
|
+
useConsent
|
|
81
|
+
};
|
|
82
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/script.tsx","../src/csp.ts","../src/index.ts"],"sourcesContent":["/** The Cookie Munch tag for `app/layout.tsx`, first in `<head>`: a Server Component, nothing runs on the client. */\n\nexport interface CookieMunchScriptProps {\n /** Your site's id (`data-cbid`). */\n cbid: string;\n /** The banner's language, e.g. `de` (`data-culture`). Default: the visitor's. */\n culture?: string;\n /** `auto` (the default) blocks third-party scripts until consent; `manual` honours `data-cookieconsent` markup only. */\n blockingMode?: 'auto' | 'manual';\n /** `test` on development and preview origins: the banner shows to headless browsers and nothing reaches your log. */\n env?: 'test';\n /** The embed's origin. Default `https://cdn.cookiemunch.net`. */\n src?: string;\n}\n\nexport function CookieMunchScript({ cbid, culture, blockingMode = 'auto', env, src = 'https://cdn.cookiemunch.net' }: CookieMunchScriptProps) {\n // A plain tag, as the install snippet is: prior-blocking needs it parsed before other scripts, so no\n // next/script strategy (they all load later).\n return (\n <script\n id=\"CookieMunch\"\n src={`${src.replace(/\\/+$/, '')}/consent.js`}\n data-cbid={cbid}\n data-blockingmode={blockingMode}\n {...(culture ? { 'data-culture': culture } : {})}\n {...(env ? { 'data-env': env } : {})}\n />\n );\n}\n","/**\n * The Content-Security-Policy a Next.js site needs for Cookie Munch, from the site's own embed manifest\n * (`GET /v1/embed?cbid=`, public): every origin the banner, the API and anything the site's config adds\n * are served from. Merged with your own directives, `'self'` first.\n *\n * // next.config.mjs\n * import { cookieMunchHeaders } from '@cookiemunch/next';\n * export default { headers: () => cookieMunchHeaders({ cbid: 'your-site-id', extra: { 'img-src': ['https://images.example.com'] } }) };\n */\n\nexport interface CspOptions {\n cbid: string;\n /** Your own directives, merged in (e.g. `{ 'script-src': ['https://js.stripe.com'] }`). */\n extra?: Record<string, string[]>;\n /** The API origin. Default `https://api.cookiemunch.net`. */\n apiBase?: string;\n fetch?: typeof fetch;\n}\n\ninterface Manifest {\n surfaces?: Record<string, { csp?: Record<string, unknown>; requires?: Record<string, unknown> }>;\n}\n\nconst ORIGIN = /^(https|wss):\\/\\/[^\\s*'\"{]+$/;\n// A hash source ('sha256-…') is a keyword here: copied verbatim, never read as an origin.\nconst KEYWORD = /^('self'|'unsafe-inline'|'unsafe-eval'|'wasm-unsafe-eval'|'unsafe-hashes'|data:|blob:|'sha(256|384|512)-[A-Za-z0-9+/_-]+={0,2}')$/;\nconst DIRECTIVE = /^[a-z-]+-src$|^form-action$/;\n\n/** The policy as a map, directive → sources (`'self'` first); exported for tests and custom headers. */\nexport function mergePolicy(manifest: Manifest, extra: Record<string, string[]> = {}): Map<string, string[]> {\n const by = new Map<string, Set<string>>();\n const add = (d: string, list: unknown, keywords: boolean) => {\n if (!DIRECTIVE.test(d) || !Array.isArray(list)) return;\n const set = by.get(d) ?? new Set<string>();\n by.set(d, set);\n for (const s of list) if (typeof s === 'string' && (ORIGIN.test(s) || (keywords && KEYWORD.test(s)))) set.add(s);\n };\n for (const s of Object.values(manifest.surfaces ?? {})) {\n for (const [d, l] of Object.entries(s.csp ?? {})) add(d, l, false);\n for (const [d, l] of Object.entries(s.requires ?? {})) add(d, l, true);\n }\n for (const [d, l] of Object.entries(extra)) add(d, l, true);\n const out = new Map<string, string[]>([['default-src', [\"'self'\"]]]);\n for (const [d, set] of [...by.entries()].sort(([a], [b]) => a.localeCompare(b))) {\n const rest = [...set].filter((s) => s !== \"'self'\");\n out.set(d, [\"'self'\", ...rest.filter((s) => !ORIGIN.test(s)).sort(), ...rest.filter((s) => ORIGIN.test(s)).sort()]);\n }\n return out;\n}\n\nexport function policyString(policy: Map<string, string[]>): string {\n return [...policy.entries()].map(([d, l]) => `${d} ${l.join(' ')}`).join('; ');\n}\n\n/** The `Content-Security-Policy` value for the site. Throws when the manifest cannot be read (a build should fail loudly). */\nexport async function cookieMunchCsp(o: CspOptions): Promise<string> {\n const base = (o.apiBase ?? 'https://api.cookiemunch.net').replace(/\\/+$/, '');\n const res = await (o.fetch ?? fetch)(`${base}/v1/embed?cbid=${encodeURIComponent(o.cbid)}`, { headers: { Accept: 'application/json', 'User-Agent': 'cookiemunch-next/0.1.0' } });\n if (!res.ok) throw new Error(`Cookie Munch: the embed manifest for ${o.cbid} answered ${res.status}`);\n return policyString(mergePolicy((await res.json()) as Manifest, o.extra));\n}\n\n/** `next.config` `headers()`: the policy on every path. */\nexport async function cookieMunchHeaders(o: CspOptions & { source?: string }): Promise<Array<{ source: string; headers: Array<{ key: string; value: string }> }>> {\n return [{ source: o.source ?? '/(.*)', headers: [{ key: 'Content-Security-Policy', value: await cookieMunchCsp(o) }] }];\n}\n","// @cookiemunch/next: the tag, the CSP, and the React hooks, for the Next.js App Router.\n// No directive here: the tag and the CSP are server code; the hooks carry their own client boundary.\nexport { CookieMunchScript, type CookieMunchScriptProps } from './script.js';\nexport { cookieMunchCsp, cookieMunchHeaders, mergePolicy, policyString, type CspOptions } from './csp.js';\nexport {\n ConsentProvider,\n type ConsentProviderProps,\n useConsent,\n useBannerInset,\n ConsentGate,\n type ConsentGateProps,\n CookieSettingsLink,\n type CookieSettingsLinkProps,\n isGranted,\n consentCookie,\n parseConsentCookie,\n CONSENT_COOKIE_NAME,\n} from '@cookiemunch/react';\n"],"mappings":";AAmBI;AAJG,SAAS,kBAAkB,EAAE,MAAM,SAAS,eAAe,QAAQ,KAAK,MAAM,8BAA8B,GAA2B;AAG5I,SACE;AAAA,IAAC;AAAA;AAAA,MACC,IAAG;AAAA,MACH,KAAK,GAAG,IAAI,QAAQ,QAAQ,EAAE,CAAC;AAAA,MAC/B,aAAW;AAAA,MACX,qBAAmB;AAAA,MAClB,GAAI,UAAU,EAAE,gBAAgB,QAAQ,IAAI,CAAC;AAAA,MAC7C,GAAI,MAAM,EAAE,YAAY,IAAI,IAAI,CAAC;AAAA;AAAA,EACpC;AAEJ;;;ACLA,IAAM,SAAS;AAEf,IAAM,UAAU;AAChB,IAAM,YAAY;AAGX,SAAS,YAAY,UAAoB,QAAkC,CAAC,GAA0B;AAC3G,QAAM,KAAK,oBAAI,IAAyB;AACxC,QAAM,MAAM,CAAC,GAAW,MAAe,aAAsB;AAC3D,QAAI,CAAC,UAAU,KAAK,CAAC,KAAK,CAAC,MAAM,QAAQ,IAAI,EAAG;AAChD,UAAM,MAAM,GAAG,IAAI,CAAC,KAAK,oBAAI,IAAY;AACzC,OAAG,IAAI,GAAG,GAAG;AACb,eAAW,KAAK,KAAM,KAAI,OAAO,MAAM,aAAa,OAAO,KAAK,CAAC,KAAM,YAAY,QAAQ,KAAK,CAAC,GAAK,KAAI,IAAI,CAAC;AAAA,EACjH;AACA,aAAW,KAAK,OAAO,OAAO,SAAS,YAAY,CAAC,CAAC,GAAG;AACtD,eAAW,CAAC,GAAG,CAAC,KAAK,OAAO,QAAQ,EAAE,OAAO,CAAC,CAAC,EAAG,KAAI,GAAG,GAAG,KAAK;AACjE,eAAW,CAAC,GAAG,CAAC,KAAK,OAAO,QAAQ,EAAE,YAAY,CAAC,CAAC,EAAG,KAAI,GAAG,GAAG,IAAI;AAAA,EACvE;AACA,aAAW,CAAC,GAAG,CAAC,KAAK,OAAO,QAAQ,KAAK,EAAG,KAAI,GAAG,GAAG,IAAI;AAC1D,QAAM,MAAM,oBAAI,IAAsB,CAAC,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC;AACnE,aAAW,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,GAAG,QAAQ,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,GAAG;AAC/E,UAAM,OAAO,CAAC,GAAG,GAAG,EAAE,OAAO,CAAC,MAAM,MAAM,QAAQ;AAClD,QAAI,IAAI,GAAG,CAAC,UAAU,GAAG,KAAK,OAAO,CAAC,MAAM,CAAC,OAAO,KAAK,CAAC,CAAC,EAAE,KAAK,GAAG,GAAG,KAAK,OAAO,CAAC,MAAM,OAAO,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;AAAA,EACpH;AACA,SAAO;AACT;AAEO,SAAS,aAAa,QAAuC;AAClE,SAAO,CAAC,GAAG,OAAO,QAAQ,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,KAAK,GAAG,CAAC,EAAE,EAAE,KAAK,IAAI;AAC/E;AAGA,eAAsB,eAAe,GAAgC;AACnE,QAAM,QAAQ,EAAE,WAAW,+BAA+B,QAAQ,QAAQ,EAAE;AAC5E,QAAM,MAAM,OAAO,EAAE,SAAS,OAAO,GAAG,IAAI,kBAAkB,mBAAmB,EAAE,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,oBAAoB,cAAc,yBAAyB,EAAE,CAAC;AAC/K,MAAI,CAAC,IAAI,GAAI,OAAM,IAAI,MAAM,wCAAwC,EAAE,IAAI,aAAa,IAAI,MAAM,EAAE;AACpG,SAAO,aAAa,YAAa,MAAM,IAAI,KAAK,GAAgB,EAAE,KAAK,CAAC;AAC1E;AAGA,eAAsB,mBAAmB,GAAyH;AAChK,SAAO,CAAC,EAAE,QAAQ,EAAE,UAAU,SAAS,SAAS,CAAC,EAAE,KAAK,2BAA2B,OAAO,MAAM,eAAe,CAAC,EAAE,CAAC,EAAE,CAAC;AACxH;;;AC7DA;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":[]}
|
package/dist/script.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** The Cookie Munch tag for `app/layout.tsx`, first in `<head>`: a Server Component, nothing runs on the client. */
|
|
2
|
+
export interface CookieMunchScriptProps {
|
|
3
|
+
/** Your site's id (`data-cbid`). */
|
|
4
|
+
cbid: string;
|
|
5
|
+
/** The banner's language, e.g. `de` (`data-culture`). Default: the visitor's. */
|
|
6
|
+
culture?: string;
|
|
7
|
+
/** `auto` (the default) blocks third-party scripts until consent; `manual` honours `data-cookieconsent` markup only. */
|
|
8
|
+
blockingMode?: 'auto' | 'manual';
|
|
9
|
+
/** `test` on development and preview origins: the banner shows to headless browsers and nothing reaches your log. */
|
|
10
|
+
env?: 'test';
|
|
11
|
+
/** The embed's origin. Default `https://cdn.cookiemunch.net`. */
|
|
12
|
+
src?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function CookieMunchScript({ cbid, culture, blockingMode, env, src }: CookieMunchScriptProps): import("react").JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,6 +1,49 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cookiemunch/next",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Cookie Munch for the Next.js App Router: the tag, the Content-Security-Policy, and the React hooks",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md",
|
|
18
|
+
"CHANGELOG.md"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && tsup && tsc -p tsconfig.json --emitDeclarationOnly --declaration",
|
|
22
|
+
"test": "vitest run"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@cookiemunch/react": "^0.3.0"
|
|
26
|
+
},
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"react": ">=18"
|
|
29
|
+
},
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "git+https://github.com/Cookie-Munch/next.git"
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://cookiemunch.net/docs/nextjs",
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/Cookie-Munch/next/issues"
|
|
37
|
+
},
|
|
38
|
+
"license": "MIT",
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@types/node": "22.20.0",
|
|
41
|
+
"@types/react": "19.2.17",
|
|
42
|
+
"@types/react-dom": "19.2.3",
|
|
43
|
+
"react": "19.2.7",
|
|
44
|
+
"react-dom": "19.2.7",
|
|
45
|
+
"tsup": "8.5.1",
|
|
46
|
+
"typescript": "5.9.3",
|
|
47
|
+
"vitest": "2.1.9"
|
|
48
|
+
}
|
|
49
|
+
}
|