@c15t/backend 2.0.0-rc.0 → 2.0.0-rc.10
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 +3 -3
- package/dist/302.js +473 -0
- package/dist/583.js +540 -0
- package/dist/915.js +1771 -0
- package/dist/cache.cjs +5 -5
- package/dist/cache.js +4 -415
- package/dist/core.cjs +1356 -120
- package/dist/core.js +163 -1981
- 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 +43 -3
- package/dist/db/schema.js +35 -4
- package/dist/define-config.cjs +1 -1
- package/dist/edge.cjs +1106 -0
- package/dist/edge.js +190 -0
- package/dist/router.cjs +885 -123
- package/dist/router.js +1 -1507
- package/dist/{types.cjs → 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 +0 -1
- 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-types/db/registry/consent-policy.d.ts +78 -0
- 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-types/db/registry/index.d.ts +118 -0
- package/dist-types/db/registry/runtime-policy-decision.d.ts +60 -0
- package/{dist → dist-types}/db/registry/subject.d.ts +0 -2
- package/{dist → dist-types}/db/registry/types.d.ts +1 -1
- 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 +1 -2
- 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 -32
- package/{dist → dist-types}/db/schema/1.0.0/subject.d.ts +0 -2
- package/{dist → dist-types}/db/schema/2.0.0/audit-log.d.ts +1 -2
- package/{dist → dist-types}/db/schema/2.0.0/consent-policy.d.ts +3 -3
- package/{dist → dist-types}/db/schema/2.0.0/consent-purpose.d.ts +1 -2
- package/{dist → dist-types}/db/schema/2.0.0/consent.d.ts +7 -2
- package/{dist → dist-types}/db/schema/2.0.0/domain.d.ts +1 -2
- package/{dist → dist-types}/db/schema/2.0.0/index.d.ts +455 -28
- 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 +1 -3
- package/{dist → dist-types}/db/schema/index.d.ts +908 -86
- package/{dist → dist-types}/db/tenant-scope.d.ts +0 -1
- package/dist-types/define-config.d.ts +17 -0
- package/dist-types/edge/index.d.ts +5 -0
- package/dist-types/edge/init-handler.d.ts +40 -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 +2 -3
- 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/legal-document/current.handler.d.ts +11 -0
- package/dist-types/handlers/legal-document/snapshot.d.ts +39 -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 +3 -2
- 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 +3 -2
- package/{dist → dist-types}/handlers/subject/patch.handler.d.ts +0 -2
- package/{dist → dist-types}/handlers/subject/post.handler.d.ts +12 -1
- package/{dist → dist-types}/handlers/utils/consent-enrichment.d.ts +3 -1
- package/{dist → dist-types}/init.d.ts +4 -7
- 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 +0 -1
- 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/{dist → dist-types}/routes/index.d.ts +1 -1
- package/{dist → dist-types}/routes/init.d.ts +0 -1
- package/dist-types/routes/legal-document.d.ts +7 -0
- 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-types/types/index.d.ts +464 -0
- package/dist-types/utils/background.d.ts +6 -0
- package/{dist → dist-types}/utils/create-telemetry-options.d.ts +1 -2
- 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 +2 -3
- package/{dist → dist-types}/utils/logger.d.ts +0 -1
- 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 +208 -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 +251 -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 +53 -39
- package/.turbo/turbo-build.log +0 -49
- package/CHANGELOG.md +0 -89
- 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 +0 -23
- 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 +0 -57
- 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 +0 -5
- 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 -28
- 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.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 +0 -255
- 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 -368
- 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 -388
- package/src/db/registry/subject.ts +0 -129
- 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 -12
- 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 -26
- 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 -14
- package/src/db/schema/index.ts +0 -15
- package/src/db/tenant-scope.test.ts +0 -750
- package/src/db/tenant-scope.ts +0 -103
- package/src/define-config.ts +0 -5
- 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 -72
- 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 -93
- package/src/handlers/subject/list.handler.ts +0 -93
- package/src/handlers/subject/patch.handler.ts +0 -122
- package/src/handlers/subject/post.handler.test.ts +0 -294
- package/src/handlers/subject/post.handler.ts +0 -254
- 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 -126
- package/src/init.ts +0 -87
- 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 -195
- 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/index.ts +0 -10
- package/src/routes/init.ts +0 -102
- 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 -288
- package/src/utils/create-telemetry-options.test.ts +0 -302
- 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 -185
- package/src/utils/instrumentation.ts +0 -196
- package/src/utils/logger.ts +0 -41
- package/src/utils/metrics.test.ts +0 -323
- package/src/utils/metrics.ts +0 -402
- package/src/utils/telemetry-pii.test.ts +0 -325
- package/src/version.ts +0 -2
- package/tsconfig.json +0 -11
- package/vitest.config.ts +0 -28
- /package/dist/{types.js → types/index.js} +0 -0
- /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,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;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Meter, type Span } from '@opentelemetry/api';
|
|
2
2
|
import type { C15TOptions } from '../types';
|
|
3
|
-
type TelemetryConfig =
|
|
3
|
+
type TelemetryConfig = C15TOptions['telemetry'];
|
|
4
4
|
/**
|
|
5
5
|
* Creates telemetry configuration from provided options
|
|
6
6
|
*
|
|
@@ -68,4 +68,3 @@ export declare function getTraceContext(): {
|
|
|
68
68
|
*/
|
|
69
69
|
export declare const withSpanContext: <T>(span: Span, operation: () => Promise<T>) => Promise<T>;
|
|
70
70
|
export {};
|
|
71
|
-
//# sourceMappingURL=create-telemetry-options.d.ts.map
|
|
@@ -3,8 +3,8 @@ import type { C15TOptions } from '../types';
|
|
|
3
3
|
* Span attributes for database operations
|
|
4
4
|
*/
|
|
5
5
|
export interface DatabaseSpanAttributes {
|
|
6
|
-
/** The database operation type
|
|
7
|
-
operation: 'find' | 'create' | 'update' | 'delete' | 'findOrCreate';
|
|
6
|
+
/** The database operation type */
|
|
7
|
+
operation: 'find' | 'create' | 'update' | 'delete' | 'findOrCreate' | 'findLatest' | 'findByHash' | 'syncCurrent' | 'findOrCreateLegalDocument';
|
|
8
8
|
/** The entity type being operated on */
|
|
9
9
|
entity: string;
|
|
10
10
|
/** Optional additional attributes */
|
|
@@ -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
|
|
@@ -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.10";
|
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,208 @@
|
|
|
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" \|"inth" \|undefined|Select which branding to show in the consent banner. Use "inth" for the INTH brand. "consent" is a deprecated alias for "inth". 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
|
+
|legalDocumentSnapshot|LegalDocumentSnapshotOptions \|undefined|Optional signed legal-document snapshots issued by external document renderers.|-|Optional|
|
|
33
|
+
|background|BackgroundOptions \|undefined|Optional background task runner for non-critical side effects.|-|Optional|
|
|
34
|
+
|
|
35
|
+
#### `adapter` FumaDBAdapter
|
|
36
|
+
|
|
37
|
+
The database adapter to use.
|
|
38
|
+
|
|
39
|
+
|Property|Type|Description|Default|Required|
|
|
40
|
+
|:--|:--|:--|:--|:--:|
|
|
41
|
+
|name|string|Name of the adapter|-|✅ Required|
|
|
42
|
+
|generateSchema|Object \|undefined|Generate ORM schema based on FumaDB Schema|-|Optional|
|
|
43
|
+
|createMigrationEngine|((this: FumaDBAdapterContext) => Migrator) \|undefined|-|-|Optional|
|
|
44
|
+
|
|
45
|
+
#### `logger` LoggerOptions
|
|
46
|
+
|
|
47
|
+
Logger configuration.
|
|
48
|
+
|
|
49
|
+
|Property|Type|Description|Default|Required|
|
|
50
|
+
|:--|:--|:--|:--|:--:|
|
|
51
|
+
|disabled|boolean \|undefined|Whether logging is disabled.|-|Optional|
|
|
52
|
+
|level|"info" \|"warn" \|"error" \|"debug" \|undefined|The minimum log level to publish.|-|Optional|
|
|
53
|
+
|log|((level: LogLevel, message: string, ...args: unknown\[]) => void) \|undefined|Custom log handler function.|-|Optional|
|
|
54
|
+
|appName|string \|undefined|Custom application name to display in log messages.|-|Optional|
|
|
55
|
+
|getTraceContext|(() => TraceContext \|null) \|undefined|Optional callback to get trace context for log correlation.|-|Optional|
|
|
56
|
+
|
|
57
|
+
#### `i18n` I18nOptions
|
|
58
|
+
|
|
59
|
+
Internationalization message profiles used by runtime policies.
|
|
60
|
+
|
|
61
|
+
|Property|Type|Description|Default|Required|
|
|
62
|
+
|:--|:--|:--|:--|:--:|
|
|
63
|
+
|messages|I18nMessageProfiles \|undefined|Named translation catalogs grouped by profile.|-|Optional|
|
|
64
|
+
|defaultProfile|string \|undefined|Fallback profile used when a policy does not provide \`messageProfile\`.|-|Optional|
|
|
65
|
+
|
|
66
|
+
#### `policyPacks` PolicyConfig
|
|
67
|
+
|
|
68
|
+
Runtime regional policy pack resolved per request.
|
|
69
|
+
|
|
70
|
+
|Property|Type|Description|Default|Required|
|
|
71
|
+
|:--|:--|:--|:--|:--:|
|
|
72
|
+
|id|string|-|-|✅ Required|
|
|
73
|
+
|match|Object \|undefined|-|-|✅ Required|
|
|
74
|
+
|i18n|Object \|undefined|-|-|Optional|
|
|
75
|
+
|consent|Object \|undefined|-|-|Optional|
|
|
76
|
+
|ui|Object \|undefined|-|-|Optional|
|
|
77
|
+
|proof|Object \|undefined|-|-|Optional|
|
|
78
|
+
|
|
79
|
+
#### `policySnapshot` PolicySnapshotOptions
|
|
80
|
+
|
|
81
|
+
Optional signed policy snapshots used to keep /init and /subjects consistent.
|
|
82
|
+
|
|
83
|
+
|Property|Type|Description|Default|Required|
|
|
84
|
+
|:--|:--|:--|:--|:--:|
|
|
85
|
+
|signingKey|string|Secret used for signing and verifying policy snapshot tokens.|-|✅ Required|
|
|
86
|
+
|onValidationFailure|"reject" \|"resolve\_current" \|undefined|How writes should behave when snapshot validation fails.|-|Optional|
|
|
87
|
+
|issuer|string \|undefined|JWT issuer claim for snapshot tokens.|-|Optional|
|
|
88
|
+
|audience|string \|undefined|JWT audience claim for snapshot tokens. When omitted, c15t derives a default snapshot audience and scopes it per tenant.|-|Optional|
|
|
89
|
+
|ttlSeconds|number \|undefined|Snapshot token lifetime in seconds.|-|Optional|
|
|
90
|
+
|
|
91
|
+
#### `legalDocumentSnapshot` LegalDocumentSnapshotOptions
|
|
92
|
+
|
|
93
|
+
Optional signed legal-document snapshots issued by external document renderers.
|
|
94
|
+
|
|
95
|
+
|Property|Type|Description|Default|Required|
|
|
96
|
+
|:--|:--|:--|:--|:--:|
|
|
97
|
+
|signingKey|string|Secret used for signing and verifying legal-document snapshot tokens.|-|✅ Required|
|
|
98
|
+
|issuer|string \|undefined|JWT issuer claim for legal-document snapshot tokens.|-|Optional|
|
|
99
|
+
|audience|string \|undefined|JWT audience claim for legal-document snapshot tokens. When omitted, c15t derives a default audience and scopes it per tenant.|-|Optional|
|
|
100
|
+
|
|
101
|
+
#### `background` BackgroundOptions
|
|
102
|
+
|
|
103
|
+
Optional background task runner for non-critical side effects.
|
|
104
|
+
|
|
105
|
+
|Property|Type|Description|Default|Required|
|
|
106
|
+
|:--|:--|:--|:--|:--:|
|
|
107
|
+
|run|(task: () => Promise\<void>) => void|Executes non-critical tasks after the response path has completed.|-|✅ Required|
|
|
108
|
+
|
|
109
|
+
### OpenAPIOptions
|
|
110
|
+
|
|
111
|
+
|Property|Type|Description|Default|Required|
|
|
112
|
+
|:--|:--|:--|:--|:--:|
|
|
113
|
+
|enabled|boolean \|undefined|Enable/disable OpenAPI spec generation|true|Optional|
|
|
114
|
+
|specPath|string \|undefined|Path to serve the OpenAPI JSON spec|"/spec.json"|Optional|
|
|
115
|
+
|docsPath|string \|undefined|Path to serve the API documentation UI|"/docs"|Optional|
|
|
116
|
+
|options|Object \|undefined|OpenAPI specification options|-|Optional|
|
|
117
|
+
|customUiTemplate|string \|undefined|Custom template for rendering the API documentation UI If provided, this will be used instead of the default Scalar UI|-|Optional|
|
|
118
|
+
|
|
119
|
+
#### `options`
|
|
120
|
+
|
|
121
|
+
OpenAPI specification options
|
|
122
|
+
|
|
123
|
+
|Property|Type|Description|Default|Required|
|
|
124
|
+
|:--|:--|:--|:--|:--:|
|
|
125
|
+
|info|Object \|undefined|-|-|Optional|
|
|
126
|
+
|servers|Array\<Object> \|undefined|-|-|Optional|
|
|
127
|
+
|security|Record\<string, string\[]>\[] \|undefined|-|-|Optional|
|
|
128
|
+
|
|
129
|
+
### TelemetryOptions
|
|
130
|
+
|
|
131
|
+
|Property|Type|Description|Default|Required|
|
|
132
|
+
|:--|:--|:--|:--|:--:|
|
|
133
|
+
|enabled|boolean \|undefined|Enable telemetry (tracing and metrics). Must be explicitly set to true to activate.|false|Optional|
|
|
134
|
+
|tracer|Tracer \|undefined|User-provided tracer instance. Users should set up their own OpenTelemetry SDK and pass the tracer here.|-|Optional|
|
|
135
|
+
|meter|Meter \|undefined|User-provided meter instance for metrics. Users should set up their own OpenTelemetry SDK and pass the meter here.|-|Optional|
|
|
136
|
+
|defaultAttributes|Record\<string, string \|number \|boolean> \|undefined|Default attributes to include on all spans and metrics.|-|Optional|
|
|
137
|
+
|
|
138
|
+
### IPAddressOptions
|
|
139
|
+
|
|
140
|
+
|Property|Type|Description|Default|Required|
|
|
141
|
+
|:--|:--|:--|:--|:--:|
|
|
142
|
+
|tracking|boolean \|undefined|Enable/disable IP address tracking. When disabled, all IP addresses will be stored as null.|true|Optional|
|
|
143
|
+
|masking|boolean \|undefined|Enable/disable IP address masking to reduce PII collection.|true|Optional|
|
|
144
|
+
|ipAddressHeaders|string\[] \|undefined|Override the default IP address headers used to extract client IP. Headers are checked in order, first match wins.|-|Optional|
|
|
145
|
+
|
|
146
|
+
### CacheOptions
|
|
147
|
+
|
|
148
|
+
|Property|Type|Description|Default|Required|
|
|
149
|
+
|:--|:--|:--|:--|:--:|
|
|
150
|
+
|adapter|CacheAdapter \|undefined|External cache adapter (Redis, KV, etc.). If not provided, only in-memory cache is used.|-|Optional|
|
|
151
|
+
|
|
152
|
+
### IABOptions
|
|
153
|
+
|
|
154
|
+
|Property|Type|Description|Default|Required|
|
|
155
|
+
|:--|:--|:--|:--|:--:|
|
|
156
|
+
|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|
|
|
157
|
+
|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|
|
|
158
|
+
|bundled|Object \|undefined \|null|Bundled GVL translations by language code. These are checked first before any cache or fetch.|-|Optional|
|
|
159
|
+
|vendorIds|number\[] \|undefined|Vendor IDs to filter when fetching non-bundled languages. Reduces payload size.|-|Optional|
|
|
160
|
+
|endpoint|string \|undefined|Override the default GVL endpoint.|'https\://gvl.consent.io'|Optional|
|
|
161
|
+
|customVendors|Array\<Object> \|undefined|Custom vendors not registered with IAB. These are synced to the frontend via the /init endpoint.|-|Optional|
|
|
162
|
+
|
|
163
|
+
## Return Value
|
|
164
|
+
|
|
165
|
+
`c15tInstance()` returns:
|
|
166
|
+
|
|
167
|
+
```ts
|
|
168
|
+
interface C15TInstance {
|
|
169
|
+
/** Standard Fetch API handler */
|
|
170
|
+
handler: (request: Request) => Promise<Response>;
|
|
171
|
+
|
|
172
|
+
/** Resolved configuration */
|
|
173
|
+
options: C15TOptions;
|
|
174
|
+
|
|
175
|
+
/** Internal context (database, registry, logger) */
|
|
176
|
+
$context: C15TContext;
|
|
177
|
+
|
|
178
|
+
/** OpenAPI spec as JSON */
|
|
179
|
+
getOpenAPISpec: () => Promise<Record<string, unknown>>;
|
|
180
|
+
|
|
181
|
+
/** OpenAPI docs UI as HTML string */
|
|
182
|
+
getDocsUI: () => string;
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## Edge Init Options
|
|
187
|
+
|
|
188
|
+
`unstable_c15tEdgeInit()` from `@c15t/backend/edge` accepts a subset of `C15TOptions` — only the fields needed for consent policy resolution without a database. This edge runtime API is unstable in `2.0`. See the [Edge Deployment guide](/docs/self-host/guides/edge-deployment) for usage.
|
|
189
|
+
|
|
190
|
+
### C15TEdgeOptions
|
|
191
|
+
|
|
192
|
+
|Property|Type|Description|Default|Required|
|
|
193
|
+
|:--|:--|:--|:--|:--:|
|
|
194
|
+
|C15TEdgeOptions|C15TEdgeOptions|Type alias for C15TEdgeOptions|-|✅ Required|
|
|
195
|
+
|
|
196
|
+
## defineConfig Helper
|
|
197
|
+
|
|
198
|
+
For type-safe configuration in a separate file:
|
|
199
|
+
|
|
200
|
+
```ts title="c15t.config.ts"
|
|
201
|
+
import { defineConfig } from '@c15t/backend';
|
|
202
|
+
|
|
203
|
+
export default defineConfig({
|
|
204
|
+
adapter: kyselyAdapter(db),
|
|
205
|
+
trustedOrigins: ['https://example.com'],
|
|
206
|
+
// full autocomplete on all options here
|
|
207
|
+
});
|
|
208
|
+
```
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: API Endpoints
|
|
3
|
+
description: Full reference for every c15t consent backend endpoint.
|
|
4
|
+
---
|
|
5
|
+
All endpoints are relative to your configured `basePath` (e.g. `/api/c15t`).
|
|
6
|
+
|
|
7
|
+
> ℹ️ **Info:**
|
|
8
|
+
> The backend auto-generates interactive API docs at \{basePath}/docs using your OpenAPI spec. Visit this URL in a browser to explore endpoints with a visual UI.
|
|
9
|
+
|
|
10
|
+
## GET /init
|
|
11
|
+
|
|
12
|
+
Returns the initial consent state for a client. This is the first call made by the frontend SDKs.
|
|
13
|
+
|
|
14
|
+
**Response:**
|
|
15
|
+
|
|
16
|
+
```json
|
|
17
|
+
{
|
|
18
|
+
"jurisdiction": "GDPR",
|
|
19
|
+
"location": {
|
|
20
|
+
"countryCode": "DE",
|
|
21
|
+
"regionCode": "BY"
|
|
22
|
+
},
|
|
23
|
+
"translations": {
|
|
24
|
+
"language": "de",
|
|
25
|
+
"translations": { "...": "..." }
|
|
26
|
+
},
|
|
27
|
+
"branding": "c15t",
|
|
28
|
+
"gvl": null
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
|Field|Description|
|
|
33
|
+
|--|--|
|
|
34
|
+
|`jurisdiction`|Detected regulation (`GDPR`, `UK_GDPR`, `CCPA`, etc.)|
|
|
35
|
+
|`location`|Geo-location from IP address|
|
|
36
|
+
|`translations`|Server-side translations based on `Accept-Language`|
|
|
37
|
+
|`branding`|Branding configuration|
|
|
38
|
+
|`gvl`|Global Vendor List (if IAB TCF is enabled)|
|
|
39
|
+
|
|
40
|
+
## GET /status
|
|
41
|
+
|
|
42
|
+
Health check endpoint. Returns server version and client info.
|
|
43
|
+
|
|
44
|
+
**Response:**
|
|
45
|
+
|
|
46
|
+
```json
|
|
47
|
+
{
|
|
48
|
+
"version": "1.8.0",
|
|
49
|
+
"timestamp": "2026-02-11T12:00:00.000Z",
|
|
50
|
+
"client": {
|
|
51
|
+
"ip": "192.168.1.0",
|
|
52
|
+
"acceptLanguage": "en-US",
|
|
53
|
+
"userAgent": "Mozilla/5.0 ...",
|
|
54
|
+
"region": { "countryCode": "US", "regionCode": "CA" }
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## POST /subjects
|
|
60
|
+
|
|
61
|
+
Records a consent event. This is an append-only operation — every call creates a new consent record.
|
|
62
|
+
|
|
63
|
+
**Request:**
|
|
64
|
+
|
|
65
|
+
```json
|
|
66
|
+
{
|
|
67
|
+
"type": "cookie_banner",
|
|
68
|
+
"subjectId": "sub_abc123",
|
|
69
|
+
"domain": "example.com",
|
|
70
|
+
"preferences": {
|
|
71
|
+
"necessary": true,
|
|
72
|
+
"measurement": true,
|
|
73
|
+
"marketing": false
|
|
74
|
+
},
|
|
75
|
+
"givenAt": 1707648000000,
|
|
76
|
+
"metadata": {}
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
|Field|Type|Required|Description|
|
|
81
|
+
|--|--|--|--|
|
|
82
|
+
|`type`|string|Yes|`cookie_banner`, `privacy_policy`, `dpa`, `terms_and_conditions`, `marketing_communications`, `age_verification`, `other`|
|
|
83
|
+
|`subjectId`|string|Yes|Client-generated subject identifier|
|
|
84
|
+
|`domain`|string|Yes|Domain where consent was given|
|
|
85
|
+
|`preferences`|object|No|Consent category preferences (for `cookie_banner` type)|
|
|
86
|
+
|`givenAt`|number|Yes|Epoch timestamp|
|
|
87
|
+
|`policyId`|string|No|Associated policy ID|
|
|
88
|
+
|`metadata`|object|No|Arbitrary metadata|
|
|
89
|
+
|`externalSubjectId`|string|No|External user ID for cross-device linking|
|
|
90
|
+
|`identityProvider`|string|No|Identity provider name|
|
|
91
|
+
|
|
92
|
+
**Response:**
|
|
93
|
+
|
|
94
|
+
```json
|
|
95
|
+
{
|
|
96
|
+
"subject": { "id": "sub_abc123", "...": "..." },
|
|
97
|
+
"consent": { "id": "con_xyz789", "type": "cookie_banner", "...": "..." }
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## GET /subjects/:id
|
|
102
|
+
|
|
103
|
+
Retrieves consent status for a subject.
|
|
104
|
+
|
|
105
|
+
**Query Parameters:**
|
|
106
|
+
|
|
107
|
+
|Parameter|Description|
|
|
108
|
+
|--|--|
|
|
109
|
+
|`type`|Comma-separated consent types to filter (e.g. `cookie_banner,privacy_policy`)|
|
|
110
|
+
|
|
111
|
+
**Response:**
|
|
112
|
+
|
|
113
|
+
```json
|
|
114
|
+
{
|
|
115
|
+
"subject": { "id": "sub_abc123" },
|
|
116
|
+
"consents": [
|
|
117
|
+
{
|
|
118
|
+
"id": "con_xyz789",
|
|
119
|
+
"type": "cookie_banner",
|
|
120
|
+
"givenAt": "2026-02-11T12:00:00.000Z",
|
|
121
|
+
"jurisdiction": "GDPR",
|
|
122
|
+
"preferences": { "necessary": true, "measurement": true }
|
|
123
|
+
}
|
|
124
|
+
],
|
|
125
|
+
"isValid": true
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## PATCH /subjects/:id
|
|
130
|
+
|
|
131
|
+
Links a subject to an external user ID for cross-device consent resolution.
|
|
132
|
+
|
|
133
|
+
**Request:**
|
|
134
|
+
|
|
135
|
+
```json
|
|
136
|
+
{
|
|
137
|
+
"externalId": "user_12345",
|
|
138
|
+
"identityProvider": "auth0"
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**Response:**
|
|
143
|
+
|
|
144
|
+
```json
|
|
145
|
+
{
|
|
146
|
+
"subject": {
|
|
147
|
+
"id": "sub_abc123",
|
|
148
|
+
"externalId": "user_12345",
|
|
149
|
+
"identityProvider": "auth0"
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## GET /consents/check
|
|
155
|
+
|
|
156
|
+
Check consent status by external ID — useful for cross-device consent resolution.
|
|
157
|
+
|
|
158
|
+
**Query Parameters:**
|
|
159
|
+
|
|
160
|
+
|Parameter|Description|
|
|
161
|
+
|--|--|
|
|
162
|
+
|`externalId`|The external user ID to look up|
|
|
163
|
+
|`type`|Comma-separated consent types|
|
|
164
|
+
|
|
165
|
+
**Response:**
|
|
166
|
+
|
|
167
|
+
```json
|
|
168
|
+
{
|
|
169
|
+
"found": true,
|
|
170
|
+
"consents": [
|
|
171
|
+
{ "id": "con_xyz789", "type": "cookie_banner", "...": "..." }
|
|
172
|
+
]
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## GET /subjects (Authenticated)
|
|
177
|
+
|
|
178
|
+
List subjects by external ID. Requires an API key.
|
|
179
|
+
|
|
180
|
+
**Headers:**
|
|
181
|
+
|
|
182
|
+
```
|
|
183
|
+
Authorization: Bearer sk_live_abc123
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
**Query Parameters:**
|
|
187
|
+
|
|
188
|
+
|Parameter|Description|
|
|
189
|
+
|--|--|
|
|
190
|
+
|`externalId`|The external user ID to search|
|
|
191
|
+
|
|
192
|
+
**Response:**
|
|
193
|
+
|
|
194
|
+
```json
|
|
195
|
+
{
|
|
196
|
+
"subjects": [
|
|
197
|
+
{ "id": "sub_abc123", "externalId": "user_12345" }
|
|
198
|
+
]
|
|
199
|
+
}
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
> ℹ️ **Info:**
|
|
203
|
+
> This endpoint requires API key authentication. Configure API keys in the apiKeys option. The key is passed via the Authorization: Bearer header using timing-safe comparison.
|
|
204
|
+
|
|
205
|
+
## GET /spec.json
|
|
206
|
+
|
|
207
|
+
Returns the OpenAPI 3.1 specification for the consent API.
|
|
208
|
+
|
|
209
|
+
## GET /docs
|
|
210
|
+
|
|
211
|
+
Serves the interactive API documentation UI (Scalar).
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Caching
|
|
3
|
+
description: Add a caching layer to your self-hosted c15t backend for production performance.
|
|
4
|
+
---
|
|
5
|
+
The backend includes a caching layer for frequently accessed data like GVL (Global Vendor List) lookups and custom server-side translations. By default, an in-memory cache is used — suitable for single-instance deployments. For production with multiple instances, plug in Redis or Cloudflare KV so all instances share the same cache.
|
|
6
|
+
|
|
7
|
+
## In-Memory (Default)
|
|
8
|
+
|
|
9
|
+
No configuration needed. The default memory cache has a 5-minute TTL and is suitable for development and single-instance deployments.
|
|
10
|
+
|
|
11
|
+
## Upstash Redis
|
|
12
|
+
|
|
13
|
+
```ts title="c15t.ts"
|
|
14
|
+
import { c15tInstance } from '@c15t/backend';
|
|
15
|
+
import { createUpstashRedisAdapter } from '@c15t/backend/cache';
|
|
16
|
+
|
|
17
|
+
export const c15t = c15tInstance({
|
|
18
|
+
// ...
|
|
19
|
+
cache: {
|
|
20
|
+
adapter: createUpstashRedisAdapter({
|
|
21
|
+
url: process.env.UPSTASH_REDIS_REST_URL,
|
|
22
|
+
token: process.env.UPSTASH_REDIS_REST_TOKEN,
|
|
23
|
+
}),
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
If you already have an Upstash Redis client, pass it directly:
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import { createUpstashRedisAdapterFromClient } from '@c15t/backend/cache';
|
|
32
|
+
import { Redis } from '@upstash/redis';
|
|
33
|
+
|
|
34
|
+
const redis = new Redis({
|
|
35
|
+
url: process.env.UPSTASH_REDIS_REST_URL,
|
|
36
|
+
token: process.env.UPSTASH_REDIS_REST_TOKEN,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const adapter = createUpstashRedisAdapterFromClient(redis);
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Cloudflare KV
|
|
43
|
+
|
|
44
|
+
For Cloudflare Workers deployments:
|
|
45
|
+
|
|
46
|
+
```ts title="worker.ts"
|
|
47
|
+
import { c15tInstance } from '@c15t/backend';
|
|
48
|
+
import { createCloudflareKVAdapter } from '@c15t/backend/cache';
|
|
49
|
+
|
|
50
|
+
export default {
|
|
51
|
+
async fetch(request: Request, env: Env) {
|
|
52
|
+
const c15t = c15tInstance({
|
|
53
|
+
// ...
|
|
54
|
+
cache: {
|
|
55
|
+
adapter: createCloudflareKVAdapter(env.GVL_CACHE),
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
return c15t.handler(request);
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Custom Cache Adapter
|
|
65
|
+
|
|
66
|
+
Implement the `CacheAdapter` interface to use any cache backend:
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
import type { CacheAdapter } from '@c15t/backend/cache';
|
|
70
|
+
|
|
71
|
+
const customCache: CacheAdapter = {
|
|
72
|
+
async get<T>(key: string): Promise<T | null> {
|
|
73
|
+
// retrieve from your cache
|
|
74
|
+
},
|
|
75
|
+
async set<T>(key: string, value: T, ttlMs?: number): Promise<void> {
|
|
76
|
+
// store in your cache
|
|
77
|
+
},
|
|
78
|
+
async delete(key: string): Promise<void> {
|
|
79
|
+
// remove from cache
|
|
80
|
+
},
|
|
81
|
+
async has(key: string): Promise<boolean> {
|
|
82
|
+
// check existence
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
```
|