@easy-cookie/policy 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/LICENSE +21 -0
- package/README.md +182 -2
- package/dist/chunk-HDY2VYU4.js +23 -0
- package/dist/chunk-HDY2VYU4.js.map +1 -0
- package/dist/chunk-P3F5NQPR.js +224 -0
- package/dist/chunk-P3F5NQPR.js.map +1 -0
- package/dist/client.cjs +50 -0
- package/dist/client.cjs.map +1 -0
- package/dist/client.d.cts +51 -0
- package/dist/client.d.ts +51 -0
- package/dist/client.js +13 -0
- package/dist/client.js.map +1 -0
- package/dist/easy-cookie-legal.css +129 -0
- package/dist/index.cjs +1091 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +91 -0
- package/dist/index.d.ts +91 -0
- package/dist/index.js +820 -0
- package/dist/index.js.map +1 -0
- package/dist/legal-document.cjs +72 -0
- package/dist/legal-document.cjs.map +1 -0
- package/dist/legal-document.js +48 -0
- package/dist/legal-document.js.map +1 -0
- package/dist/react.cjs +219 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +49 -0
- package/dist/react.d.ts +49 -0
- package/dist/react.js +80 -0
- package/dist/react.js.map +1 -0
- package/dist/render-DYrvn1cT.d.cts +115 -0
- package/dist/render-DYrvn1cT.d.ts +115 -0
- package/package.json +75 -3
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Legal document types and the fetch client. Kept free of the Markdown
|
|
3
|
+
* renderer so browser bundles (React component, Next.js) stay small.
|
|
4
|
+
*/
|
|
5
|
+
/** The three legal documents every site has. */
|
|
6
|
+
type LegalKind = 'cookie' | 'privacy' | 'terms';
|
|
7
|
+
declare const LEGAL_KINDS: readonly LegalKind[];
|
|
8
|
+
declare const isLegalKind: (v: unknown) => v is LegalKind;
|
|
9
|
+
interface LegalTranslation {
|
|
10
|
+
title: string;
|
|
11
|
+
/** Markdown, rendered with raw HTML disabled. */
|
|
12
|
+
body: string;
|
|
13
|
+
}
|
|
14
|
+
/** Content of a legal document: one entry per language it is written in. */
|
|
15
|
+
interface LegalDocContent {
|
|
16
|
+
translations: Record<string, LegalTranslation>;
|
|
17
|
+
}
|
|
18
|
+
/** A published document as served by `GET /v1/sites/:publicKey/legal/:kind.json`. */
|
|
19
|
+
interface PublishedLegalDocument {
|
|
20
|
+
kind: LegalKind;
|
|
21
|
+
/** Language actually shown (after fallback). */
|
|
22
|
+
lang: string;
|
|
23
|
+
/** Every language the document is written in. */
|
|
24
|
+
languages: string[];
|
|
25
|
+
title: string;
|
|
26
|
+
/** Rendered, safe HTML wrapped in `<div class="ec-legal" lang="…">`. */
|
|
27
|
+
html: string;
|
|
28
|
+
version: string;
|
|
29
|
+
publishedAt: string;
|
|
30
|
+
}
|
|
31
|
+
interface FetchLegalDocumentOptions {
|
|
32
|
+
/** Base URL of the consent server. */
|
|
33
|
+
endpoint: string;
|
|
34
|
+
/** Public site key (`pk_…`). */
|
|
35
|
+
siteKey: string;
|
|
36
|
+
kind: LegalKind;
|
|
37
|
+
lang?: string;
|
|
38
|
+
/** Extra fetch options (e.g. Next's `next: { revalidate }`). */
|
|
39
|
+
init?: RequestInit & Record<string, unknown>;
|
|
40
|
+
/** Custom fetch implementation. */
|
|
41
|
+
fetch?: typeof fetch;
|
|
42
|
+
}
|
|
43
|
+
/** URL of the published document JSON on the consent server. */
|
|
44
|
+
declare function legalDocumentUrl(opts: Pick<FetchLegalDocumentOptions, 'endpoint' | 'siteKey' | 'kind' | 'lang'>): string;
|
|
45
|
+
/**
|
|
46
|
+
* Fetch a published legal document from the consent server.
|
|
47
|
+
* Resolves to null when nothing is published yet (404); throws on other errors.
|
|
48
|
+
*/
|
|
49
|
+
declare function fetchLegalDocument(opts: FetchLegalDocumentOptions): Promise<PublishedLegalDocument | null>;
|
|
50
|
+
|
|
51
|
+
export { type FetchLegalDocumentOptions, LEGAL_KINDS, type LegalDocContent, type LegalKind, type LegalTranslation, type PublishedLegalDocument, fetchLegalDocument, isLegalKind, legalDocumentUrl };
|
package/dist/client.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @easy-cookie/policy: legal documents (cookie policy, privacy policy, terms).
|
|
3
|
+
* Neutral and readable on its own; restyle it through the --ec-legal-* variables,
|
|
4
|
+
* set on :root, on .ec-legal or on any ancestor.
|
|
5
|
+
* Selectors use :where() so any site rule wins without !important.
|
|
6
|
+
*/
|
|
7
|
+
:where(.ec-legal) {
|
|
8
|
+
box-sizing: border-box;
|
|
9
|
+
max-width: var(--ec-legal-max-width, 72ch);
|
|
10
|
+
font-family: var(--ec-legal-font, system-ui, sans-serif);
|
|
11
|
+
font-size: 1rem;
|
|
12
|
+
line-height: 1.6;
|
|
13
|
+
color: var(--ec-legal-ink, #1c1c1a);
|
|
14
|
+
overflow-wrap: break-word;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
:where(.ec-legal) *,
|
|
18
|
+
:where(.ec-legal) *::before,
|
|
19
|
+
:where(.ec-legal) *::after {
|
|
20
|
+
box-sizing: inherit;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
:where(.ec-legal) :where(h1, h2, h3, h4) {
|
|
24
|
+
line-height: 1.25;
|
|
25
|
+
margin: 2em 0 0.6em;
|
|
26
|
+
font-weight: 650;
|
|
27
|
+
}
|
|
28
|
+
:where(.ec-legal) :where(h1) { font-size: 2em; margin-top: 0; }
|
|
29
|
+
:where(.ec-legal) :where(h2) { font-size: 1.4em; padding-bottom: 0.3em; border-bottom: 1px solid var(--ec-legal-line, #dcdcd6); }
|
|
30
|
+
:where(.ec-legal) :where(h3) { font-size: 1.15em; }
|
|
31
|
+
:where(.ec-legal) :where(h4) { font-size: 1em; }
|
|
32
|
+
|
|
33
|
+
:where(.ec-legal) :where(p, ul, ol, table, blockquote, .ec-policy__table-wrap) { margin: 0 0 1em; }
|
|
34
|
+
:where(.ec-legal) :where(ul, ol) { padding-left: 1.5em; }
|
|
35
|
+
:where(.ec-legal) :where(li) { margin: 0.25em 0; }
|
|
36
|
+
|
|
37
|
+
:where(.ec-legal) :where(a) {
|
|
38
|
+
color: var(--ec-legal-accent, #1a56c4);
|
|
39
|
+
text-decoration: underline;
|
|
40
|
+
text-underline-offset: 0.15em;
|
|
41
|
+
}
|
|
42
|
+
:where(.ec-legal) :where(a:focus-visible) {
|
|
43
|
+
outline: 2px solid var(--ec-legal-accent, #1a56c4);
|
|
44
|
+
outline-offset: 2px;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
:where(.ec-legal) :where(code) {
|
|
48
|
+
font-family: ui-monospace, monospace;
|
|
49
|
+
font-size: 0.9em;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
:where(.ec-legal) :where(blockquote) {
|
|
53
|
+
margin-left: 0;
|
|
54
|
+
padding-left: 1em;
|
|
55
|
+
border-left: 1px solid var(--ec-legal-line, #dcdcd6);
|
|
56
|
+
color: var(--ec-legal-muted, #5a5a55);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
:where(.ec-legal) :where(hr) {
|
|
60
|
+
border: 0;
|
|
61
|
+
border-top: 1px solid var(--ec-legal-line, #dcdcd6);
|
|
62
|
+
margin: 2em 0;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/* Tables: Markdown tables and the generated cookie tables. */
|
|
66
|
+
:where(.ec-legal) :where(.ec-policy__table-wrap) { overflow-x: auto; }
|
|
67
|
+
:where(.ec-legal) :where(table) {
|
|
68
|
+
width: 100%;
|
|
69
|
+
border-collapse: collapse;
|
|
70
|
+
font-size: 0.92em;
|
|
71
|
+
}
|
|
72
|
+
:where(.ec-legal) :where(th, td) {
|
|
73
|
+
text-align: left;
|
|
74
|
+
vertical-align: top;
|
|
75
|
+
padding: 0.5em 0.75em;
|
|
76
|
+
border-bottom: 1px solid var(--ec-legal-line, #dcdcd6);
|
|
77
|
+
}
|
|
78
|
+
:where(.ec-legal) :where(thead th) {
|
|
79
|
+
font-weight: 600;
|
|
80
|
+
border-bottom-width: 2px;
|
|
81
|
+
white-space: nowrap;
|
|
82
|
+
}
|
|
83
|
+
:where(.ec-legal) :where(tbody th) { font-weight: 400; }
|
|
84
|
+
|
|
85
|
+
/* Generated cookie policy (`{{cookie-table}}`). */
|
|
86
|
+
:where(.ec-legal) :where(.ec-policy__category) { margin: 0 0 1.75em; }
|
|
87
|
+
:where(.ec-legal) :where(.ec-policy__caption) {
|
|
88
|
+
caption-side: top;
|
|
89
|
+
text-align: left;
|
|
90
|
+
font-size: 0.85em;
|
|
91
|
+
color: var(--ec-legal-muted, #5a5a55);
|
|
92
|
+
padding-bottom: 0.4em;
|
|
93
|
+
}
|
|
94
|
+
:where(.ec-legal) :where(.ec-policy__badge) {
|
|
95
|
+
display: inline-block;
|
|
96
|
+
font-size: 0.8em;
|
|
97
|
+
padding: 0.1em 0.6em;
|
|
98
|
+
border: 1px solid var(--ec-legal-line, #dcdcd6);
|
|
99
|
+
border-radius: 999px;
|
|
100
|
+
color: var(--ec-legal-muted, #5a5a55);
|
|
101
|
+
}
|
|
102
|
+
:where(.ec-legal) :where(.ec-policy__domain, .ec-policy__none, .ec-policy__empty) { color: var(--ec-legal-muted, #5a5a55); }
|
|
103
|
+
|
|
104
|
+
/* Services list (`{{services-list}}`). */
|
|
105
|
+
:where(.ec-legal) :where(.ec-legal__services) { list-style: none; padding: 0; }
|
|
106
|
+
:where(.ec-legal) :where(.ec-legal__service) {
|
|
107
|
+
margin: 0;
|
|
108
|
+
padding: 0.75em 0;
|
|
109
|
+
border-bottom: 1px solid var(--ec-legal-line, #dcdcd6);
|
|
110
|
+
}
|
|
111
|
+
:where(.ec-legal) :where(.ec-legal__service p) { margin: 0.15em 0; }
|
|
112
|
+
:where(.ec-legal) :where(.ec-legal__service-meta) { font-size: 0.9em; color: var(--ec-legal-muted, #5a5a55); }
|
|
113
|
+
|
|
114
|
+
:where(.ec-legal) :where(.ec-legal__updated, .ec-legal__notice, .ec-legal__empty) { color: var(--ec-legal-muted, #5a5a55); }
|
|
115
|
+
|
|
116
|
+
/* `[[placeholders]]` the owner still has to fill in. */
|
|
117
|
+
:where(.ec-legal) :where(.ec-legal__todo) {
|
|
118
|
+
background: var(--ec-legal-todo, #fff2a8);
|
|
119
|
+
color: inherit;
|
|
120
|
+
padding: 0.05em 0.25em;
|
|
121
|
+
border-radius: 3px;
|
|
122
|
+
box-decoration-break: clone;
|
|
123
|
+
-webkit-box-decoration-break: clone;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
@media print {
|
|
127
|
+
:where(.ec-legal) { max-width: none; }
|
|
128
|
+
:where(.ec-legal) :where(a) { color: inherit; }
|
|
129
|
+
}
|