@emplugins/emprivacy 1.0.0 → 2.1.0
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/README.md +119 -63
- package/dist/index.d.mts +257 -6
- package/dist/index.mjs +2335 -12
- package/docs/DEVELOPMENT.md +6 -10
- package/docs/GETTING_STARTED.md +83 -75
- package/docs/PLUGIN_SETTINGS.md +121 -117
- package/docs/RELEASE_NOTES.md +10 -12
- package/docs/TESTING.md +25 -27
- package/package.json +16 -14
- package/src/astro/GatedEmbed.astro +70 -0
- package/src/astro/embed-resolve.ts +227 -0
- package/src/astro/index.ts +24 -0
- package/dist/config-BJ1LHuri.mjs +0 -166
- package/dist/config-CqOtRoQR.d.mts +0 -63
- package/dist/sandbox-entry.d.mts +0 -283
- package/dist/sandbox-entry.mjs +0 -693
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
//#region src/config.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* EmPrivacy KV document (`consent:config`) and shared helpers.
|
|
4
|
-
*/
|
|
5
|
-
declare const KV_KEY: "consent:config";
|
|
6
|
-
declare const COOKIE_NAME: "emprivacy_cc";
|
|
7
|
-
/** How analytics scripts are chosen after the user consents to analytics. */
|
|
8
|
-
type AnalyticsProvider = "cloudflare" | "none" | "custom";
|
|
9
|
-
interface EmprivacyConfig {
|
|
10
|
-
bannerTitle: string;
|
|
11
|
-
bannerMessage: string;
|
|
12
|
-
/**
|
|
13
|
-
* Privacy policy location: full `https://…` URL **or** a root-relative path to an EmDash **Page**
|
|
14
|
-
* (e.g. `/privacy`) resolved with `ctx.url()` on the server.
|
|
15
|
-
*/
|
|
16
|
-
privacyPolicyUrl: string;
|
|
17
|
-
/** Optional cookie policy: same rules as `privacyPolicyUrl` (https URL or path like `/cookies`) */
|
|
18
|
-
cookiePolicyUrl: string;
|
|
19
|
-
/** When true, analytics/marketing require explicit opt-in in the UI */
|
|
20
|
-
strictDefaults: boolean;
|
|
21
|
-
/** Bump to invalidate client consent cookies and re-show the banner */
|
|
22
|
-
policyVersion: string;
|
|
23
|
-
/**
|
|
24
|
-
* Analytics when `cloudflare` — **site token** from Cloudflare → Web Analytics (injected with `data-cf-beacon`).
|
|
25
|
-
* Public in the same way as a normal site embed. Empty means no Cloudflare script until a token is saved.
|
|
26
|
-
*/
|
|
27
|
-
cloudflareWebAnalyticsToken: string;
|
|
28
|
-
/**
|
|
29
|
-
* Which analytics load path to use after consent. `cloudflare` = beacon + `cloudflareWebAnalyticsToken`;
|
|
30
|
-
* `custom` = `analyticsScriptUrls` only; `none` = no third-party analytics scripts.
|
|
31
|
-
*/
|
|
32
|
-
analyticsProvider: AnalyticsProvider;
|
|
33
|
-
/** When `analyticsProvider` is `custom`, these https script URLs load after analytics consent. */
|
|
34
|
-
analyticsScriptUrls: string[];
|
|
35
|
-
/** Third-party script URLs loaded only after marketing consent (https only) */
|
|
36
|
-
marketingScriptUrls: string[];
|
|
37
|
-
/** Emit Google Consent Mode v2 defaults (denied) in head; updates after choice */
|
|
38
|
-
googleConsentMode: boolean;
|
|
39
|
-
/** POST consent snapshots to the plugin record route and optional storage */
|
|
40
|
-
logConsentToServer: boolean;
|
|
41
|
-
}
|
|
42
|
-
declare const DEFAULT_CONFIG: EmprivacyConfig;
|
|
43
|
-
/** Reject characters that would break JSON or attributes; allow typical Cloudflare site token strings. */
|
|
44
|
-
declare function assertValidCloudflareToken(t: string): void;
|
|
45
|
-
/**
|
|
46
|
-
* Root-relative public path (EmDash page route), e.g. `/privacy`.
|
|
47
|
-
* Rejects protocol-relative URLs (`//…`) and whitespace.
|
|
48
|
-
*/
|
|
49
|
-
declare function isRootRelativeSitePath(s: string): boolean;
|
|
50
|
-
/** For hooks: turn stored path or absolute URL into a public absolute URL. */
|
|
51
|
-
declare function resolvePolicyHref(stored: string, ctx: {
|
|
52
|
-
url: (path: string) => string;
|
|
53
|
-
}): string;
|
|
54
|
-
declare function isValidPolicyHrefInput(s: string): boolean;
|
|
55
|
-
declare function normalizeConfig(raw: unknown): EmprivacyConfig;
|
|
56
|
-
interface ConsentRecordPayload {
|
|
57
|
-
createdAt: string;
|
|
58
|
-
policyVersion: string;
|
|
59
|
-
analytics: boolean;
|
|
60
|
-
marketing: boolean;
|
|
61
|
-
}
|
|
62
|
-
//#endregion
|
|
63
|
-
export { EmprivacyConfig as a, isRootRelativeSitePath as c, resolvePolicyHref as d, DEFAULT_CONFIG as i, isValidPolicyHrefInput as l, COOKIE_NAME as n, KV_KEY as o, ConsentRecordPayload as r, assertValidCloudflareToken as s, AnalyticsProvider as t, normalizeConfig as u };
|
package/dist/sandbox-entry.d.mts
DELETED
|
@@ -1,283 +0,0 @@
|
|
|
1
|
-
import { t as AnalyticsProvider } from "./config-CqOtRoQR.mjs";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
import * as emdash from "emdash";
|
|
4
|
-
import { PageFragmentContribution, PageMetadataContribution } from "emdash";
|
|
5
|
-
import * as emdash_plugin0 from "emdash/plugin";
|
|
6
|
-
import { PluginContext } from "emdash/plugin";
|
|
7
|
-
|
|
8
|
-
//#region src/sandbox-entry.d.ts
|
|
9
|
-
declare const _default: {
|
|
10
|
-
hooks: {
|
|
11
|
-
"plugin:install": (_e: emdash_plugin0.LifecycleEvent, ctx: PluginContext<emdash.PluginStorageConfig>) => Promise<void>;
|
|
12
|
-
"page:metadata": {
|
|
13
|
-
handler: (_e: emdash.PageMetadataEvent, ctx: PluginContext<emdash.PluginStorageConfig>) => Promise<PageMetadataContribution[] | null>;
|
|
14
|
-
};
|
|
15
|
-
"page:fragments": {
|
|
16
|
-
handler: (_e: emdash.PageFragmentEvent, ctx: PluginContext<emdash.PluginStorageConfig>) => Promise<PageFragmentContribution[]>;
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
routes: {
|
|
20
|
-
admin: {
|
|
21
|
-
handler: (routeCtx: emdash_plugin0.SandboxedRouteContext, ctx: PluginContext<emdash.PluginStorageConfig>) => Promise<{
|
|
22
|
-
blocks: ({
|
|
23
|
-
type: "header";
|
|
24
|
-
text: string;
|
|
25
|
-
blockId?: undefined;
|
|
26
|
-
fields?: undefined;
|
|
27
|
-
submit?: undefined;
|
|
28
|
-
} | {
|
|
29
|
-
type: "context";
|
|
30
|
-
text: string;
|
|
31
|
-
blockId?: undefined;
|
|
32
|
-
fields?: undefined;
|
|
33
|
-
submit?: undefined;
|
|
34
|
-
} | {
|
|
35
|
-
type: "divider";
|
|
36
|
-
text?: undefined;
|
|
37
|
-
blockId?: undefined;
|
|
38
|
-
fields?: undefined;
|
|
39
|
-
submit?: undefined;
|
|
40
|
-
} | {
|
|
41
|
-
type: "form";
|
|
42
|
-
blockId: string;
|
|
43
|
-
fields: ({
|
|
44
|
-
type: "text_input";
|
|
45
|
-
action_id: string;
|
|
46
|
-
label: string;
|
|
47
|
-
initial_value: string;
|
|
48
|
-
multiline?: undefined;
|
|
49
|
-
placeholder?: undefined;
|
|
50
|
-
options?: undefined;
|
|
51
|
-
condition?: undefined;
|
|
52
|
-
} | {
|
|
53
|
-
type: "text_input";
|
|
54
|
-
action_id: string;
|
|
55
|
-
label: string;
|
|
56
|
-
multiline: boolean;
|
|
57
|
-
initial_value: string;
|
|
58
|
-
placeholder?: undefined;
|
|
59
|
-
options?: undefined;
|
|
60
|
-
condition?: undefined;
|
|
61
|
-
} | {
|
|
62
|
-
type: "text_input";
|
|
63
|
-
action_id: string;
|
|
64
|
-
label: string;
|
|
65
|
-
placeholder: string;
|
|
66
|
-
initial_value: string;
|
|
67
|
-
multiline?: undefined;
|
|
68
|
-
options?: undefined;
|
|
69
|
-
condition?: undefined;
|
|
70
|
-
} | {
|
|
71
|
-
type: "toggle";
|
|
72
|
-
action_id: string;
|
|
73
|
-
label: string;
|
|
74
|
-
initial_value: boolean;
|
|
75
|
-
multiline?: undefined;
|
|
76
|
-
placeholder?: undefined;
|
|
77
|
-
options?: undefined;
|
|
78
|
-
condition?: undefined;
|
|
79
|
-
} | {
|
|
80
|
-
type: "radio";
|
|
81
|
-
action_id: string;
|
|
82
|
-
label: string;
|
|
83
|
-
options: {
|
|
84
|
-
value: string;
|
|
85
|
-
label: string;
|
|
86
|
-
}[];
|
|
87
|
-
initial_value: AnalyticsProvider;
|
|
88
|
-
multiline?: undefined;
|
|
89
|
-
placeholder?: undefined;
|
|
90
|
-
condition?: undefined;
|
|
91
|
-
} | {
|
|
92
|
-
type: "text_input";
|
|
93
|
-
action_id: string;
|
|
94
|
-
label: string;
|
|
95
|
-
placeholder: string;
|
|
96
|
-
initial_value: string;
|
|
97
|
-
condition: {
|
|
98
|
-
field: string;
|
|
99
|
-
eq: string;
|
|
100
|
-
};
|
|
101
|
-
multiline?: undefined;
|
|
102
|
-
options?: undefined;
|
|
103
|
-
} | {
|
|
104
|
-
type: "text_input";
|
|
105
|
-
action_id: string;
|
|
106
|
-
label: string;
|
|
107
|
-
placeholder: string;
|
|
108
|
-
multiline: boolean;
|
|
109
|
-
initial_value: string;
|
|
110
|
-
condition: {
|
|
111
|
-
field: string;
|
|
112
|
-
eq: string;
|
|
113
|
-
};
|
|
114
|
-
options?: undefined;
|
|
115
|
-
} | {
|
|
116
|
-
type: "text_input";
|
|
117
|
-
action_id: string;
|
|
118
|
-
label: string;
|
|
119
|
-
placeholder: string;
|
|
120
|
-
multiline: boolean;
|
|
121
|
-
initial_value: string;
|
|
122
|
-
options?: undefined;
|
|
123
|
-
condition?: undefined;
|
|
124
|
-
})[];
|
|
125
|
-
submit: {
|
|
126
|
-
label: string;
|
|
127
|
-
action_id: string;
|
|
128
|
-
};
|
|
129
|
-
text?: undefined;
|
|
130
|
-
} | {
|
|
131
|
-
type: "fields";
|
|
132
|
-
fields: {
|
|
133
|
-
label: string;
|
|
134
|
-
value: string;
|
|
135
|
-
}[];
|
|
136
|
-
text?: undefined;
|
|
137
|
-
blockId?: undefined;
|
|
138
|
-
submit?: undefined;
|
|
139
|
-
})[];
|
|
140
|
-
} | {
|
|
141
|
-
toast: {
|
|
142
|
-
message: string;
|
|
143
|
-
type: string;
|
|
144
|
-
};
|
|
145
|
-
blocks: ({
|
|
146
|
-
type: "header";
|
|
147
|
-
text: string;
|
|
148
|
-
blockId?: undefined;
|
|
149
|
-
fields?: undefined;
|
|
150
|
-
submit?: undefined;
|
|
151
|
-
} | {
|
|
152
|
-
type: "context";
|
|
153
|
-
text: string;
|
|
154
|
-
blockId?: undefined;
|
|
155
|
-
fields?: undefined;
|
|
156
|
-
submit?: undefined;
|
|
157
|
-
} | {
|
|
158
|
-
type: "divider";
|
|
159
|
-
text?: undefined;
|
|
160
|
-
blockId?: undefined;
|
|
161
|
-
fields?: undefined;
|
|
162
|
-
submit?: undefined;
|
|
163
|
-
} | {
|
|
164
|
-
type: "form";
|
|
165
|
-
blockId: string;
|
|
166
|
-
fields: ({
|
|
167
|
-
type: "text_input";
|
|
168
|
-
action_id: string;
|
|
169
|
-
label: string;
|
|
170
|
-
initial_value: string;
|
|
171
|
-
multiline?: undefined;
|
|
172
|
-
placeholder?: undefined;
|
|
173
|
-
options?: undefined;
|
|
174
|
-
condition?: undefined;
|
|
175
|
-
} | {
|
|
176
|
-
type: "text_input";
|
|
177
|
-
action_id: string;
|
|
178
|
-
label: string;
|
|
179
|
-
multiline: boolean;
|
|
180
|
-
initial_value: string;
|
|
181
|
-
placeholder?: undefined;
|
|
182
|
-
options?: undefined;
|
|
183
|
-
condition?: undefined;
|
|
184
|
-
} | {
|
|
185
|
-
type: "text_input";
|
|
186
|
-
action_id: string;
|
|
187
|
-
label: string;
|
|
188
|
-
placeholder: string;
|
|
189
|
-
initial_value: string;
|
|
190
|
-
multiline?: undefined;
|
|
191
|
-
options?: undefined;
|
|
192
|
-
condition?: undefined;
|
|
193
|
-
} | {
|
|
194
|
-
type: "toggle";
|
|
195
|
-
action_id: string;
|
|
196
|
-
label: string;
|
|
197
|
-
initial_value: boolean;
|
|
198
|
-
multiline?: undefined;
|
|
199
|
-
placeholder?: undefined;
|
|
200
|
-
options?: undefined;
|
|
201
|
-
condition?: undefined;
|
|
202
|
-
} | {
|
|
203
|
-
type: "radio";
|
|
204
|
-
action_id: string;
|
|
205
|
-
label: string;
|
|
206
|
-
options: {
|
|
207
|
-
value: string;
|
|
208
|
-
label: string;
|
|
209
|
-
}[];
|
|
210
|
-
initial_value: AnalyticsProvider;
|
|
211
|
-
multiline?: undefined;
|
|
212
|
-
placeholder?: undefined;
|
|
213
|
-
condition?: undefined;
|
|
214
|
-
} | {
|
|
215
|
-
type: "text_input";
|
|
216
|
-
action_id: string;
|
|
217
|
-
label: string;
|
|
218
|
-
placeholder: string;
|
|
219
|
-
initial_value: string;
|
|
220
|
-
condition: {
|
|
221
|
-
field: string;
|
|
222
|
-
eq: string;
|
|
223
|
-
};
|
|
224
|
-
multiline?: undefined;
|
|
225
|
-
options?: undefined;
|
|
226
|
-
} | {
|
|
227
|
-
type: "text_input";
|
|
228
|
-
action_id: string;
|
|
229
|
-
label: string;
|
|
230
|
-
placeholder: string;
|
|
231
|
-
multiline: boolean;
|
|
232
|
-
initial_value: string;
|
|
233
|
-
condition: {
|
|
234
|
-
field: string;
|
|
235
|
-
eq: string;
|
|
236
|
-
};
|
|
237
|
-
options?: undefined;
|
|
238
|
-
} | {
|
|
239
|
-
type: "text_input";
|
|
240
|
-
action_id: string;
|
|
241
|
-
label: string;
|
|
242
|
-
placeholder: string;
|
|
243
|
-
multiline: boolean;
|
|
244
|
-
initial_value: string;
|
|
245
|
-
options?: undefined;
|
|
246
|
-
condition?: undefined;
|
|
247
|
-
})[];
|
|
248
|
-
submit: {
|
|
249
|
-
label: string;
|
|
250
|
-
action_id: string;
|
|
251
|
-
};
|
|
252
|
-
text?: undefined;
|
|
253
|
-
} | {
|
|
254
|
-
type: "fields";
|
|
255
|
-
fields: {
|
|
256
|
-
label: string;
|
|
257
|
-
value: string;
|
|
258
|
-
}[];
|
|
259
|
-
text?: undefined;
|
|
260
|
-
blockId?: undefined;
|
|
261
|
-
submit?: undefined;
|
|
262
|
-
})[];
|
|
263
|
-
}>;
|
|
264
|
-
};
|
|
265
|
-
record: {
|
|
266
|
-
public: true;
|
|
267
|
-
input: z.ZodObject<{
|
|
268
|
-
policyVersion: z.ZodString;
|
|
269
|
-
analytics: z.ZodBoolean;
|
|
270
|
-
marketing: z.ZodBoolean;
|
|
271
|
-
}, z.core.$strip>;
|
|
272
|
-
handler: (routeCtx: emdash_plugin0.SandboxedRouteContext, ctx: PluginContext<emdash.PluginStorageConfig>) => Promise<Response | {
|
|
273
|
-
ok: boolean;
|
|
274
|
-
reason?: undefined;
|
|
275
|
-
} | {
|
|
276
|
-
ok: boolean;
|
|
277
|
-
reason: string;
|
|
278
|
-
}>;
|
|
279
|
-
};
|
|
280
|
-
};
|
|
281
|
-
};
|
|
282
|
-
//#endregion
|
|
283
|
-
export { _default as default };
|