@c15t/backend 2.0.0-rc.4 → 2.0.0-rc.6
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/302.js +473 -0
- package/dist/364.js +1140 -0
- package/dist/583.js +540 -0
- package/dist/cache.cjs +1 -1
- package/dist/cache.js +4 -415
- package/dist/core.cjs +849 -96
- package/dist/core.js +147 -1817
- package/dist/db/adapters/drizzle.cjs +1 -1
- package/dist/db/adapters/drizzle.js +1 -2
- package/dist/db/adapters/kysely.cjs +1 -1
- package/dist/db/adapters/kysely.js +1 -2
- package/dist/db/adapters/mongo.cjs +1 -1
- package/dist/db/adapters/mongo.js +1 -2
- package/dist/db/adapters/prisma.cjs +1 -1
- package/dist/db/adapters/prisma.js +1 -2
- package/dist/db/adapters/typeorm.cjs +1 -1
- package/dist/db/adapters/typeorm.js +1 -2
- package/dist/db/adapters.cjs +1 -1
- package/dist/db/migrator.cjs +1 -1
- package/dist/db/schema.cjs +38 -1
- package/dist/db/schema.js +33 -2
- package/dist/define-config.cjs +1 -1
- package/dist/edge.cjs +1106 -0
- package/dist/edge.js +190 -0
- package/dist/router.cjs +629 -81
- package/dist/router.js +1 -1509
- package/dist/types/index.cjs +1 -1
- package/{dist → dist-types}/cache/adapters/cloudflare-kv.d.ts +0 -1
- package/{dist → dist-types}/cache/adapters/index.d.ts +0 -1
- package/{dist → dist-types}/cache/adapters/memory.d.ts +0 -1
- package/{dist → dist-types}/cache/adapters/upstash-redis.d.ts +0 -1
- package/{dist → dist-types}/cache/gvl-resolver.d.ts +1 -2
- package/{dist → dist-types}/cache/index.d.ts +0 -1
- package/{dist → dist-types}/cache/keys.d.ts +0 -1
- package/{dist → dist-types}/cache/types.d.ts +0 -1
- package/{dist → dist-types}/core.d.ts +8 -1
- package/{dist → dist-types}/db/migrator/index.d.ts +0 -1
- package/{dist → dist-types}/db/registry/consent-policy.d.ts +0 -1
- package/{dist → dist-types}/db/registry/consent-purpose.d.ts +0 -1
- package/{dist → dist-types}/db/registry/domain.d.ts +0 -1
- package/{dist → dist-types}/db/registry/index.d.ts +22 -2
- package/dist-types/db/registry/runtime-policy-decision.d.ts +60 -0
- package/{dist → dist-types}/db/registry/subject.d.ts +0 -1
- package/{dist → dist-types}/db/registry/types.d.ts +1 -2
- package/{dist → dist-types}/db/registry/utils/generate-id.d.ts +0 -1
- package/{dist → dist-types}/db/registry/utils.d.ts +0 -1
- package/{dist → dist-types}/db/schema/1.0.0/audit-log.d.ts +0 -1
- package/{dist → dist-types}/db/schema/1.0.0/consent-policy.d.ts +0 -1
- package/{dist → dist-types}/db/schema/1.0.0/consent-purpose.d.ts +0 -1
- package/{dist → dist-types}/db/schema/1.0.0/consent-record.d.ts +0 -1
- package/{dist → dist-types}/db/schema/1.0.0/consent.d.ts +2 -3
- package/{dist → dist-types}/db/schema/1.0.0/domain.d.ts +0 -1
- package/{dist → dist-types}/db/schema/1.0.0/index.d.ts +0 -1
- package/{dist → dist-types}/db/schema/1.0.0/subject.d.ts +0 -1
- package/{dist → dist-types}/db/schema/2.0.0/audit-log.d.ts +2 -3
- package/{dist → dist-types}/db/schema/2.0.0/consent-policy.d.ts +2 -3
- package/{dist → dist-types}/db/schema/2.0.0/consent-purpose.d.ts +2 -3
- package/{dist → dist-types}/db/schema/2.0.0/consent.d.ts +6 -3
- package/{dist → dist-types}/db/schema/2.0.0/domain.d.ts +2 -3
- package/{dist → dist-types}/db/schema/2.0.0/index.d.ts +432 -17
- package/dist-types/db/schema/2.0.0/runtime-policy-decision.d.ts +23 -0
- package/{dist → dist-types}/db/schema/2.0.0/subject.d.ts +2 -3
- package/{dist → dist-types}/db/schema/index.d.ts +862 -33
- package/{dist → dist-types}/db/tenant-scope.d.ts +0 -1
- package/{dist → dist-types}/define-config.d.ts +0 -1
- package/dist-types/edge/index.d.ts +5 -0
- package/dist-types/edge/init-handler.d.ts +38 -0
- package/dist-types/edge/resolve-consent.d.ts +80 -0
- package/dist-types/edge/types.d.ts +13 -0
- package/{dist → dist-types}/handlers/consent/check.handler.d.ts +0 -1
- package/{src/handlers/consent/index.ts → dist-types/handlers/consent/index.d.ts} +0 -1
- package/{dist → dist-types}/handlers/init/geo.d.ts +2 -3
- package/{dist → dist-types}/handlers/init/index.d.ts +4 -5
- package/dist-types/handlers/init/policy.d.ts +26 -0
- package/dist-types/handlers/init/resolve-init.d.ts +44 -0
- package/dist-types/handlers/init/translations.d.ts +48 -0
- package/dist-types/handlers/policy/snapshot.d.ts +99 -0
- package/{src/handlers/status/index.ts → dist-types/handlers/status/index.d.ts} +0 -1
- package/{dist → dist-types}/handlers/status/status.handler.d.ts +0 -1
- package/{dist → dist-types}/handlers/subject/get.handler.d.ts +0 -1
- package/{src/handlers/subject/index.ts → dist-types/handlers/subject/index.d.ts} +0 -1
- package/{dist → dist-types}/handlers/subject/list.handler.d.ts +0 -1
- package/{dist → dist-types}/handlers/subject/patch.handler.d.ts +0 -1
- package/{dist → dist-types}/handlers/subject/post.handler.d.ts +12 -1
- package/{dist → dist-types}/handlers/utils/consent-enrichment.d.ts +0 -1
- package/{dist → dist-types}/init.d.ts +0 -1
- package/{dist → dist-types}/middleware/auth/index.d.ts +0 -1
- package/{dist → dist-types}/middleware/auth/validate-api-key.d.ts +0 -1
- package/{dist → dist-types}/middleware/cors/cors.d.ts +0 -1
- package/{src/middleware/cors/index.ts → dist-types/middleware/cors/index.d.ts} +0 -1
- package/{dist → dist-types}/middleware/cors/is-origin-trusted.d.ts +1 -2
- package/{dist → dist-types}/middleware/cors/process-cors.d.ts +0 -1
- package/{dist → dist-types}/middleware/openapi/config.d.ts +0 -1
- package/{dist → dist-types}/middleware/openapi/handlers.d.ts +0 -1
- package/{src/middleware/openapi/index.ts → dist-types/middleware/openapi/index.d.ts} +0 -1
- package/{dist → dist-types}/middleware/process-ip/index.d.ts +0 -1
- package/dist-types/policies/builder.d.ts +127 -0
- package/dist-types/policies/defaults.d.ts +2 -0
- package/dist-types/policies/matchers.d.ts +3 -0
- package/{dist → dist-types}/router.d.ts +0 -1
- package/{dist → dist-types}/routes/consent.d.ts +0 -1
- package/{src/routes/index.ts → dist-types/routes/index.d.ts} +0 -1
- package/{dist → dist-types}/routes/init.d.ts +0 -1
- package/{dist → dist-types}/routes/status.d.ts +0 -1
- package/{dist → dist-types}/routes/subject.d.ts +0 -1
- package/{dist → dist-types}/types/api.d.ts +0 -1
- package/{dist → dist-types}/types/index.d.ts +110 -6
- package/dist-types/utils/background.d.ts +6 -0
- package/{dist → dist-types}/utils/create-telemetry-options.d.ts +0 -1
- package/{dist → dist-types}/utils/env.d.ts +0 -1
- package/{dist → dist-types}/utils/extract-error-message.d.ts +0 -1
- package/{dist → dist-types}/utils/instrumentation.d.ts +0 -1
- package/{dist → dist-types}/utils/logger.d.ts +1 -2
- package/{dist → dist-types}/utils/metrics.d.ts +0 -1
- package/dist-types/version.d.ts +1 -0
- package/docs/README.md +49 -0
- package/docs/api/configuration.md +197 -0
- package/docs/api/endpoints.md +211 -0
- package/docs/guides/caching.md +85 -0
- package/docs/guides/database-setup.md +128 -0
- package/docs/guides/edge-deployment.md +248 -0
- package/docs/guides/framework-integration.md +142 -0
- package/docs/guides/iab-tcf.md +89 -0
- package/docs/guides/observability.md +96 -0
- package/docs/guides/policy-packs.md +396 -0
- package/docs/quickstart.md +129 -0
- package/package.json +45 -31
- package/.turbo/turbo-build.log +0 -49
- package/CHANGELOG.md +0 -123
- package/dist/cache/adapters/cloudflare-kv.d.ts.map +0 -1
- package/dist/cache/adapters/index.d.ts.map +0 -1
- package/dist/cache/adapters/memory.d.ts.map +0 -1
- package/dist/cache/adapters/upstash-redis.d.ts.map +0 -1
- package/dist/cache/gvl-resolver.d.ts.map +0 -1
- package/dist/cache/index.d.ts.map +0 -1
- package/dist/cache/keys.d.ts.map +0 -1
- package/dist/cache/types.d.ts.map +0 -1
- package/dist/core.d.ts.map +0 -1
- package/dist/db/adapters/drizzle.d.ts +0 -2
- package/dist/db/adapters/drizzle.d.ts.map +0 -1
- package/dist/db/adapters/index.d.ts +0 -2
- package/dist/db/adapters/index.d.ts.map +0 -1
- package/dist/db/adapters/kysely.d.ts +0 -2
- package/dist/db/adapters/kysely.d.ts.map +0 -1
- package/dist/db/adapters/mongo.d.ts +0 -2
- package/dist/db/adapters/mongo.d.ts.map +0 -1
- package/dist/db/adapters/prisma.d.ts +0 -2
- package/dist/db/adapters/prisma.d.ts.map +0 -1
- package/dist/db/adapters/typeorm.d.ts +0 -2
- package/dist/db/adapters/typeorm.d.ts.map +0 -1
- package/dist/db/migrator/index.d.ts.map +0 -1
- package/dist/db/registry/consent-policy.d.ts.map +0 -1
- package/dist/db/registry/consent-purpose.d.ts.map +0 -1
- package/dist/db/registry/domain.d.ts.map +0 -1
- package/dist/db/registry/index.d.ts.map +0 -1
- package/dist/db/registry/subject.d.ts.map +0 -1
- package/dist/db/registry/types.d.ts.map +0 -1
- package/dist/db/registry/utils/generate-id.d.ts.map +0 -1
- package/dist/db/registry/utils.d.ts.map +0 -1
- package/dist/db/schema/1.0.0/audit-log.d.ts.map +0 -1
- package/dist/db/schema/1.0.0/consent-policy.d.ts.map +0 -1
- package/dist/db/schema/1.0.0/consent-purpose.d.ts.map +0 -1
- package/dist/db/schema/1.0.0/consent-record.d.ts.map +0 -1
- package/dist/db/schema/1.0.0/consent.d.ts.map +0 -1
- package/dist/db/schema/1.0.0/domain.d.ts.map +0 -1
- package/dist/db/schema/1.0.0/index.d.ts.map +0 -1
- package/dist/db/schema/1.0.0/subject.d.ts.map +0 -1
- package/dist/db/schema/2.0.0/audit-log.d.ts.map +0 -1
- package/dist/db/schema/2.0.0/consent-policy.d.ts.map +0 -1
- package/dist/db/schema/2.0.0/consent-purpose.d.ts.map +0 -1
- package/dist/db/schema/2.0.0/consent.d.ts.map +0 -1
- package/dist/db/schema/2.0.0/domain.d.ts.map +0 -1
- package/dist/db/schema/2.0.0/index.d.ts.map +0 -1
- package/dist/db/schema/2.0.0/subject.d.ts.map +0 -1
- package/dist/db/schema/index.d.ts.map +0 -1
- package/dist/db/tenant-scope.d.ts.map +0 -1
- package/dist/define-config.d.ts.map +0 -1
- package/dist/handlers/consent/check.handler.d.ts.map +0 -1
- package/dist/handlers/consent/index.d.ts +0 -12
- package/dist/handlers/consent/index.d.ts.map +0 -1
- package/dist/handlers/init/geo.d.ts.map +0 -1
- package/dist/handlers/init/index.d.ts.map +0 -1
- package/dist/handlers/init/translations.d.ts +0 -26
- package/dist/handlers/init/translations.d.ts.map +0 -1
- package/dist/handlers/status/index.d.ts +0 -7
- package/dist/handlers/status/index.d.ts.map +0 -1
- package/dist/handlers/status/status.handler.d.ts.map +0 -1
- package/dist/handlers/subject/get.handler.d.ts.map +0 -1
- package/dist/handlers/subject/index.d.ts +0 -10
- package/dist/handlers/subject/index.d.ts.map +0 -1
- package/dist/handlers/subject/list.handler.d.ts.map +0 -1
- package/dist/handlers/subject/patch.handler.d.ts.map +0 -1
- package/dist/handlers/subject/post.handler.d.ts.map +0 -1
- package/dist/handlers/utils/consent-enrichment.d.ts.map +0 -1
- package/dist/init.d.ts.map +0 -1
- package/dist/middleware/auth/index.d.ts.map +0 -1
- package/dist/middleware/auth/validate-api-key.d.ts.map +0 -1
- package/dist/middleware/cors/cors.d.ts.map +0 -1
- package/dist/middleware/cors/index.d.ts +0 -30
- package/dist/middleware/cors/index.d.ts.map +0 -1
- package/dist/middleware/cors/is-origin-trusted.d.ts.map +0 -1
- package/dist/middleware/cors/process-cors.d.ts.map +0 -1
- package/dist/middleware/openapi/config.d.ts.map +0 -1
- package/dist/middleware/openapi/handlers.d.ts.map +0 -1
- package/dist/middleware/openapi/index.d.ts +0 -12
- package/dist/middleware/openapi/index.d.ts.map +0 -1
- package/dist/middleware/process-ip/index.d.ts.map +0 -1
- package/dist/router.d.ts.map +0 -1
- package/dist/routes/consent.d.ts.map +0 -1
- package/dist/routes/index.d.ts +0 -10
- package/dist/routes/index.d.ts.map +0 -1
- package/dist/routes/init.d.ts.map +0 -1
- package/dist/routes/status.d.ts.map +0 -1
- package/dist/routes/subject.d.ts.map +0 -1
- package/dist/types/api.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/utils/create-telemetry-options.d.ts.map +0 -1
- package/dist/utils/env.d.ts.map +0 -1
- package/dist/utils/extract-error-message.d.ts.map +0 -1
- package/dist/utils/index.d.ts +0 -4
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/instrumentation.d.ts.map +0 -1
- package/dist/utils/logger.d.ts.map +0 -1
- package/dist/utils/metrics.d.ts.map +0 -1
- package/dist/version.d.ts +0 -2
- package/dist/version.d.ts.map +0 -1
- package/knip.json +0 -31
- package/rslib.config.ts +0 -93
- package/src/cache/adapters/cloudflare-kv.ts +0 -71
- package/src/cache/adapters/index.ts +0 -22
- package/src/cache/adapters/memory.ts +0 -111
- package/src/cache/adapters/upstash-redis.ts +0 -113
- package/src/cache/gvl-resolver.ts +0 -289
- package/src/cache/index.ts +0 -34
- package/src/cache/keys.ts +0 -68
- package/src/cache/types.ts +0 -66
- package/src/core.ts +0 -369
- package/src/db/migrator/index.ts +0 -80
- package/src/db/registry/consent-policy.test.ts +0 -451
- package/src/db/registry/consent-policy.ts +0 -82
- package/src/db/registry/consent-purpose.test.ts +0 -428
- package/src/db/registry/consent-purpose.ts +0 -61
- package/src/db/registry/domain.test.ts +0 -445
- package/src/db/registry/domain.ts +0 -91
- package/src/db/registry/index.ts +0 -14
- package/src/db/registry/subject.test.ts +0 -371
- package/src/db/registry/subject.ts +0 -126
- package/src/db/registry/types.ts +0 -10
- package/src/db/registry/utils/generate-id.test.ts +0 -216
- package/src/db/registry/utils/generate-id.ts +0 -133
- package/src/db/registry/utils.ts +0 -133
- package/src/db/schema/1.0.0/audit-log.ts +0 -15
- package/src/db/schema/1.0.0/consent-policy.ts +0 -14
- package/src/db/schema/1.0.0/consent-purpose.ts +0 -14
- package/src/db/schema/1.0.0/consent-record.ts +0 -10
- package/src/db/schema/1.0.0/consent.ts +0 -20
- package/src/db/schema/1.0.0/domain.ts +0 -12
- package/src/db/schema/1.0.0/index.ts +0 -48
- package/src/db/schema/1.0.0/subject.ts +0 -11
- package/src/db/schema/2.0.0/audit-log.ts +0 -18
- package/src/db/schema/2.0.0/consent-policy.ts +0 -28
- package/src/db/schema/2.0.0/consent-purpose.ts +0 -12
- package/src/db/schema/2.0.0/consent.ts +0 -28
- package/src/db/schema/2.0.0/domain.ts +0 -12
- package/src/db/schema/2.0.0/index.ts +0 -47
- package/src/db/schema/2.0.0/subject.ts +0 -13
- package/src/db/schema/index.ts +0 -15
- package/src/db/tenant-scope.test.ts +0 -747
- package/src/db/tenant-scope.ts +0 -103
- package/src/define-config.ts +0 -19
- package/src/handlers/consent/check.handler.ts +0 -126
- package/src/handlers/init/geo.test.ts +0 -317
- package/src/handlers/init/geo.ts +0 -195
- package/src/handlers/init/index.test.ts +0 -205
- package/src/handlers/init/index.ts +0 -114
- package/src/handlers/init/translations.test.ts +0 -121
- package/src/handlers/init/translations.ts +0 -69
- package/src/handlers/status/status.handler.test.ts +0 -155
- package/src/handlers/status/status.handler.ts +0 -51
- package/src/handlers/subject/get.handler.ts +0 -92
- package/src/handlers/subject/list.handler.ts +0 -92
- package/src/handlers/subject/patch.handler.ts +0 -119
- package/src/handlers/subject/post.handler.test.ts +0 -294
- package/src/handlers/subject/post.handler.ts +0 -268
- package/src/handlers/utils/consent-enrichment.test.ts +0 -380
- package/src/handlers/utils/consent-enrichment.ts +0 -218
- package/src/init.test.ts +0 -122
- package/src/init.ts +0 -88
- package/src/middleware/auth/index.ts +0 -11
- package/src/middleware/auth/validate-api-key.test.ts +0 -86
- package/src/middleware/auth/validate-api-key.ts +0 -107
- package/src/middleware/cors/cors.test.ts +0 -135
- package/src/middleware/cors/cors.ts +0 -186
- package/src/middleware/cors/is-origin-trusted.test.ts +0 -164
- package/src/middleware/cors/is-origin-trusted.ts +0 -130
- package/src/middleware/cors/process-cors.ts +0 -91
- package/src/middleware/openapi/config.ts +0 -29
- package/src/middleware/openapi/handlers.ts +0 -34
- package/src/middleware/process-ip/index.test.ts +0 -193
- package/src/middleware/process-ip/index.ts +0 -199
- package/src/router.ts +0 -15
- package/src/routes/consent.ts +0 -52
- package/src/routes/init.ts +0 -105
- package/src/routes/status.ts +0 -46
- package/src/routes/subject.ts +0 -152
- package/src/types/api.ts +0 -48
- package/src/types/index.ts +0 -391
- package/src/utils/create-telemetry-options.test.ts +0 -286
- package/src/utils/create-telemetry-options.ts +0 -229
- package/src/utils/env.ts +0 -84
- package/src/utils/extract-error-message.ts +0 -21
- package/src/utils/instrumentation.test.ts +0 -183
- package/src/utils/instrumentation.ts +0 -194
- package/src/utils/logger.ts +0 -41
- package/src/utils/metrics.test.ts +0 -311
- package/src/utils/metrics.ts +0 -402
- package/src/utils/telemetry-pii.test.ts +0 -323
- package/src/version.ts +0 -2
- package/tsconfig.json +0 -11
- package/vitest.config.ts +0 -28
- /package/{src/db/adapters/drizzle.ts → dist-types/db/adapters/drizzle.d.ts} +0 -0
- /package/{src/db/adapters/index.ts → dist-types/db/adapters/index.d.ts} +0 -0
- /package/{src/db/adapters/kysely.ts → dist-types/db/adapters/kysely.d.ts} +0 -0
- /package/{src/db/adapters/mongo.ts → dist-types/db/adapters/mongo.d.ts} +0 -0
- /package/{src/db/adapters/prisma.ts → dist-types/db/adapters/prisma.d.ts} +0 -0
- /package/{src/db/adapters/typeorm.ts → dist-types/db/adapters/typeorm.d.ts} +0 -0
- /package/{src/utils/index.ts → dist-types/utils/index.d.ts} +0 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import type { PolicyConfig, PolicyModel, PolicyScopeMode, PolicyUiMode, PolicyUiSurfaceConfig } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* High-level builder input for creating a backend policy config.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* This shape is intentionally flatter than {@link PolicyConfig} so backend
|
|
7
|
+
* configuration stays readable in `c15tInstance({ policyPacks })` setup files.
|
|
8
|
+
* Use the builder helpers to normalize this input into runtime-ready policy
|
|
9
|
+
* configs.
|
|
10
|
+
*
|
|
11
|
+
* @see {@link https://v2.c15t.com/docs/self-host/guides/policy-packs}
|
|
12
|
+
* @see {@link https://v2.c15t.com/docs/frameworks/react/concepts/policy-packs}
|
|
13
|
+
*/
|
|
14
|
+
export interface PolicyBuilderInput {
|
|
15
|
+
id: string;
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated Metadata-only label. Not used at runtime, not sent to clients,
|
|
18
|
+
* and not fingerprinted. Will be removed in a future version.
|
|
19
|
+
*/
|
|
20
|
+
name?: string;
|
|
21
|
+
countries?: string[];
|
|
22
|
+
regions?: Array<{
|
|
23
|
+
country: string;
|
|
24
|
+
region: string;
|
|
25
|
+
}>;
|
|
26
|
+
isDefault?: boolean;
|
|
27
|
+
model?: PolicyModel;
|
|
28
|
+
expiryDays?: number;
|
|
29
|
+
scopeMode?: PolicyScopeMode;
|
|
30
|
+
/**
|
|
31
|
+
* Consent categories scoped by the policy.
|
|
32
|
+
*/
|
|
33
|
+
categories?: string[];
|
|
34
|
+
preselectedCategories?: string[];
|
|
35
|
+
/**
|
|
36
|
+
* Whether the policy should respect the Global Privacy Control signal.
|
|
37
|
+
*/
|
|
38
|
+
gpc?: boolean;
|
|
39
|
+
uiMode?: PolicyUiMode;
|
|
40
|
+
banner?: PolicyUiSurfaceConfig;
|
|
41
|
+
dialog?: PolicyUiSurfaceConfig;
|
|
42
|
+
i18n?: {
|
|
43
|
+
language?: string;
|
|
44
|
+
messageProfile?: string;
|
|
45
|
+
};
|
|
46
|
+
proof?: {
|
|
47
|
+
storeIp?: boolean;
|
|
48
|
+
storeUserAgent?: boolean;
|
|
49
|
+
storeLanguage?: boolean;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Converts a single {@link PolicyBuilderInput} into a normalized
|
|
54
|
+
* backend-compatible {@link PolicyConfig}.
|
|
55
|
+
*
|
|
56
|
+
* @remarks
|
|
57
|
+
* Empty optional fields are removed from the final output, matcher input is
|
|
58
|
+
* merged into `match`, and duplicate string arrays are deduplicated.
|
|
59
|
+
*
|
|
60
|
+
* @see {@link https://v2.c15t.com/docs/self-host/guides/policy-packs}
|
|
61
|
+
*/
|
|
62
|
+
export declare function buildPolicyConfig(input: PolicyBuilderInput): PolicyConfig;
|
|
63
|
+
/**
|
|
64
|
+
* Converts an ordered list of builder inputs into a policy pack.
|
|
65
|
+
*
|
|
66
|
+
* @remarks
|
|
67
|
+
* The resulting array preserves input order. That order matters because
|
|
68
|
+
* duplicate region/country matchers use first-match-wins semantics within the
|
|
69
|
+
* same matcher type.
|
|
70
|
+
*
|
|
71
|
+
* @see {@link https://v2.c15t.com/docs/self-host/guides/policy-packs}
|
|
72
|
+
*/
|
|
73
|
+
export declare function buildPolicyPack(inputs: PolicyBuilderInput[]): PolicyConfig[];
|
|
74
|
+
/**
|
|
75
|
+
* Creates a policy pack and guarantees that it ends with a default policy.
|
|
76
|
+
*
|
|
77
|
+
* @remarks
|
|
78
|
+
* If the provided inputs already contain a default matcher, the pack is
|
|
79
|
+
* returned unchanged. Otherwise c15t appends either:
|
|
80
|
+
*
|
|
81
|
+
* - the supplied `defaultPolicy`, coerced to `match.isDefault = true`
|
|
82
|
+
* - or the built-in "World No Banner" fallback
|
|
83
|
+
*
|
|
84
|
+
* When `defaultPolicy` is provided, its `countries` and `regions` fields are
|
|
85
|
+
* stripped and replaced with `match.isDefault = true`.
|
|
86
|
+
*
|
|
87
|
+
* @see {@link https://v2.c15t.com/docs/self-host/guides/policy-packs}
|
|
88
|
+
*/
|
|
89
|
+
export declare function buildPolicyPackWithDefault(inputs: PolicyBuilderInput[], defaultPolicy?: PolicyBuilderInput): PolicyConfig[];
|
|
90
|
+
/**
|
|
91
|
+
* Merges multiple policy packs or individual policies into a single pack.
|
|
92
|
+
*
|
|
93
|
+
* @remarks
|
|
94
|
+
* Useful for combining preset packs with custom policies without manual
|
|
95
|
+
* spread and deduplication. Policies are deduplicated by `id` — the first
|
|
96
|
+
* occurrence wins.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```ts
|
|
100
|
+
* import { composePacks, policyPackPresets, policyBuilder } from '@c15t/backend';
|
|
101
|
+
*
|
|
102
|
+
* const pack = composePacks(
|
|
103
|
+
* [policyPackPresets.europeOptIn()],
|
|
104
|
+
* [policyPackPresets.californiaOptOut()],
|
|
105
|
+
* [policyBuilder.create({ id: 'custom', countries: ['JP'], model: 'opt-in' })],
|
|
106
|
+
* [policyPackPresets.worldNoBanner()],
|
|
107
|
+
* );
|
|
108
|
+
* ```
|
|
109
|
+
*
|
|
110
|
+
* @see {@link https://v2.c15t.com/docs/self-host/guides/policy-packs}
|
|
111
|
+
*/
|
|
112
|
+
export declare function composePacks(...packs: PolicyConfig[][]): PolicyConfig[];
|
|
113
|
+
/**
|
|
114
|
+
* Convenience namespace for the policy builder helpers.
|
|
115
|
+
*
|
|
116
|
+
* @remarks
|
|
117
|
+
* Useful when you prefer a grouped API such as `policyBuilder.createPack()`
|
|
118
|
+
* inside backend config files.
|
|
119
|
+
*
|
|
120
|
+
* @see {@link https://v2.c15t.com/docs/self-host/guides/policy-packs}
|
|
121
|
+
*/
|
|
122
|
+
export declare const policyBuilder: {
|
|
123
|
+
create: typeof buildPolicyConfig;
|
|
124
|
+
createPack: typeof buildPolicyPack;
|
|
125
|
+
createPackWithDefault: typeof buildPolicyPackWithDefault;
|
|
126
|
+
composePacks: typeof composePacks;
|
|
127
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { createLogger, LoggerOptions } from '
|
|
2
|
-
import { type Branding, type GlobalVendorList, type NonIABVendor } from '
|
|
3
|
-
import type { Translations } from '
|
|
1
|
+
import type { createLogger, LoggerOptions } from '../../../logger/dist-types/index.d.ts';
|
|
2
|
+
import { type Branding, type GlobalVendorList, type NonIABVendor, type PolicyConfig } from '../../../schema/dist-types/types';
|
|
3
|
+
import type { Translations } from '../../../translations/dist-types/index.d.ts';
|
|
4
4
|
import type { Meter, Tracer } from '@opentelemetry/api';
|
|
5
5
|
import type { FumaDB, InferFumaDB } from 'fumadb';
|
|
6
6
|
import type { CacheAdapter } from '../cache/types';
|
|
@@ -141,7 +141,9 @@ export interface CacheOptions {
|
|
|
141
141
|
export interface IABOptions {
|
|
142
142
|
/**
|
|
143
143
|
* Enable IAB TCF support.
|
|
144
|
-
* When false or not provided, /init
|
|
144
|
+
* When false or not provided, /init does not include IAB payload fields.
|
|
145
|
+
* When true, /init includes IAB payload only when IAB is active for the
|
|
146
|
+
* resolved request policy (or when no policies are configured).
|
|
145
147
|
*/
|
|
146
148
|
enabled: true;
|
|
147
149
|
/**
|
|
@@ -197,6 +199,84 @@ export interface IABOptions {
|
|
|
197
199
|
customVendors?: NonIABVendor[];
|
|
198
200
|
}
|
|
199
201
|
type FumaDBSchema = InferFumaDB<typeof DB>['schemas'];
|
|
202
|
+
export interface I18nMessageProfile {
|
|
203
|
+
/**
|
|
204
|
+
* Fallback language used when the requested language is not configured in
|
|
205
|
+
* this profile.
|
|
206
|
+
*
|
|
207
|
+
* @remarks
|
|
208
|
+
* This does not expand the profile's allowed languages. If the configured
|
|
209
|
+
* fallback is not present in the profile, c15t falls back to English when
|
|
210
|
+
* available, otherwise to the first configured language in the profile.
|
|
211
|
+
*
|
|
212
|
+
* @default "en"
|
|
213
|
+
*/
|
|
214
|
+
fallbackLanguage?: string;
|
|
215
|
+
/**
|
|
216
|
+
* Translation overrides keyed by language code.
|
|
217
|
+
*/
|
|
218
|
+
translations: Record<string, Partial<Translations>>;
|
|
219
|
+
}
|
|
220
|
+
export type I18nMessageProfiles = Record<string, I18nMessageProfile>;
|
|
221
|
+
export interface I18nOptions {
|
|
222
|
+
/**
|
|
223
|
+
* Named translation catalogs grouped by profile.
|
|
224
|
+
*
|
|
225
|
+
* @example
|
|
226
|
+
* ```ts
|
|
227
|
+
* i18n: {
|
|
228
|
+
* messages: {
|
|
229
|
+
* default: {
|
|
230
|
+
* translations: { en: { cookieBanner: { title: '...' } } },
|
|
231
|
+
* },
|
|
232
|
+
* us_ca: {
|
|
233
|
+
* fallbackLanguage: 'en',
|
|
234
|
+
* translations: { en: { cookieBanner: { title: '...' } } },
|
|
235
|
+
* },
|
|
236
|
+
* }
|
|
237
|
+
* }
|
|
238
|
+
* ```
|
|
239
|
+
*/
|
|
240
|
+
messages?: I18nMessageProfiles;
|
|
241
|
+
/**
|
|
242
|
+
* Fallback profile used when a policy does not provide `messageProfile`.
|
|
243
|
+
* @default "default"
|
|
244
|
+
*/
|
|
245
|
+
defaultProfile?: string;
|
|
246
|
+
}
|
|
247
|
+
export type { PolicyConfig, PolicyModel, PolicyPack, PolicyScopeMode, PolicyUiAction, PolicyUiActionDirection, PolicyUiActionGroup, PolicyUiMode, PolicyUiProfile, PolicyUiSurfaceConfig, } from '../../../schema/dist-types/types';
|
|
248
|
+
export interface PolicySnapshotOptions {
|
|
249
|
+
/**
|
|
250
|
+
* Secret used for signing and verifying policy snapshot tokens.
|
|
251
|
+
*/
|
|
252
|
+
signingKey: string;
|
|
253
|
+
/**
|
|
254
|
+
* How writes should behave when snapshot validation fails.
|
|
255
|
+
* @default "reject"
|
|
256
|
+
*/
|
|
257
|
+
onValidationFailure?: 'reject' | 'resolve_current';
|
|
258
|
+
/**
|
|
259
|
+
* JWT issuer claim for snapshot tokens.
|
|
260
|
+
* @default "c15t"
|
|
261
|
+
*/
|
|
262
|
+
issuer?: string;
|
|
263
|
+
/**
|
|
264
|
+
* JWT audience claim for snapshot tokens.
|
|
265
|
+
* When omitted, c15t derives a default snapshot audience and scopes it per tenant.
|
|
266
|
+
*/
|
|
267
|
+
audience?: string;
|
|
268
|
+
/**
|
|
269
|
+
* Snapshot token lifetime in seconds.
|
|
270
|
+
* @default 1800 (30 minutes)
|
|
271
|
+
*/
|
|
272
|
+
ttlSeconds?: number;
|
|
273
|
+
}
|
|
274
|
+
export interface BackgroundOptions {
|
|
275
|
+
/**
|
|
276
|
+
* Executes non-critical tasks after the response path has completed.
|
|
277
|
+
*/
|
|
278
|
+
run: (task: () => Promise<void>) => void;
|
|
279
|
+
}
|
|
200
280
|
export interface C15TOptions {
|
|
201
281
|
/**
|
|
202
282
|
* The database adapter to use.
|
|
@@ -254,6 +334,8 @@ export interface C15TOptions {
|
|
|
254
334
|
/**
|
|
255
335
|
* Override base translations.
|
|
256
336
|
*
|
|
337
|
+
* @deprecated Use `i18n.messages` instead. This alias is kept for compatibility.
|
|
338
|
+
*
|
|
257
339
|
* @example
|
|
258
340
|
* ```ts
|
|
259
341
|
* {
|
|
@@ -263,6 +345,21 @@ export interface C15TOptions {
|
|
|
263
345
|
* ```
|
|
264
346
|
*/
|
|
265
347
|
customTranslations?: Record<string, Partial<Translations>>;
|
|
348
|
+
/**
|
|
349
|
+
* Internationalization message profiles used by runtime policies.
|
|
350
|
+
*/
|
|
351
|
+
i18n?: I18nOptions;
|
|
352
|
+
/**
|
|
353
|
+
* Runtime regional policy pack resolved per request.
|
|
354
|
+
*
|
|
355
|
+
* @remarks
|
|
356
|
+
* Omit this field to keep legacy non-policy behavior. Pass `[]` to force
|
|
357
|
+
* explicit no-banner mode. In production, prefer including a default policy
|
|
358
|
+
* so unmatched traffic still resolves deterministically.
|
|
359
|
+
*
|
|
360
|
+
* @see {@link https://v2.c15t.com/docs/self-host/guides/policy-packs}
|
|
361
|
+
*/
|
|
362
|
+
policyPacks?: PolicyConfig[];
|
|
266
363
|
/**
|
|
267
364
|
* Select which branding to show in the consent banner.
|
|
268
365
|
* Use "none" to hide branding.
|
|
@@ -314,8 +411,16 @@ export interface C15TOptions {
|
|
|
314
411
|
* @see {@link https://v2.c15t.com/docs/self-host/guides/iab-tcf}
|
|
315
412
|
*/
|
|
316
413
|
iab?: IABOptions;
|
|
414
|
+
/**
|
|
415
|
+
* Optional signed policy snapshots used to keep /init and /subjects consistent.
|
|
416
|
+
*/
|
|
417
|
+
policySnapshot?: PolicySnapshotOptions;
|
|
418
|
+
/**
|
|
419
|
+
* Optional background task runner for non-critical side effects.
|
|
420
|
+
*/
|
|
421
|
+
background?: BackgroundOptions;
|
|
317
422
|
}
|
|
318
|
-
export interface C15TContext extends Omit<C15TOptions, 'ipAddress' | 'adapter' | 'logger' | 'tablePrefix'
|
|
423
|
+
export interface C15TContext extends Omit<C15TOptions, 'ipAddress' | 'adapter' | 'logger' | 'tablePrefix'> {
|
|
319
424
|
appName: string;
|
|
320
425
|
logger: ReturnType<typeof createLogger>;
|
|
321
426
|
registry: ReturnType<typeof createRegistry>;
|
|
@@ -336,4 +441,3 @@ export interface C15TContext extends Omit<C15TOptions, 'ipAddress' | 'adapter' |
|
|
|
336
441
|
export type DeepPartial<T> = T extends (...args: unknown[]) => unknown ? T : T extends object ? {
|
|
337
442
|
[K in keyof T]?: DeepPartial<T[K]>;
|
|
338
443
|
} : T;
|
|
339
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { C15TContext } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Executes non-critical work via configured background runner when available.
|
|
4
|
+
* Falls back to fire-and-forget local execution.
|
|
5
|
+
*/
|
|
6
|
+
export declare function runInBackground(ctx: C15TContext, task: () => Promise<void>): void;
|
|
@@ -67,4 +67,3 @@ export declare function withExternalSpan<T>(attributes: ExternalSpanAttributes,
|
|
|
67
67
|
* @returns The result of the operation
|
|
68
68
|
*/
|
|
69
69
|
export declare function withCacheSpan<T>(operation: 'get' | 'set' | 'delete', layer: 'bundled' | 'memory' | 'external', fn: () => Promise<T>, options?: C15TOptions): Promise<T>;
|
|
70
|
-
//# sourceMappingURL=instrumentation.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createLogger, type LoggerOptions } from '
|
|
1
|
+
import { createLogger, type LoggerOptions } from '../../../logger/dist-types/index.d.ts';
|
|
2
2
|
/**
|
|
3
3
|
* Gets or creates a global logger instance
|
|
4
4
|
*
|
|
@@ -13,4 +13,3 @@ export declare function getLogger(options?: LoggerOptions): ReturnType<typeof cr
|
|
|
13
13
|
* @returns The initialized global logger instance
|
|
14
14
|
*/
|
|
15
15
|
export declare function initLogger(options: LoggerOptions): ReturnType<typeof createLogger>;
|
|
16
|
-
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const version = "2.0.0-rc.6";
|
package/docs/README.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# c15t Backend Docs
|
|
2
|
+
|
|
3
|
+
Self-hosted c15t backend docs for configuration, policy packs, APIs, and operational behavior.
|
|
4
|
+
|
|
5
|
+
If you are changing consent flows, consent UI, script loading, server-side setup, or backend configuration in an app that uses this package, start here before editing code.
|
|
6
|
+
|
|
7
|
+
## Start Here
|
|
8
|
+
|
|
9
|
+
- [Quickstart](./quickstart.md)
|
|
10
|
+
- [Database Setup](./guides/database-setup.md)
|
|
11
|
+
- [Policy Packs](./guides/policy-packs.md)
|
|
12
|
+
- [Configuration](./api/configuration.md)
|
|
13
|
+
|
|
14
|
+
## Workflow Rules
|
|
15
|
+
|
|
16
|
+
### Database & Initial Setup
|
|
17
|
+
|
|
18
|
+
Use this when:
|
|
19
|
+
- configuring a self-hosted backend
|
|
20
|
+
- choosing adapters or initial backend wiring
|
|
21
|
+
|
|
22
|
+
Prefer:
|
|
23
|
+
- Start with the documented database setup guide.
|
|
24
|
+
- Prefer the documented adapter and setup path before custom backend wiring.
|
|
25
|
+
|
|
26
|
+
If that is not enough:
|
|
27
|
+
- Use the API reference when you need exact option-level behavior.
|
|
28
|
+
|
|
29
|
+
Read next:
|
|
30
|
+
- [Quickstart](./quickstart.md)
|
|
31
|
+
- [Database Setup](./guides/database-setup.md)
|
|
32
|
+
- [Configuration](./api/configuration.md)
|
|
33
|
+
|
|
34
|
+
### Policy Packs & Regional Behavior
|
|
35
|
+
|
|
36
|
+
Use this when:
|
|
37
|
+
- configuring region-aware consent behavior
|
|
38
|
+
- deciding whether logic belongs in backend policy config or frontend code
|
|
39
|
+
|
|
40
|
+
Prefer:
|
|
41
|
+
- Prefer policy-pack and documented backend configuration over frontend-only regional logic.
|
|
42
|
+
- Keep consent behavior centralized in backend policy configuration where possible.
|
|
43
|
+
|
|
44
|
+
Avoid:
|
|
45
|
+
- Do not scatter policy decisions across client code when the backend can own them.
|
|
46
|
+
|
|
47
|
+
Read next:
|
|
48
|
+
- [Policy Packs](./guides/policy-packs.md)
|
|
49
|
+
- [Configuration](./api/configuration.md)
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Configuration Reference
|
|
3
|
+
description: Complete reference for all c15t backend configuration options.
|
|
4
|
+
---
|
|
5
|
+
All options are passed to `c15tInstance()`. Only `adapter` and `trustedOrigins` are required.
|
|
6
|
+
|
|
7
|
+
## Options
|
|
8
|
+
|
|
9
|
+
### C15TOptions
|
|
10
|
+
|
|
11
|
+
|Property|Type|Description|Default|Required|
|
|
12
|
+
|:--|:--|:--|:--|:--:|
|
|
13
|
+
|adapter|[FumaDBAdapter](https://v2.c15t.com/docs/self-host/guides/database-setup)|The database adapter to use.|-|✅ Required|
|
|
14
|
+
|tenantId|string \|undefined|Tenant ID for multi-tenant deployments. When set, all database queries are automatically scoped to this tenant.|-|Optional|
|
|
15
|
+
|tablePrefix|[string \|undefined](https://v2.c15t.com/docs/self-host/guides/database-setup)|Optional prefix for all database table names. Useful when sharing a database with other applications to avoid naming conflicts.|-|Optional|
|
|
16
|
+
|appName|[string \|undefined](https://v2.c15t.com/docs/self-host/api/configuration)|Application name used as backend metadata and identity. Returned by \`/init\` (\`appName\`), used in logs, telemetry defaults (\`service.name\`), and cache key prefixing.|"c15t"|Optional|
|
|
17
|
+
|basePath|[string \|undefined](https://v2.c15t.com/docs/self-host/api/endpoints)|Base path prefix for all API routes (e.g. \`/api/self-host\`).|-|Optional|
|
|
18
|
+
|trustedOrigins|[string\[\]](https://v2.c15t.com/docs/self-host/api/configuration)|Allowed origins for CORS. Required for browser-based consent collection. Protocol is optional; matching is protocol-agnostic and normalized.|-|✅ Required|
|
|
19
|
+
|logger|LoggerOptions \|undefined|Logger configuration.|-|Optional|
|
|
20
|
+
|disableGeoLocation|boolean \|undefined|Disables the use of Geo Location to determine the jurisdiction. When enabled, the jurisdiction will be set to "GDPR" to show the strictest version of the banner as we don't know the jurisdiction in this case.|false|Optional|
|
|
21
|
+
|customTranslations|Record\<string, Partial\<Translations>> \|undefined|Override base translations.|-|Optional|
|
|
22
|
+
|i18n|I18nOptions \|undefined|Internationalization message profiles used by runtime policies.|-|Optional|
|
|
23
|
+
|policyPacks|[PolicyConfig \|undefined](https://v2.c15t.com/docs/self-host/guides/policy-packs)|Runtime regional policy pack resolved per request.|-|Optional|
|
|
24
|
+
|branding|"c15t" \|"consent" \|"none" \|undefined|Select which branding to show in the consent banner. Use "none" to hide branding.|"c15t"|Optional|
|
|
25
|
+
|openapi|[OpenAPIOptions \|undefined](https://v2.c15t.com/docs/self-host/api/endpoints)|OpenAPI spec generation and documentation UI options.|-|Optional|
|
|
26
|
+
|telemetry|[TelemetryOptions \|undefined](https://v2.c15t.com/docs/self-host/guides/observability)|OpenTelemetry configuration for tracing and metrics. Telemetry is opt-in and disabled by default. Users must provide their own SDK setup (Node, Bun, edge, etc.).|-|Optional|
|
|
27
|
+
|ipAddress|[IPAddressOptions \|undefined](https://v2.c15t.com/docs/self-host/api/configuration)|IP address tracking and masking options.|-|Optional|
|
|
28
|
+
|cache|[CacheOptions \|undefined](https://v2.c15t.com/docs/self-host/guides/caching)|Cache configuration for external persistent storage. Used for caching GVL and other data.|-|Optional|
|
|
29
|
+
|apiKeys|string\[] \|undefined|API keys for authenticated endpoints. Used for server-side endpoints like GET /subjects.|-|Optional|
|
|
30
|
+
|iab|[IABOptions \|undefined](https://v2.c15t.com/docs/self-host/guides/iab-tcf)|IAB TCF configuration including GVL, CMP registration, and custom vendors. Disabled by default - most users don't need IAB TCF. Set enabled: true to activate IAB support.|-|Optional|
|
|
31
|
+
|policySnapshot|PolicySnapshotOptions \|undefined|Optional signed policy snapshots used to keep /init and /subjects consistent.|-|Optional|
|
|
32
|
+
|background|BackgroundOptions \|undefined|Optional background task runner for non-critical side effects.|-|Optional|
|
|
33
|
+
|
|
34
|
+
#### `adapter` FumaDBAdapter
|
|
35
|
+
|
|
36
|
+
The database adapter to use.
|
|
37
|
+
|
|
38
|
+
|Property|Type|Description|Default|Required|
|
|
39
|
+
|:--|:--|:--|:--|:--:|
|
|
40
|
+
|name|string|Name of the adapter|-|✅ Required|
|
|
41
|
+
|generateSchema|Object \|undefined|Generate ORM schema based on FumaDB Schema|-|Optional|
|
|
42
|
+
|createMigrationEngine|((this: FumaDBAdapterContext) => Migrator) \|undefined|-|-|Optional|
|
|
43
|
+
|
|
44
|
+
#### `logger` LoggerOptions
|
|
45
|
+
|
|
46
|
+
Logger configuration.
|
|
47
|
+
|
|
48
|
+
|Property|Type|Description|Default|Required|
|
|
49
|
+
|:--|:--|:--|:--|:--:|
|
|
50
|
+
|disabled|boolean \|undefined|Whether logging is disabled.|-|Optional|
|
|
51
|
+
|level|"info" \|"warn" \|"error" \|"debug" \|undefined|The minimum log level to publish.|-|Optional|
|
|
52
|
+
|log|((level: LogLevel, message: string, ...args: unknown\[]) => void) \|undefined|Custom log handler function.|-|Optional|
|
|
53
|
+
|appName|string \|undefined|Custom application name to display in log messages.|-|Optional|
|
|
54
|
+
|getTraceContext|(() => TraceContext \|null) \|undefined|Optional callback to get trace context for log correlation.|-|Optional|
|
|
55
|
+
|
|
56
|
+
#### `i18n` I18nOptions
|
|
57
|
+
|
|
58
|
+
Internationalization message profiles used by runtime policies.
|
|
59
|
+
|
|
60
|
+
|Property|Type|Description|Default|Required|
|
|
61
|
+
|:--|:--|:--|:--|:--:|
|
|
62
|
+
|messages|I18nMessageProfiles \|undefined|Named translation catalogs grouped by profile.|-|Optional|
|
|
63
|
+
|defaultProfile|string \|undefined|Fallback profile used when a policy does not provide \`messageProfile\`.|-|Optional|
|
|
64
|
+
|
|
65
|
+
#### `policyPacks` PolicyConfig
|
|
66
|
+
|
|
67
|
+
Runtime regional policy pack resolved per request.
|
|
68
|
+
|
|
69
|
+
|Property|Type|Description|Default|Required|
|
|
70
|
+
|:--|:--|:--|:--|:--:|
|
|
71
|
+
|id|string|-|-|✅ Required|
|
|
72
|
+
|match|Object \|undefined|-|-|✅ Required|
|
|
73
|
+
|i18n|Object \|undefined|-|-|Optional|
|
|
74
|
+
|consent|Object \|undefined|-|-|Optional|
|
|
75
|
+
|ui|Object \|undefined|-|-|Optional|
|
|
76
|
+
|proof|Object \|undefined|-|-|Optional|
|
|
77
|
+
|
|
78
|
+
#### `policySnapshot` PolicySnapshotOptions
|
|
79
|
+
|
|
80
|
+
Optional signed policy snapshots used to keep /init and /subjects consistent.
|
|
81
|
+
|
|
82
|
+
|Property|Type|Description|Default|Required|
|
|
83
|
+
|:--|:--|:--|:--|:--:|
|
|
84
|
+
|signingKey|string|Secret used for signing and verifying policy snapshot tokens.|-|✅ Required|
|
|
85
|
+
|onValidationFailure|"reject" \|"resolve\_current" \|undefined|How writes should behave when snapshot validation fails.|-|Optional|
|
|
86
|
+
|issuer|string \|undefined|JWT issuer claim for snapshot tokens.|-|Optional|
|
|
87
|
+
|audience|string \|undefined|JWT audience claim for snapshot tokens. When omitted, c15t derives a default snapshot audience and scopes it per tenant.|-|Optional|
|
|
88
|
+
|ttlSeconds|number \|undefined|Snapshot token lifetime in seconds.|-|Optional|
|
|
89
|
+
|
|
90
|
+
#### `background` BackgroundOptions
|
|
91
|
+
|
|
92
|
+
Optional background task runner for non-critical side effects.
|
|
93
|
+
|
|
94
|
+
|Property|Type|Description|Default|Required|
|
|
95
|
+
|:--|:--|:--|:--|:--:|
|
|
96
|
+
|run|(task: () => Promise\<void>) => void|Executes non-critical tasks after the response path has completed.|-|✅ Required|
|
|
97
|
+
|
|
98
|
+
### OpenAPIOptions
|
|
99
|
+
|
|
100
|
+
|Property|Type|Description|Default|Required|
|
|
101
|
+
|:--|:--|:--|:--|:--:|
|
|
102
|
+
|enabled|boolean \|undefined|Enable/disable OpenAPI spec generation|true|Optional|
|
|
103
|
+
|specPath|string \|undefined|Path to serve the OpenAPI JSON spec|"/spec.json"|Optional|
|
|
104
|
+
|docsPath|string \|undefined|Path to serve the API documentation UI|"/docs"|Optional|
|
|
105
|
+
|options|Object \|undefined|OpenAPI specification options|-|Optional|
|
|
106
|
+
|customUiTemplate|string \|undefined|Custom template for rendering the API documentation UI If provided, this will be used instead of the default Scalar UI|-|Optional|
|
|
107
|
+
|
|
108
|
+
#### `options`
|
|
109
|
+
|
|
110
|
+
OpenAPI specification options
|
|
111
|
+
|
|
112
|
+
|Property|Type|Description|Default|Required|
|
|
113
|
+
|:--|:--|:--|:--|:--:|
|
|
114
|
+
|info|Object \|undefined|-|-|Optional|
|
|
115
|
+
|servers|Array\<Object> \|undefined|-|-|Optional|
|
|
116
|
+
|security|Record\<string, string\[]>\[] \|undefined|-|-|Optional|
|
|
117
|
+
|
|
118
|
+
### TelemetryOptions
|
|
119
|
+
|
|
120
|
+
|Property|Type|Description|Default|Required|
|
|
121
|
+
|:--|:--|:--|:--|:--:|
|
|
122
|
+
|enabled|boolean \|undefined|Enable telemetry (tracing and metrics). Must be explicitly set to true to activate.|false|Optional|
|
|
123
|
+
|tracer|Tracer \|undefined|User-provided tracer instance. Users should set up their own OpenTelemetry SDK and pass the tracer here.|-|Optional|
|
|
124
|
+
|meter|Meter \|undefined|User-provided meter instance for metrics. Users should set up their own OpenTelemetry SDK and pass the meter here.|-|Optional|
|
|
125
|
+
|defaultAttributes|Record\<string, string \|number \|boolean> \|undefined|Default attributes to include on all spans and metrics.|-|Optional|
|
|
126
|
+
|
|
127
|
+
### IPAddressOptions
|
|
128
|
+
|
|
129
|
+
|Property|Type|Description|Default|Required|
|
|
130
|
+
|:--|:--|:--|:--|:--:|
|
|
131
|
+
|tracking|boolean \|undefined|Enable/disable IP address tracking. When disabled, all IP addresses will be stored as null.|true|Optional|
|
|
132
|
+
|masking|boolean \|undefined|Enable/disable IP address masking to reduce PII collection.|true|Optional|
|
|
133
|
+
|ipAddressHeaders|string\[] \|undefined|Override the default IP address headers used to extract client IP. Headers are checked in order, first match wins.|-|Optional|
|
|
134
|
+
|
|
135
|
+
### CacheOptions
|
|
136
|
+
|
|
137
|
+
|Property|Type|Description|Default|Required|
|
|
138
|
+
|:--|:--|:--|:--|:--:|
|
|
139
|
+
|adapter|CacheAdapter \|undefined|External cache adapter (Redis, KV, etc.). If not provided, only in-memory cache is used.|-|Optional|
|
|
140
|
+
|
|
141
|
+
### IABOptions
|
|
142
|
+
|
|
143
|
+
|Property|Type|Description|Default|Required|
|
|
144
|
+
|:--|:--|:--|:--|:--:|
|
|
145
|
+
|enabled|true|Enable IAB TCF support. When false or not provided, /init does not include IAB payload fields. When true, /init includes IAB payload only when IAB is active for the resolved request policy (or when no policies are configured).|-|✅ Required|
|
|
146
|
+
|cmpId|number \|undefined|CMP ID registered with IAB Europe. This is returned to clients via the /init endpoint so they can use the correct CMP identity in TC Strings. See List of registered CMPs: https\://iabeurope.eu/cmp-list/|-|Optional|
|
|
147
|
+
|bundled|Object \|undefined \|null|Bundled GVL translations by language code. These are checked first before any cache or fetch.|-|Optional|
|
|
148
|
+
|vendorIds|number\[] \|undefined|Vendor IDs to filter when fetching non-bundled languages. Reduces payload size.|-|Optional|
|
|
149
|
+
|endpoint|string \|undefined|Override the default GVL endpoint.|'https\://gvl.consent.io'|Optional|
|
|
150
|
+
|customVendors|Array\<Object> \|undefined|Custom vendors not registered with IAB. These are synced to the frontend via the /init endpoint.|-|Optional|
|
|
151
|
+
|
|
152
|
+
## Return Value
|
|
153
|
+
|
|
154
|
+
`c15tInstance()` returns:
|
|
155
|
+
|
|
156
|
+
```ts
|
|
157
|
+
interface C15TInstance {
|
|
158
|
+
/** Standard Fetch API handler */
|
|
159
|
+
handler: (request: Request) => Promise<Response>;
|
|
160
|
+
|
|
161
|
+
/** Resolved configuration */
|
|
162
|
+
options: C15TOptions;
|
|
163
|
+
|
|
164
|
+
/** Internal context (database, registry, logger) */
|
|
165
|
+
$context: C15TContext;
|
|
166
|
+
|
|
167
|
+
/** OpenAPI spec as JSON */
|
|
168
|
+
getOpenAPISpec: () => Promise<Record<string, unknown>>;
|
|
169
|
+
|
|
170
|
+
/** OpenAPI docs UI as HTML string */
|
|
171
|
+
getDocsUI: () => string;
|
|
172
|
+
}
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## Edge Init Options
|
|
176
|
+
|
|
177
|
+
`c15tEdgeInit()` from `@c15t/backend/edge` accepts a subset of `C15TOptions` — only the fields needed for consent policy resolution without a database. See the [Edge Deployment guide](/docs/self-host/guides/edge-deployment) for usage.
|
|
178
|
+
|
|
179
|
+
### C15TEdgeOptions
|
|
180
|
+
|
|
181
|
+
|Property|Type|Description|Default|Required|
|
|
182
|
+
|:--|:--|:--|:--|:--:|
|
|
183
|
+
|C15TEdgeOptions|C15TEdgeOptions|Type alias for C15TEdgeOptions|-|✅ Required|
|
|
184
|
+
|
|
185
|
+
## defineConfig Helper
|
|
186
|
+
|
|
187
|
+
For type-safe configuration in a separate file:
|
|
188
|
+
|
|
189
|
+
```ts title="c15t.config.ts"
|
|
190
|
+
import { defineConfig } from '@c15t/backend';
|
|
191
|
+
|
|
192
|
+
export default defineConfig({
|
|
193
|
+
adapter: kyselyAdapter(db),
|
|
194
|
+
trustedOrigins: ['https://example.com'],
|
|
195
|
+
// full autocomplete on all options here
|
|
196
|
+
});
|
|
197
|
+
```
|