@dealsystem/site 0.0.0-stage → 0.2.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 +145 -2
- package/agent-files/claude/skills/angebote-einbauen/SKILL.md +30 -0
- package/agent-files/claude/skills/bild-einbauen/SKILL.md +43 -0
- package/agent-files/claude/skills/domain-verbinden/SKILL.md +23 -0
- package/agent-files/claude/skills/extern-einbinden/SKILL.md +37 -0
- package/agent-files/claude/skills/formular-anbinden/SKILL.md +34 -0
- package/agent-files/claude/skills/funnel-mehrstufig/BewertungFunnel.svelte +220 -0
- package/agent-files/claude/skills/funnel-mehrstufig/SKILL.md +101 -0
- package/agent-files/claude/skills/neue-seite/SKILL.md +47 -0
- package/agent-files/claude/skills/prueffehler-beheben/SKILL.md +31 -0
- package/agent-files/claude/skills/termin-buchung/SKILL.md +51 -0
- package/agent-files/claude/skills/veroeffentlichen/SKILL.md +32 -0
- package/agent-files/cursor/rules/dealsystem.mdc +7 -0
- package/agent-files/manifest.json +93 -0
- package/contract/README.md +41 -0
- package/contract/ds-content.v1.json +2355 -0
- package/contract/external-presets.v1.json +65 -0
- package/contract/funnel-code-config.md +87 -0
- package/contract/site-api.v1.json +3916 -0
- package/dist/client/altcha-workers.d.ts +10 -0
- package/dist/client/attribution.d.ts +119 -0
- package/dist/client/attribution.js +341 -0
- package/dist/client/bookingClient.svelte.d.ts +166 -0
- package/dist/client/bookingClient.svelte.js +369 -0
- package/dist/client/bookingTime.d.ts +46 -0
- package/dist/client/bookingTime.js +109 -0
- package/dist/client/captcha.d.ts +26 -0
- package/dist/client/captcha.js +71 -0
- package/dist/client/captchaSession.d.ts +21 -0
- package/dist/client/captchaSession.js +105 -0
- package/dist/client/collections.d.ts +34 -0
- package/dist/client/collections.js +40 -0
- package/dist/client/externalScript.d.ts +20 -0
- package/dist/client/externalScript.js +36 -0
- package/dist/client/funnelState.svelte.d.ts +47 -0
- package/dist/client/funnelState.svelte.js +81 -0
- package/dist/client/leadClient.svelte.d.ts +131 -0
- package/dist/client/leadClient.svelte.js +250 -0
- package/dist/client/pageview.d.ts +7 -0
- package/dist/client/pageview.js +44 -0
- package/dist/client/siteApi.d.ts +211 -0
- package/dist/client/siteApi.js +320 -0
- package/dist/client/tracking.d.ts +18 -0
- package/dist/client/tracking.js +93 -0
- package/dist/client/validation.d.ts +10 -0
- package/dist/client/validation.js +66 -0
- package/dist/components/Booker.svelte +729 -0
- package/dist/components/Booker.svelte.d.ts +42 -0
- package/dist/components/CollectionList.svelte +122 -0
- package/dist/components/CollectionList.svelte.d.ts +65 -0
- package/dist/components/ConsentGate.svelte +68 -0
- package/dist/components/ConsentGate.svelte.d.ts +44 -0
- package/dist/components/CookieBanner.svelte +303 -0
- package/dist/components/CookieBanner.svelte.d.ts +29 -0
- package/dist/components/Datenschutz.svelte +84 -0
- package/dist/components/Datenschutz.svelte.d.ts +26 -0
- package/dist/components/Embed.svelte +263 -0
- package/dist/components/Embed.svelte.d.ts +41 -0
- package/dist/components/ExternalScript.svelte +94 -0
- package/dist/components/ExternalScript.svelte.d.ts +41 -0
- package/dist/components/Impressum.svelte +59 -0
- package/dist/components/Impressum.svelte.d.ts +25 -0
- package/dist/components/LeadForm.svelte +475 -0
- package/dist/components/LeadForm.svelte.d.ts +35 -0
- package/dist/components/LeadHoneypot.svelte +43 -0
- package/dist/components/LeadHoneypot.svelte.d.ts +18 -0
- package/dist/components/Link.svelte +48 -0
- package/dist/components/Link.svelte.d.ts +30 -0
- package/dist/components/MapEmbed.svelte +154 -0
- package/dist/components/MapEmbed.svelte.d.ts +28 -0
- package/dist/components/MediaImage.svelte +218 -0
- package/dist/components/MediaImage.svelte.d.ts +128 -0
- package/dist/components/MediaVideo.svelte +103 -0
- package/dist/components/MediaVideo.svelte.d.ts +20 -0
- package/dist/components/RichText.svelte +105 -0
- package/dist/components/RichText.svelte.d.ts +55 -0
- package/dist/components/Seo.svelte +89 -0
- package/dist/components/Seo.svelte.d.ts +45 -0
- package/dist/components/SiteFooterLegal.svelte +75 -0
- package/dist/components/SiteFooterLegal.svelte.d.ts +22 -0
- package/dist/components/SiteHead.svelte +79 -0
- package/dist/components/SiteHead.svelte.d.ts +32 -0
- package/dist/components/Text.svelte +100 -0
- package/dist/components/Text.svelte.d.ts +55 -0
- package/dist/components/Tracking.svelte +30 -0
- package/dist/components/Tracking.svelte.d.ts +14 -0
- package/dist/components/Zeitfenster.svelte +92 -0
- package/dist/components/Zeitfenster.svelte.d.ts +34 -0
- package/dist/components/legal.d.ts +12 -0
- package/dist/components/legal.js +27 -0
- package/dist/config/index.d.ts +121 -0
- package/dist/config/index.js +602 -0
- package/dist/config/static/index.d.ts +3 -0
- package/dist/config/static/index.js +5 -0
- package/dist/config/static/lines.d.ts +9 -0
- package/dist/config/static/lines.js +22 -0
- package/dist/config/static/literal.d.ts +45 -0
- package/dist/config/static/literal.js +175 -0
- package/dist/config/static/siteConfig.d.ts +39 -0
- package/dist/config/static/siteConfig.js +150 -0
- package/dist/consent/consent.svelte.d.ts +91 -0
- package/dist/consent/consent.svelte.js +221 -0
- package/dist/content/index.d.ts +123 -0
- package/dist/content/index.js +247 -0
- package/dist/contentBlock.d.ts +45 -0
- package/dist/contentBlock.js +78 -0
- package/dist/csp/index.d.ts +27 -0
- package/dist/csp/index.js +74 -0
- package/dist/external/csp.d.ts +25 -0
- package/dist/external/csp.js +104 -0
- package/dist/external/hosts.d.ts +30 -0
- package/dist/external/hosts.js +128 -0
- package/dist/external/presets.d.ts +54 -0
- package/dist/external/presets.js +212 -0
- package/dist/external/resolve.d.ts +39 -0
- package/dist/external/resolve.js +254 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +32 -0
- package/dist/internal/consentNeed.d.ts +21 -0
- package/dist/internal/consentNeed.js +50 -0
- package/dist/internal/dealsystem-legal-imprint.d.ts +2 -0
- package/dist/internal/dealsystem-legal-imprint.js +5 -0
- package/dist/internal/dealsystem-legal-privacy.d.ts +2 -0
- package/dist/internal/dealsystem-legal-privacy.js +5 -0
- package/dist/internal/dealsystem-site-data.d.ts +3 -0
- package/dist/internal/dealsystem-site-data.js +2 -0
- package/dist/internal/imprint.d.ts +4 -0
- package/dist/internal/imprint.js +10 -0
- package/dist/internal/mediaImage.d.ts +15 -0
- package/dist/internal/mediaImage.js +22 -0
- package/dist/internal/privacy.d.ts +4 -0
- package/dist/internal/privacy.js +10 -0
- package/dist/internal/providers.d.ts +9 -0
- package/dist/internal/providers.js +44 -0
- package/dist/internal/reload.d.ts +2 -0
- package/dist/internal/reload.js +5 -0
- package/dist/internal/seo.d.ts +41 -0
- package/dist/internal/seo.js +79 -0
- package/dist/internal/siteData.d.ts +7 -0
- package/dist/internal/siteData.js +39 -0
- package/dist/internal/usage.d.ts +7 -0
- package/dist/internal/usage.js +13 -0
- package/dist/keys.d.ts +20 -0
- package/dist/keys.js +58 -0
- package/dist/leadmagnet.d.ts +16 -0
- package/dist/leadmagnet.js +28 -0
- package/dist/paths.d.ts +8 -0
- package/dist/paths.js +9 -0
- package/dist/richtext/escape.d.ts +4 -0
- package/dist/richtext/escape.js +18 -0
- package/dist/richtext/server.d.ts +16 -0
- package/dist/richtext/server.js +123 -0
- package/dist/schedule.d.ts +23 -0
- package/dist/schedule.js +67 -0
- package/dist/slots.d.ts +9 -0
- package/dist/slots.js +38 -0
- package/dist/snapshot.d.ts +14 -0
- package/dist/snapshot.js +214 -0
- package/dist/types.d.ts +550 -0
- package/dist/types.js +4 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +2 -0
- package/dist/vite/index.d.ts +85 -0
- package/dist/vite/index.js +641 -0
- package/dist/vite/scan.d.ts +47 -0
- package/dist/vite/scan.js +355 -0
- package/dist/vite/zeitfenster.d.ts +18 -0
- package/dist/vite/zeitfenster.js +76 -0
- package/docs/ablauf.md +167 -0
- package/docs/agents-block.md +100 -0
- package/docs/befehle.md +103 -0
- package/docs/extern.md +143 -0
- package/docs/gestaltung.md +139 -0
- package/docs/inhalte.md +224 -0
- package/docs/komponenten.md +1273 -0
- package/docs/konfiguration.md +310 -0
- package/docs/llms.txt +19 -0
- package/docs/rechtstexte.md +84 -0
- package/docs/regeln.md +108 -0
- package/docs/seo.md +55 -0
- package/docs/termine.md +73 -0
- package/package.json +115 -5
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/** `id` des Blocks im HTML. Vertrag zwischen SDK, Build-Host und Core. */
|
|
2
|
+
export const CONTENT_BLOCK_ID = 'ds-content';
|
|
3
|
+
/** Format des Blocks (`v` im Block, `contentPatch.format` im Manifest). Steigt, wenn sich die Form ändert. */
|
|
4
|
+
export const CONTENT_BLOCK_VERSION = 1;
|
|
5
|
+
/**
|
|
6
|
+
* Grenzen für `contentPatch.richtextDefaults` im Manifest (Vertrag `contract/ds-content.v1.json`).
|
|
7
|
+
* Der Build-Bericht an den Core ist auf 8 MB begrenzt; wird eine Grenze überschritten, bekommt
|
|
8
|
+
* `contentPatch` den Blocker `richtext-defaults-too-large` und leere `richtextDefaults`: Die Seite
|
|
9
|
+
* baut weiter, der Core baut dann neu statt zu patchen.
|
|
10
|
+
*/
|
|
11
|
+
export const CONTENT_PATCH_LIMITS = Object.freeze({
|
|
12
|
+
/** Alle Werte und Schlüssel zusammen, in Bytes (UTF-8). */
|
|
13
|
+
richtextDefaultsTotalBytes: 2 * 1024 * 1024,
|
|
14
|
+
/** Ein Wert, in Zeichen. */
|
|
15
|
+
richtextDefaultMaxLength: 100_000,
|
|
16
|
+
/** Einträge. */
|
|
17
|
+
richtextDefaultsMaxEntries: 2000,
|
|
18
|
+
/** Einträge in `blockers`, Länge eines Eintrags. */
|
|
19
|
+
blockersMaxItems: 20,
|
|
20
|
+
blockerMaxLength: 40,
|
|
21
|
+
});
|
|
22
|
+
/**
|
|
23
|
+
* JSON, das in einem `<script>`-Element sicher ist: `<`, `>` und `&` werden
|
|
24
|
+
* als `\u003c` usw. geschrieben, damit kein Wert `</script>` oder `<!--`
|
|
25
|
+
* bilden kann. U+2028/U+2029 ebenso (ältere Parser).
|
|
26
|
+
*/
|
|
27
|
+
export function serializeContentBlock(block) {
|
|
28
|
+
return JSON.stringify(block)
|
|
29
|
+
.replace(/</g, '\\u003c')
|
|
30
|
+
.replace(/>/g, '\\u003e')
|
|
31
|
+
.replace(/&/g, '\\u0026')
|
|
32
|
+
.replace(/\u2028/g, '\\u2028')
|
|
33
|
+
.replace(/\u2029/g, '\\u2029');
|
|
34
|
+
}
|
|
35
|
+
/** Das fertige Element für den Kopf der Seite. */
|
|
36
|
+
export function contentBlockTag(block) {
|
|
37
|
+
return `<script type="application/json" id="${CONTENT_BLOCK_ID}">${serializeContentBlock(block)}</script>`;
|
|
38
|
+
}
|
|
39
|
+
/** Findet den Block in einer HTML-Datei: Anfang und Ende des ganzen Elements. */
|
|
40
|
+
export const CONTENT_BLOCK_PATTERN = /<script type="application\/json" id="ds-content">([^<]*)<\/script>/g;
|
|
41
|
+
function isRecord(value) {
|
|
42
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Liest den Block. Alles, was nicht passt, wird verworfen: dann gelten die
|
|
46
|
+
* Standardwerte aus dem Code, die Seite bleibt benutzbar.
|
|
47
|
+
*/
|
|
48
|
+
export function parseContentBlock(text) {
|
|
49
|
+
if (!text)
|
|
50
|
+
return null;
|
|
51
|
+
let raw;
|
|
52
|
+
try {
|
|
53
|
+
raw = JSON.parse(text);
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
if (!isRecord(raw) || raw.v !== CONTENT_BLOCK_VERSION)
|
|
59
|
+
return null;
|
|
60
|
+
const slots = {};
|
|
61
|
+
if (isRecord(raw.slots)) {
|
|
62
|
+
for (const [key, value] of Object.entries(raw.slots)) {
|
|
63
|
+
if (key === '__proto__')
|
|
64
|
+
continue;
|
|
65
|
+
if (isRecord(value) && typeof value.type === 'string') {
|
|
66
|
+
slots[key] = { type: value.type, value: value.value };
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const richtext = {};
|
|
71
|
+
if (isRecord(raw.richtext)) {
|
|
72
|
+
for (const [key, value] of Object.entries(raw.richtext)) {
|
|
73
|
+
if (key !== '__proto__' && typeof value === 'string')
|
|
74
|
+
richtext[key] = value;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return { v: CONTENT_BLOCK_VERSION, slots, richtext };
|
|
78
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Config } from '@sveltejs/kit';
|
|
2
|
+
type KitCsp = NonNullable<NonNullable<Config['kit']>['csp']>;
|
|
3
|
+
/**
|
|
4
|
+
* Sicherheitsregeln (Content-Security-Policy) der Seite für `kit.csp` in `svelte.config.js`. Sie entstehen aus
|
|
5
|
+
* einer festen Basis und den fremden Diensten unter `external` in `dealsystem.config.ts`; die Datei wird dafür
|
|
6
|
+
* gelesen, nicht ausgeführt. Was dort nicht steht, lässt der Browser nicht zu. Die Funktion nimmt bewusst keine
|
|
7
|
+
* Argumente: Hosts trägst du in `external` ein, nie hier.
|
|
8
|
+
*
|
|
9
|
+
* Die Adresse der Site-API kommt aus `PUBLIC_DEALSYSTEM_API` (wie bei `siteApiOrigin()`). Steht im CRM eine Google-Ads-
|
|
10
|
+
* Kennung (`AW-…`), kommen die Hosts für Ads-Conversions dazu (aus dem Inhalts-Schnappschuss gelesen).
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* // svelte.config.js
|
|
14
|
+
* import adapter from '@sveltejs/adapter-static';
|
|
15
|
+
* import { handleHttpError } from '@dealsystem/site/config';
|
|
16
|
+
* import { dealsystemCsp } from '@dealsystem/site/csp';
|
|
17
|
+
*
|
|
18
|
+
* export default {
|
|
19
|
+
* kit: {
|
|
20
|
+
* adapter: adapter({ fallback: '404.html' }),
|
|
21
|
+
* prerender: { handleHttpError, handleUnseenRoutes: 'ignore' },
|
|
22
|
+
* csp: dealsystemCsp(),
|
|
23
|
+
* },
|
|
24
|
+
* };
|
|
25
|
+
*/
|
|
26
|
+
export declare function dealsystemCsp(): KitCsp;
|
|
27
|
+
export { buildCspDirectives } from '../external/csp.js';
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// `@dealsystem/site/csp`: die Content-Security-Policy der Seite für `kit.csp` in svelte.config.js.
|
|
2
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
3
|
+
import { dirname, join, resolve } from 'node:path';
|
|
4
|
+
import { siteApiOrigin } from '../config/index.js';
|
|
5
|
+
import { readSiteConfig, SITE_CONFIG_FILE } from '../config/static/index.js';
|
|
6
|
+
import { buildCspDirectives, isGoogleAdsId } from '../external/csp.js';
|
|
7
|
+
import { CONTENT_FILE_ENV, LOCAL_CONTENT_FILE } from '../paths.js';
|
|
8
|
+
/** Sucht `dealsystem.config.ts` im Arbeitsordner und darüber bis zum Projektordner (erste `package.json`). */
|
|
9
|
+
function findSiteConfig(start) {
|
|
10
|
+
let dir = start;
|
|
11
|
+
for (;;) {
|
|
12
|
+
const file = join(dir, SITE_CONFIG_FILE);
|
|
13
|
+
if (existsSync(file))
|
|
14
|
+
return file;
|
|
15
|
+
const parent = dirname(dir);
|
|
16
|
+
if (existsSync(join(dir, 'package.json')) || parent === dir)
|
|
17
|
+
return null;
|
|
18
|
+
dir = parent;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Google-Kennung aus dem Inhalts-Schnappschuss (`DEALSYSTEM_CONTENT_FILE` oder `.dealsystem/content.json`), als
|
|
23
|
+
* JSON gelesen. Fehlt die Datei oder ist sie unlesbar: `null` (dann keine Ads-Hosts; der Build meldet die Datei
|
|
24
|
+
* selbst).
|
|
25
|
+
*/
|
|
26
|
+
function snapshotGoogleTagId(projectDir) {
|
|
27
|
+
const file = resolve(projectDir, process.env[CONTENT_FILE_ENV] || LOCAL_CONTENT_FILE);
|
|
28
|
+
try {
|
|
29
|
+
const raw = JSON.parse(readFileSync(file, 'utf8'));
|
|
30
|
+
const id = raw?.tracking?.googleTagId;
|
|
31
|
+
return typeof id === 'string' ? id : null;
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Sicherheitsregeln (Content-Security-Policy) der Seite für `kit.csp` in `svelte.config.js`. Sie entstehen aus
|
|
39
|
+
* einer festen Basis und den fremden Diensten unter `external` in `dealsystem.config.ts`; die Datei wird dafür
|
|
40
|
+
* gelesen, nicht ausgeführt. Was dort nicht steht, lässt der Browser nicht zu. Die Funktion nimmt bewusst keine
|
|
41
|
+
* Argumente: Hosts trägst du in `external` ein, nie hier.
|
|
42
|
+
*
|
|
43
|
+
* Die Adresse der Site-API kommt aus `PUBLIC_DEALSYSTEM_API` (wie bei `siteApiOrigin()`). Steht im CRM eine Google-Ads-
|
|
44
|
+
* Kennung (`AW-…`), kommen die Hosts für Ads-Conversions dazu (aus dem Inhalts-Schnappschuss gelesen).
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* // svelte.config.js
|
|
48
|
+
* import adapter from '@sveltejs/adapter-static';
|
|
49
|
+
* import { handleHttpError } from '@dealsystem/site/config';
|
|
50
|
+
* import { dealsystemCsp } from '@dealsystem/site/csp';
|
|
51
|
+
*
|
|
52
|
+
* export default {
|
|
53
|
+
* kit: {
|
|
54
|
+
* adapter: adapter({ fallback: '404.html' }),
|
|
55
|
+
* prerender: { handleHttpError, handleUnseenRoutes: 'ignore' },
|
|
56
|
+
* csp: dealsystemCsp(),
|
|
57
|
+
* },
|
|
58
|
+
* };
|
|
59
|
+
*/
|
|
60
|
+
export function dealsystemCsp() {
|
|
61
|
+
const file = findSiteConfig(process.cwd());
|
|
62
|
+
const result = readSiteConfig(file ? readFileSync(file, 'utf8') : null);
|
|
63
|
+
const problems = result.problems.filter((p) => p.kind === 'external');
|
|
64
|
+
if (problems.length > 0) {
|
|
65
|
+
const lines = problems.map((p) => ` - ${p.path}${p.line ? ` (Zeile ${p.line})` : ''}: ${p.message}`);
|
|
66
|
+
throw new Error(`[dealsystem] external in ${SITE_CONFIG_FILE} ist ungültig:\n${lines.join('\n')}`);
|
|
67
|
+
}
|
|
68
|
+
const projectDir = file ? dirname(file) : process.cwd();
|
|
69
|
+
const directives = buildCspDirectives(result.data?.external ?? [], siteApiOrigin(), {
|
|
70
|
+
googleAds: isGoogleAdsId(snapshotGoogleTagId(projectDir)),
|
|
71
|
+
});
|
|
72
|
+
return { mode: 'hash', directives: directives };
|
|
73
|
+
}
|
|
74
|
+
export { buildCspDirectives } from '../external/csp.js';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ExternalDirective, ResolvedExternal } from '../types.js';
|
|
2
|
+
/** CSP-Direktive je Schlüssel einer Deklaration. */
|
|
3
|
+
export declare const CSP_DIRECTIVE: Readonly<Record<ExternalDirective, string>>;
|
|
4
|
+
/** Hosts von Google Tag und Meta Pixel. Laden nur über `<Tracking>` nach der Einwilligung „Marketing“. */
|
|
5
|
+
export declare const TRACKING_CSP: Readonly<Record<string, readonly string[]>>;
|
|
6
|
+
/**
|
|
7
|
+
* Zusätzliche Hosts für Google Ads (Conversion, Remarketing, Conversion Linker), nur wenn im CRM eine Kennung
|
|
8
|
+
* `AW-…` steht. Laut Google: https://developers.google.com/tag-platform/security/guides/csp (Abschnitt „Google Ads“,
|
|
9
|
+
* Stand 10.11.2026). `www.google.<TLD>` lässt sich in CSP nicht mit Platzhalter schreiben; aufgenommen ist
|
|
10
|
+
* `www.google.de` für deutsche Besucher. Geladen wird weiter nur über `<Tracking>` nach der Einwilligung „Marketing“.
|
|
11
|
+
*/
|
|
12
|
+
export declare const GOOGLE_ADS_CSP: Readonly<Record<string, readonly string[]>>;
|
|
13
|
+
/** Ist die Google-Kennung aus dem CRM eine von Google Ads (`AW-…`)? */
|
|
14
|
+
export declare function isGoogleAdsId(id: string | null | undefined): boolean;
|
|
15
|
+
/** Herkunft der Karte von `<MapEmbed>` (OpenStreetMap, nach Einwilligung). */
|
|
16
|
+
export declare const MAP_EMBED_ORIGIN = "https://www.openstreetmap.org";
|
|
17
|
+
/**
|
|
18
|
+
* Direktiven der CSP aus Basis und Deklaration. Gleiche Eingabe, gleiche Ausgabe (Reihenfolge: Basis, dann die
|
|
19
|
+
* deklarierten Hosts sortiert).
|
|
20
|
+
*/
|
|
21
|
+
export declare function buildCspDirectives(external: readonly ResolvedExternal[], apiOrigin: string,
|
|
22
|
+
/** `googleAds`: Kennung `AW-…` im CRM, dann kommen die Hosts aus `GOOGLE_ADS_CSP` dazu. */
|
|
23
|
+
options?: {
|
|
24
|
+
googleAds?: boolean;
|
|
25
|
+
}): Record<string, string[]>;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// Content-Security-Policy einer Seite: feste Basis plus die Hosts aus `external`. Reine Funktion; `dealsystemCsp()`
|
|
2
|
+
// (`@dealsystem/site/csp`) liest dafür die Konfiguration, `dealsystem check` (SEC-008) rechnet dieselbe CSP nach
|
|
3
|
+
// und vergleicht sie mit dem Meta-Tag jeder fertigen Seite.
|
|
4
|
+
import { EXTERNAL_DIRECTIVES } from './hosts.js';
|
|
5
|
+
/** CSP-Direktive je Schlüssel einer Deklaration. */
|
|
6
|
+
export const CSP_DIRECTIVE = {
|
|
7
|
+
script: 'script-src',
|
|
8
|
+
connect: 'connect-src',
|
|
9
|
+
img: 'img-src',
|
|
10
|
+
frame: 'frame-src',
|
|
11
|
+
media: 'media-src',
|
|
12
|
+
style: 'style-src',
|
|
13
|
+
font: 'font-src',
|
|
14
|
+
};
|
|
15
|
+
/** Hosts von Google Tag und Meta Pixel. Laden nur über `<Tracking>` nach der Einwilligung „Marketing“. */
|
|
16
|
+
export const TRACKING_CSP = {
|
|
17
|
+
'script-src': ['https://www.googletagmanager.com', 'https://connect.facebook.net'],
|
|
18
|
+
'img-src': ['https://www.googletagmanager.com', 'https://www.facebook.com'],
|
|
19
|
+
'connect-src': [
|
|
20
|
+
'https://*.google-analytics.com',
|
|
21
|
+
'https://*.analytics.google.com',
|
|
22
|
+
'https://www.googletagmanager.com',
|
|
23
|
+
'https://www.facebook.com',
|
|
24
|
+
],
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Zusätzliche Hosts für Google Ads (Conversion, Remarketing, Conversion Linker), nur wenn im CRM eine Kennung
|
|
28
|
+
* `AW-…` steht. Laut Google: https://developers.google.com/tag-platform/security/guides/csp (Abschnitt „Google Ads“,
|
|
29
|
+
* Stand 10.11.2026). `www.google.<TLD>` lässt sich in CSP nicht mit Platzhalter schreiben; aufgenommen ist
|
|
30
|
+
* `www.google.de` für deutsche Besucher. Geladen wird weiter nur über `<Tracking>` nach der Einwilligung „Marketing“.
|
|
31
|
+
*/
|
|
32
|
+
export const GOOGLE_ADS_CSP = {
|
|
33
|
+
'script-src': ['https://www.googleadservices.com', 'https://www.google.com'],
|
|
34
|
+
'img-src': [
|
|
35
|
+
'https://www.googleadservices.com',
|
|
36
|
+
'https://googleads.g.doubleclick.net',
|
|
37
|
+
'https://pagead2.googlesyndication.com',
|
|
38
|
+
'https://www.google.com',
|
|
39
|
+
'https://www.google.de',
|
|
40
|
+
],
|
|
41
|
+
'connect-src': [
|
|
42
|
+
'https://www.googleadservices.com',
|
|
43
|
+
'https://googleads.g.doubleclick.net',
|
|
44
|
+
'https://pagead2.googlesyndication.com',
|
|
45
|
+
'https://www.google.com',
|
|
46
|
+
'https://www.google.de',
|
|
47
|
+
'https://ad.doubleclick.net',
|
|
48
|
+
],
|
|
49
|
+
'frame-src': ['https://www.googletagmanager.com'],
|
|
50
|
+
};
|
|
51
|
+
/** Ist die Google-Kennung aus dem CRM eine von Google Ads (`AW-…`)? */
|
|
52
|
+
export function isGoogleAdsId(id) {
|
|
53
|
+
return typeof id === 'string' && /^AW-[A-Z0-9-]{4,30}$/i.test(id.trim());
|
|
54
|
+
}
|
|
55
|
+
/** Herkunft der Karte von `<MapEmbed>` (OpenStreetMap, nach Einwilligung). */
|
|
56
|
+
export const MAP_EMBED_ORIGIN = 'https://www.openstreetmap.org';
|
|
57
|
+
/**
|
|
58
|
+
* Basis der CSP, ohne Site-API. Schlüsselwörter ohne Anführungszeichen, wie SvelteKit sie in `kit.csp`
|
|
59
|
+
* erwartet. Entspricht der festen CSP des Starters bis SDK 0.1 plus `media-src 'self'`.
|
|
60
|
+
*/
|
|
61
|
+
function baseDirectives(apiOrigin) {
|
|
62
|
+
return {
|
|
63
|
+
'default-src': ['self'],
|
|
64
|
+
'script-src': ['self', ...TRACKING_CSP['script-src']],
|
|
65
|
+
'style-src': ['self', 'unsafe-inline'],
|
|
66
|
+
'img-src': ['self', 'data:', ...TRACKING_CSP['img-src']],
|
|
67
|
+
'font-src': ['self'],
|
|
68
|
+
'connect-src': ['self', apiOrigin, ...TRACKING_CSP['connect-src']],
|
|
69
|
+
'frame-src': ['self', MAP_EMBED_ORIGIN],
|
|
70
|
+
'media-src': ['self'],
|
|
71
|
+
'worker-src': ['self'],
|
|
72
|
+
'object-src': ['none'],
|
|
73
|
+
'base-uri': ['self'],
|
|
74
|
+
'form-action': ['self'],
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Direktiven der CSP aus Basis und Deklaration. Gleiche Eingabe, gleiche Ausgabe (Reihenfolge: Basis, dann die
|
|
79
|
+
* deklarierten Hosts sortiert).
|
|
80
|
+
*/
|
|
81
|
+
export function buildCspDirectives(external, apiOrigin,
|
|
82
|
+
/** `googleAds`: Kennung `AW-…` im CRM, dann kommen die Hosts aus `GOOGLE_ADS_CSP` dazu. */
|
|
83
|
+
options = {}) {
|
|
84
|
+
const directives = baseDirectives(apiOrigin);
|
|
85
|
+
if (options.googleAds) {
|
|
86
|
+
for (const [name, hosts] of Object.entries(GOOGLE_ADS_CSP)) {
|
|
87
|
+
const list = directives[name] ?? ['self'];
|
|
88
|
+
for (const host of hosts)
|
|
89
|
+
if (!list.includes(host))
|
|
90
|
+
list.push(host);
|
|
91
|
+
directives[name] = list;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
for (const directive of EXTERNAL_DIRECTIVES) {
|
|
95
|
+
const name = CSP_DIRECTIVE[directive];
|
|
96
|
+
const declared = [...new Set(external.flatMap((e) => e.hosts[directive]))].sort();
|
|
97
|
+
const list = directives[name] ?? ['self'];
|
|
98
|
+
for (const host of declared)
|
|
99
|
+
if (!list.includes(host))
|
|
100
|
+
list.push(host);
|
|
101
|
+
directives[name] = list;
|
|
102
|
+
}
|
|
103
|
+
return directives;
|
|
104
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ExternalDirective } from '../types.js';
|
|
2
|
+
/** Direktiven in der Reihenfolge, in der sie im Manifest und in Meldungen stehen. */
|
|
3
|
+
export declare const EXTERNAL_DIRECTIVES: readonly ExternalDirective[];
|
|
4
|
+
/** Direktiven, in denen `https://*.domain` erlaubt ist. In `script` und `frame` nie: jeder Unterhost wäre offen. */
|
|
5
|
+
export declare const WILDCARD_DIRECTIVES: readonly ExternalDirective[];
|
|
6
|
+
/** Höchstzahl der fremden Dienste einer Seite und der Hosts je Direktive. */
|
|
7
|
+
export declare const MAX_EXTERNAL_ENTRIES = 30;
|
|
8
|
+
export declare const MAX_HOSTS_PER_DIRECTIVE = 20;
|
|
9
|
+
/**
|
|
10
|
+
* Endungen, unter denen jeder Fremde eine Adresse bekommt (Ländervorwahlen mit zwei Teilen, Hosting-Plattformen).
|
|
11
|
+
* `https://*.<endung>` würde Hosts beliebiger Dritter öffnen. Bewusst kurz: die häufigen Fälle, kein Ersatz für die
|
|
12
|
+
* Public Suffix List.
|
|
13
|
+
*/
|
|
14
|
+
export declare const SHARED_SUFFIXES: readonly string[];
|
|
15
|
+
/** Zerlegt `https://*.a.de` in `{ wildcard: true, host: 'a.de' }`; `null`, wenn die Form nicht passt. */
|
|
16
|
+
export declare function parseHostSource(source: string): {
|
|
17
|
+
wildcard: boolean;
|
|
18
|
+
host: string;
|
|
19
|
+
} | null;
|
|
20
|
+
/**
|
|
21
|
+
* Warum eine Host-Quelle in dieser Direktive nicht erlaubt ist; `null`, wenn sie passt.
|
|
22
|
+
* Die Meldung ist ein ganzer Satz mit Beispiel, für Agenten ohne Vorwissen.
|
|
23
|
+
*/
|
|
24
|
+
export declare function hostSourceProblem(source: unknown, directive: ExternalDirective): string | null;
|
|
25
|
+
/** Ob die Host-Quelle (`https://a.de` oder `https://*.a.de`) die Adresse abdeckt. Nur https, Standard-Port. */
|
|
26
|
+
export declare function hostSourceMatches(source: string, url: URL): boolean;
|
|
27
|
+
/** Fremde Adresse (`https://…`, `//…`) als URL; `null` für eigene Pfade, Ausdrücke und Ungültiges. */
|
|
28
|
+
export declare function externalUrl(value: string | null | undefined): URL | null;
|
|
29
|
+
/** Eigener Pfad der Seite (`/scripts/chat.js`), kein `//host`, keine Steuerzeichen. */
|
|
30
|
+
export declare function isLocalPath(value: string): boolean;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
// Host-Quellen fremder Dienste (`external` in dealsystem.config.ts): Form prüfen und gegen Adressen abgleichen.
|
|
2
|
+
// Dieselben Funktionen nutzen Konfiguration, CSP-Erzeugung, Bausteine und `dealsystem check`.
|
|
3
|
+
/** Direktiven in der Reihenfolge, in der sie im Manifest und in Meldungen stehen. */
|
|
4
|
+
export const EXTERNAL_DIRECTIVES = [
|
|
5
|
+
'script',
|
|
6
|
+
'connect',
|
|
7
|
+
'img',
|
|
8
|
+
'frame',
|
|
9
|
+
'media',
|
|
10
|
+
'style',
|
|
11
|
+
'font',
|
|
12
|
+
];
|
|
13
|
+
/** Direktiven, in denen `https://*.domain` erlaubt ist. In `script` und `frame` nie: jeder Unterhost wäre offen. */
|
|
14
|
+
export const WILDCARD_DIRECTIVES = ['connect', 'img', 'media', 'style', 'font'];
|
|
15
|
+
/** Höchstzahl der fremden Dienste einer Seite und der Hosts je Direktive. */
|
|
16
|
+
export const MAX_EXTERNAL_ENTRIES = 30;
|
|
17
|
+
export const MAX_HOSTS_PER_DIRECTIVE = 20;
|
|
18
|
+
/**
|
|
19
|
+
* Endungen, unter denen jeder Fremde eine Adresse bekommt (Ländervorwahlen mit zwei Teilen, Hosting-Plattformen).
|
|
20
|
+
* `https://*.<endung>` würde Hosts beliebiger Dritter öffnen. Bewusst kurz: die häufigen Fälle, kein Ersatz für die
|
|
21
|
+
* Public Suffix List.
|
|
22
|
+
*/
|
|
23
|
+
export const SHARED_SUFFIXES = [
|
|
24
|
+
'co.uk',
|
|
25
|
+
'org.uk',
|
|
26
|
+
'ac.uk',
|
|
27
|
+
'gov.uk',
|
|
28
|
+
'com.au',
|
|
29
|
+
'net.au',
|
|
30
|
+
'org.au',
|
|
31
|
+
'co.at',
|
|
32
|
+
'or.at',
|
|
33
|
+
'com.br',
|
|
34
|
+
'co.jp',
|
|
35
|
+
'co.nz',
|
|
36
|
+
'com.cn',
|
|
37
|
+
'com.tr',
|
|
38
|
+
'co.za',
|
|
39
|
+
'com.mx',
|
|
40
|
+
'github.io',
|
|
41
|
+
'gitlab.io',
|
|
42
|
+
'herokuapp.com',
|
|
43
|
+
'vercel.app',
|
|
44
|
+
'netlify.app',
|
|
45
|
+
'pages.dev',
|
|
46
|
+
'workers.dev',
|
|
47
|
+
'web.app',
|
|
48
|
+
'firebaseapp.com',
|
|
49
|
+
'appspot.com',
|
|
50
|
+
'cloudfront.net',
|
|
51
|
+
'amazonaws.com',
|
|
52
|
+
'azurewebsites.net',
|
|
53
|
+
'blogspot.com',
|
|
54
|
+
'dealsystem.site',
|
|
55
|
+
];
|
|
56
|
+
/** Hosts von DealSystem selbst: Die Site-API steht schon in der CSP, alles andere braucht eine Seite nicht. */
|
|
57
|
+
const OWN_DOMAINS = ['dealsystem.io'];
|
|
58
|
+
const HOST_SOURCE = /^https:\/\/(\*\.)?((?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z][a-z0-9-]{0,61}[a-z0-9])$/;
|
|
59
|
+
/** Zerlegt `https://*.a.de` in `{ wildcard: true, host: 'a.de' }`; `null`, wenn die Form nicht passt. */
|
|
60
|
+
export function parseHostSource(source) {
|
|
61
|
+
const m = HOST_SOURCE.exec(source.trim().toLowerCase());
|
|
62
|
+
if (!m)
|
|
63
|
+
return null;
|
|
64
|
+
return { wildcard: m[1] !== undefined, host: m[2] };
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Warum eine Host-Quelle in dieser Direktive nicht erlaubt ist; `null`, wenn sie passt.
|
|
68
|
+
* Die Meldung ist ein ganzer Satz mit Beispiel, für Agenten ohne Vorwissen.
|
|
69
|
+
*/
|
|
70
|
+
export function hostSourceProblem(source, directive) {
|
|
71
|
+
if (typeof source !== 'string')
|
|
72
|
+
return 'Ein Host ist eine Zeichenkette, z. B. "https://js.example.com".';
|
|
73
|
+
const raw = source.trim();
|
|
74
|
+
if (raw !== source || raw.toLowerCase() !== raw)
|
|
75
|
+
return `"${source}" ist nicht in der Grundform: Kleinbuchstaben, keine Leerzeichen, z. B. "${raw.toLowerCase()}".`;
|
|
76
|
+
if (['*', 'https:', 'http:', 'data:', 'blob:', "'unsafe-eval'", 'unsafe-eval'].includes(raw))
|
|
77
|
+
return `"${source}" würde jeden Host öffnen. Nenne die Hosts einzeln, z. B. "https://js.example.com".`;
|
|
78
|
+
if (raw.startsWith('http://'))
|
|
79
|
+
return `"${source}" ist unverschlüsselt. Nur https:// ist erlaubt.`;
|
|
80
|
+
if (!raw.startsWith('https://'))
|
|
81
|
+
return `"${source}" braucht die Form "https://host.de" (mit https://).`;
|
|
82
|
+
const parsed = parseHostSource(raw);
|
|
83
|
+
if (!parsed) {
|
|
84
|
+
if (/^https:\/\/[^/]+\/./.test(raw) || raw.endsWith('/'))
|
|
85
|
+
return `"${source}" enthält einen Pfad oder Schrägstrich am Ende. Nenne nur den Host, z. B. "${raw.replace(/^(https:\/\/[^/]+).*$/, '$1')}".`;
|
|
86
|
+
if (/^https:\/\/[^/]+:\d+/.test(raw))
|
|
87
|
+
return `"${source}" enthält einen Port. Erlaubt ist nur Port 443 ohne Angabe.`;
|
|
88
|
+
if (raw.includes('*'))
|
|
89
|
+
return `"${source}": Ein Platzhalter steht nur ganz vorn als "https://*.domain.de", nie mitten im Namen.`;
|
|
90
|
+
return `"${source}" ist kein gültiger Host. Form: "https://host.de".`;
|
|
91
|
+
}
|
|
92
|
+
const { wildcard, host } = parsed;
|
|
93
|
+
if (OWN_DOMAINS.some((d) => host === d || host.endsWith(`.${d}`)))
|
|
94
|
+
return `"${source}" gehört zu DealSystem. Die Site-API steht schon in den Sicherheitsregeln; trage sie nicht ein.`;
|
|
95
|
+
if (wildcard) {
|
|
96
|
+
if (!WILDCARD_DIRECTIVES.includes(directive))
|
|
97
|
+
return `"${source}": In ${directive} sind keine Platzhalter erlaubt. Nenne jeden Host einzeln, z. B. "https://js.${host}".`;
|
|
98
|
+
if (host.split('.').length < 2 || SHARED_SUFFIXES.includes(host))
|
|
99
|
+
return `"${source}" würde Hosts beliebiger Dritter öffnen. Ein Platzhalter braucht eine eigene Domain des Anbieters, z. B. "https://*.anbieter.de".`;
|
|
100
|
+
}
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
/** Ob die Host-Quelle (`https://a.de` oder `https://*.a.de`) die Adresse abdeckt. Nur https, Standard-Port. */
|
|
104
|
+
export function hostSourceMatches(source, url) {
|
|
105
|
+
const parsed = parseHostSource(source);
|
|
106
|
+
if (!parsed || url.protocol !== 'https:' || url.port !== '')
|
|
107
|
+
return false;
|
|
108
|
+
const name = url.hostname.toLowerCase();
|
|
109
|
+
return parsed.wildcard ? name.endsWith(`.${parsed.host}`) : name === parsed.host;
|
|
110
|
+
}
|
|
111
|
+
/** Fremde Adresse (`https://…`, `//…`) als URL; `null` für eigene Pfade, Ausdrücke und Ungültiges. */
|
|
112
|
+
export function externalUrl(value) {
|
|
113
|
+
if (!value)
|
|
114
|
+
return null;
|
|
115
|
+
const v = value.trim();
|
|
116
|
+
if (!/^(https?:)?\/\//i.test(v))
|
|
117
|
+
return null;
|
|
118
|
+
try {
|
|
119
|
+
return new URL(v.startsWith('//') ? `https:${v}` : v);
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/** Eigener Pfad der Seite (`/scripts/chat.js`), kein `//host`, keine Steuerzeichen. */
|
|
126
|
+
export function isLocalPath(value) {
|
|
127
|
+
return /^\/(?!\/)[^\s\\]*$/.test(value) && !value.includes('/../') && !value.endsWith('/..');
|
|
128
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { ExternalCategory, ExternalDirective, ExternalHosts, ExternalPreset } from '../types.js';
|
|
2
|
+
/** Wie `<Embed>` einen Dienst als iframe einbettet. */
|
|
3
|
+
export interface EmbedSettings {
|
|
4
|
+
/** Werte für `sandbox`. Nie `allow-top-navigation`: ein Rahmen darf die Seite nicht wegleiten. */
|
|
5
|
+
sandbox: string;
|
|
6
|
+
/** Werte für `allow` (Permissions Policy). */
|
|
7
|
+
allow: string;
|
|
8
|
+
allowFullscreen: boolean;
|
|
9
|
+
referrerPolicy: 'no-referrer' | 'strict-origin-when-cross-origin';
|
|
10
|
+
/** Beschriftung der Schaltfläche im Platzhalter. */
|
|
11
|
+
loadLabel: string;
|
|
12
|
+
/** Was eingebettet ist, für den Text im Platzhalter („Das Video kommt von …“). */
|
|
13
|
+
noun: string;
|
|
14
|
+
/** Seitenverhältnis (`aspect-ratio`), wenn keine Höhe vorgegeben ist. */
|
|
15
|
+
aspect: string | null;
|
|
16
|
+
/** Feste Höhe, z. B. für Terminbuchung. */
|
|
17
|
+
height: string | null;
|
|
18
|
+
}
|
|
19
|
+
export interface PresetDef {
|
|
20
|
+
category: ExternalCategory;
|
|
21
|
+
provider: string;
|
|
22
|
+
purpose: string;
|
|
23
|
+
privacyUrl: string;
|
|
24
|
+
hosts: Partial<Record<ExternalDirective, readonly string[]>>;
|
|
25
|
+
embed: EmbedSettings;
|
|
26
|
+
/** Bringt eine vom Kunden kopierte Adresse in die Form der Einbettung; `null`, wenn sie nicht passt. */
|
|
27
|
+
normalize(src: URL): string | null;
|
|
28
|
+
/** Adresse für den Link „beim Anbieter öffnen“. */
|
|
29
|
+
original(embedSrc: URL): string;
|
|
30
|
+
}
|
|
31
|
+
export declare const PRESETS: Readonly<Record<ExternalPreset, PresetDef>>;
|
|
32
|
+
/** Einstellungen für einen eigenen Dienst mit `frame`-Hosts (kein Preset). */
|
|
33
|
+
export declare const CUSTOM_EMBED: EmbedSettings;
|
|
34
|
+
export declare const PRESET_NAMES: ExternalPreset[];
|
|
35
|
+
export declare function isPreset(value: unknown): value is ExternalPreset;
|
|
36
|
+
/** Fassung von `contract/external-presets.v1.json`. */
|
|
37
|
+
export declare const EXTERNAL_PRESETS_CONTRACT_VERSION = 1;
|
|
38
|
+
/** Eine Vorlage, wie sie der Core kennt: ohne Einbettung und ohne Normalisierung. */
|
|
39
|
+
export interface PresetContractEntry {
|
|
40
|
+
category: ExternalCategory;
|
|
41
|
+
provider: string;
|
|
42
|
+
/** Alle sieben Direktiven, je sortiert, wie im Manifest. */
|
|
43
|
+
hosts: ExternalHosts;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Inhalt von `contract/external-presets.v1.json`, aus `PRESETS` erzeugt. Der Core hält eine byte-gleiche Kopie und
|
|
47
|
+
* prüft seine Vorlagen dagegen: Ein Manifest-Eintrag zählt dort nur als Vorlage, wenn er genau diese Hosts trägt.
|
|
48
|
+
*/
|
|
49
|
+
export declare function externalPresetsContract(): {
|
|
50
|
+
version: number;
|
|
51
|
+
presets: Record<string, PresetContractEntry>;
|
|
52
|
+
};
|
|
53
|
+
/** Text der Vertragsdatei (JSON mit Tabulator, Zeilenende am Schluss). */
|
|
54
|
+
export declare function externalPresetsContractText(): string;
|