@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,5 @@
|
|
|
1
|
+
export type { InitPayload } from './init-handler';
|
|
2
|
+
export { c15tEdgeInit } from './init-handler';
|
|
3
|
+
export type { C15TConsentResolverOptions, CategoryConsent, ResolvedConsent, } from './resolve-consent';
|
|
4
|
+
export { resolveConsent } from './resolve-consent';
|
|
5
|
+
export type { C15TEdgeOptions } from './types';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Edge-compatible /init handler — runs as a pure Request → Response function
|
|
3
|
+
* without Hono or a database adapter.
|
|
4
|
+
*
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
import { type InitPayload } from '../handlers/init/resolve-init';
|
|
8
|
+
import type { C15TEdgeOptions } from './types';
|
|
9
|
+
export type { InitPayload };
|
|
10
|
+
/**
|
|
11
|
+
* Creates an edge-compatible /init handler.
|
|
12
|
+
*
|
|
13
|
+
* The returned function accepts a standard `Request` and returns a `Response`.
|
|
14
|
+
* It has no dependency on Hono or any database adapter, making it suitable for
|
|
15
|
+
* edge runtimes such as Vercel Middleware, Cloudflare Workers, or Deno Deploy.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* // middleware.ts (Vercel Edge)
|
|
20
|
+
* import { c15tEdgeInit } from '@c15t/backend/edge';
|
|
21
|
+
*
|
|
22
|
+
* const initHandler = c15tEdgeInit({
|
|
23
|
+
* trustedOrigins: ['https://myapp.com'],
|
|
24
|
+
* policyPacks: [
|
|
25
|
+
* { id: 'eu', match: { countries: ['DE', 'FR'] }, consent: { model: 'opt-in' }, ui: { mode: 'banner' } },
|
|
26
|
+
* ],
|
|
27
|
+
* policySnapshot: { signingKey: process.env.SNAPSHOT_KEY! },
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* export async function middleware(request: Request) {
|
|
31
|
+
* const url = new URL(request.url);
|
|
32
|
+
* if (url.pathname === '/api/consent/init') {
|
|
33
|
+
* return initHandler(request);
|
|
34
|
+
* }
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function c15tEdgeInit(options: C15TEdgeOptions): (request: Request) => Promise<Response>;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lightweight edge consent resolver — resolves policy + default consent
|
|
3
|
+
* categories from geo headers without the full /init payload.
|
|
4
|
+
*
|
|
5
|
+
* Designed for enterprise customers who maintain their own consent cookie
|
|
6
|
+
* and need to know which categories to load in middleware.
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
import type { Logger } from '../../../logger/dist-types/index.d.ts';
|
|
11
|
+
import type { C15TEdgeOptions } from './types';
|
|
12
|
+
/**
|
|
13
|
+
* Options for the consent resolver — a subset of C15TEdgeOptions
|
|
14
|
+
* containing only what's needed for policy resolution.
|
|
15
|
+
*/
|
|
16
|
+
export type C15TConsentResolverOptions = Pick<C15TEdgeOptions, 'policyPacks' | 'disableGeoLocation'>;
|
|
17
|
+
/**
|
|
18
|
+
* Default consent state for a single category.
|
|
19
|
+
*/
|
|
20
|
+
export interface CategoryConsent {
|
|
21
|
+
/** Whether this category is granted by default (before user interaction). */
|
|
22
|
+
granted: boolean;
|
|
23
|
+
/** Whether the user can toggle this category off. */
|
|
24
|
+
required: boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Result of resolving consent defaults for a request.
|
|
28
|
+
*/
|
|
29
|
+
export interface ResolvedConsent {
|
|
30
|
+
/** The jurisdiction code for this visitor (GDPR, CCPA, etc.) */
|
|
31
|
+
jurisdiction: string;
|
|
32
|
+
/** Visitor's detected location. */
|
|
33
|
+
location: {
|
|
34
|
+
countryCode: string | null;
|
|
35
|
+
regionCode: string | null;
|
|
36
|
+
};
|
|
37
|
+
/** The resolved consent model (opt-in, opt-out, none, iab). */
|
|
38
|
+
model: string;
|
|
39
|
+
/** The matched policy ID, or null if no policy matched. */
|
|
40
|
+
policyId: string | null;
|
|
41
|
+
/** Default consent state per category. */
|
|
42
|
+
defaults: Record<string, CategoryConsent>;
|
|
43
|
+
/** Whether a consent banner/dialog should be shown. */
|
|
44
|
+
showBanner: boolean;
|
|
45
|
+
/** Whether the GPC (Global Privacy Control) signal is active. */
|
|
46
|
+
gpc: boolean;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Resolves consent policy and default category states from a request.
|
|
50
|
+
*
|
|
51
|
+
* Fully synchronous — no async, no fetch calls, no crypto.
|
|
52
|
+
*
|
|
53
|
+
* This is a lightweight alternative to `c15tEdgeInit` for enterprise
|
|
54
|
+
* customers who manage their own consent cookie. It returns the resolved
|
|
55
|
+
* policy and default consent state without translations, GVL, branding,
|
|
56
|
+
* or snapshot tokens.
|
|
57
|
+
*
|
|
58
|
+
* @experimental This API may change in future versions.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* import { resolveConsent } from '@c15t/backend/edge';
|
|
63
|
+
*
|
|
64
|
+
* export function middleware(request: Request) {
|
|
65
|
+
* const consent = resolveConsent(request, {
|
|
66
|
+
* policyPacks: [
|
|
67
|
+
* { id: 'eu', match: { countries: ['DE', 'FR'] }, consent: { model: 'opt-in', categories: ['necessary', 'marketing', 'measurement'] }, ui: { mode: 'banner' } },
|
|
68
|
+
* { id: 'us', match: { isDefault: true }, consent: { model: 'opt-out', categories: ['necessary', 'marketing', 'measurement'] }, ui: { mode: 'banner' } },
|
|
69
|
+
* ],
|
|
70
|
+
* });
|
|
71
|
+
*
|
|
72
|
+
* // consent.defaults => { necessary: { granted: true, required: true }, marketing: { granted: false, required: false }, ... }
|
|
73
|
+
* // consent.model => "opt-in"
|
|
74
|
+
* // consent.showBanner => true
|
|
75
|
+
*
|
|
76
|
+
* // Read your own cookie, merge with consent.defaults, decide what to load
|
|
77
|
+
* }
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
export declare function resolveConsent(request: Request, options: C15TConsentResolverOptions, logger?: Logger): ResolvedConsent;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Edge handler types — the minimal subset of C15TOptions needed to run /init
|
|
3
|
+
* without a database adapter.
|
|
4
|
+
*
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
import type { C15TOptions } from '../types';
|
|
8
|
+
/**
|
|
9
|
+
* Configuration for the edge init handler.
|
|
10
|
+
* This is a strict subset of {@link C15TOptions} containing only the fields
|
|
11
|
+
* needed for consent policy resolution — no database adapter required.
|
|
12
|
+
*/
|
|
13
|
+
export type C15TEdgeOptions = Pick<C15TOptions, 'appName' | 'tenantId' | 'trustedOrigins' | 'disableGeoLocation' | 'customTranslations' | 'i18n' | 'policyPacks' | 'branding' | 'iab' | 'cache' | 'policySnapshot' | 'telemetry' | 'logger'>;
|
|
@@ -16,7 +16,7 @@ export declare function checkJurisdiction(countryCode: string | null, regionCode
|
|
|
16
16
|
* @param options - The C15T options
|
|
17
17
|
* @returns The location object with countryCode and regionCode
|
|
18
18
|
*/
|
|
19
|
-
export declare function getLocation(request: Request, options: C15TOptions): Promise<{
|
|
19
|
+
export declare function getLocation(request: Request, options: Pick<C15TOptions, 'disableGeoLocation'>): Promise<{
|
|
20
20
|
countryCode: string | null;
|
|
21
21
|
regionCode: string | null;
|
|
22
22
|
}>;
|
|
@@ -30,5 +30,4 @@ export declare function getLocation(request: Request, options: C15TOptions): Pro
|
|
|
30
30
|
export declare function getJurisdiction(location: {
|
|
31
31
|
countryCode: string | null;
|
|
32
32
|
regionCode: string | null;
|
|
33
|
-
}, options: C15TOptions): JurisdictionCode;
|
|
34
|
-
//# sourceMappingURL=geo.d.ts.map
|
|
33
|
+
}, options: Pick<C15TOptions, 'disableGeoLocation'>): JurisdictionCode;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { GlobalVendorList, NonIABVendor } from '
|
|
2
|
-
import type { Translations } from '
|
|
1
|
+
import type { GlobalVendorList, NonIABVendor } from '../../../../schema/dist-types/types';
|
|
2
|
+
import type { Translations } from '../../../../translations/dist-types/index.d.ts';
|
|
3
3
|
import type { Branding } from '../../types';
|
|
4
4
|
import type { JurisdictionCode } from '../../types/api';
|
|
5
5
|
/**
|
|
@@ -38,7 +38,7 @@ export declare function buildResponse({ jurisdiction, location, acceptLanguage,
|
|
|
38
38
|
regionCode: string | null;
|
|
39
39
|
};
|
|
40
40
|
translations: {
|
|
41
|
-
translations: import("
|
|
41
|
+
translations: import("../../../../translations/dist-types/index.d.ts").CompleteTranslations;
|
|
42
42
|
language: string;
|
|
43
43
|
};
|
|
44
44
|
branding: "c15t" | "consent" | "none";
|
|
@@ -153,5 +153,4 @@ export declare function buildResponse({ jurisdiction, location, acceptLanguage,
|
|
|
153
153
|
}[] | undefined;
|
|
154
154
|
};
|
|
155
155
|
export { checkJurisdiction, getJurisdiction, getLocation } from './geo';
|
|
156
|
-
export { getTranslations, getTranslationsData } from './translations';
|
|
157
|
-
//# sourceMappingURL=index.d.ts.map
|
|
156
|
+
export { getTranslations, getTranslationsData, listProfiles, validateMessages, } from './translations';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { PolicyMatchedBy, PolicyValidationResult, ResolvedPolicyDecision as SharedResolvedPolicyDecision, ResolvedPolicyMatch as SharedResolvedPolicyMatch, ResolvedPolicy as SharedResolvedRuntimePolicy } from '../../../../schema/dist-types/types';
|
|
2
|
+
import type { JurisdictionCode as BackendJurisdictionCode } from '../../types';
|
|
3
|
+
export type { PolicyMatchedBy, PolicyValidationResult };
|
|
4
|
+
export type ResolvedRuntimePolicy = SharedResolvedRuntimePolicy;
|
|
5
|
+
export type ResolvedPolicyDecision = SharedResolvedPolicyDecision;
|
|
6
|
+
export type ResolvedPolicyMatch = SharedResolvedPolicyMatch;
|
|
7
|
+
export declare function inspectPolicies(policies: unknown, options?: {
|
|
8
|
+
iabEnabled?: boolean;
|
|
9
|
+
}): PolicyValidationResult;
|
|
10
|
+
export declare function validatePolicies(policies: unknown, options?: {
|
|
11
|
+
iabEnabled?: boolean;
|
|
12
|
+
}): void;
|
|
13
|
+
export declare function resolvePolicyDecision(params: {
|
|
14
|
+
policies?: unknown;
|
|
15
|
+
countryCode: string | null;
|
|
16
|
+
regionCode: string | null;
|
|
17
|
+
jurisdiction?: BackendJurisdictionCode;
|
|
18
|
+
iabEnabled?: boolean;
|
|
19
|
+
}): Promise<ResolvedPolicyDecision | undefined>;
|
|
20
|
+
export declare function resolvePolicySync(params: {
|
|
21
|
+
policies?: unknown;
|
|
22
|
+
countryCode: string | null;
|
|
23
|
+
regionCode: string | null;
|
|
24
|
+
jurisdiction?: BackendJurisdictionCode;
|
|
25
|
+
iabEnabled?: boolean;
|
|
26
|
+
}): ResolvedPolicyMatch | undefined;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared init payload resolution — used by both the Hono route and the edge handler.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
import type { Logger } from '../../../../logger/dist-types/index.d.ts';
|
|
7
|
+
import type { ResolvedPolicy } from '../../../../schema/dist-types/types';
|
|
8
|
+
import type { C15TEdgeOptions } from '../../edge/types';
|
|
9
|
+
/**
|
|
10
|
+
* Subset of C15TOptions needed by the init resolver.
|
|
11
|
+
* Derived from {@link C15TEdgeOptions} minus `logger` (passed separately).
|
|
12
|
+
*/
|
|
13
|
+
export type InitResolverOptions = Omit<C15TEdgeOptions, 'logger'>;
|
|
14
|
+
/** The JSON-serializable payload returned by /init. */
|
|
15
|
+
export interface InitPayload {
|
|
16
|
+
jurisdiction: string;
|
|
17
|
+
location: {
|
|
18
|
+
countryCode: string | null;
|
|
19
|
+
regionCode: string | null;
|
|
20
|
+
};
|
|
21
|
+
translations: {
|
|
22
|
+
translations: unknown;
|
|
23
|
+
language: string;
|
|
24
|
+
};
|
|
25
|
+
branding: string;
|
|
26
|
+
gvl?: unknown;
|
|
27
|
+
customVendors?: unknown[];
|
|
28
|
+
policy?: ResolvedPolicy;
|
|
29
|
+
policyDecision?: {
|
|
30
|
+
policyId: string;
|
|
31
|
+
fingerprint: string;
|
|
32
|
+
matchedBy: string;
|
|
33
|
+
country: string | null;
|
|
34
|
+
region: string | null;
|
|
35
|
+
jurisdiction: string;
|
|
36
|
+
};
|
|
37
|
+
policySnapshotToken?: string;
|
|
38
|
+
cmpId?: number;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Resolves the full /init payload from a request and options.
|
|
42
|
+
* Pure function — no Hono, no database dependency.
|
|
43
|
+
*/
|
|
44
|
+
export declare function resolveInitPayload(request: Request, options: InitResolverOptions, logger?: Logger): Promise<InitPayload>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type CompleteTranslations, type Translations } from '../../../../translations/dist-types/index.d.ts';
|
|
2
|
+
import type { C15TOptions, PolicyConfig } from '../../types';
|
|
3
|
+
interface LoggerLike {
|
|
4
|
+
warn: (message: string, metadata?: Record<string, unknown>) => void;
|
|
5
|
+
}
|
|
6
|
+
interface TranslationResolutionOptions {
|
|
7
|
+
i18n?: C15TOptions['i18n'];
|
|
8
|
+
policyI18n?: PolicyConfig['i18n'];
|
|
9
|
+
logger?: LoggerLike;
|
|
10
|
+
}
|
|
11
|
+
export declare function listProfiles(options: {
|
|
12
|
+
customTranslations?: Record<string, Partial<Translations>>;
|
|
13
|
+
i18n?: C15TOptions['i18n'];
|
|
14
|
+
}): string[];
|
|
15
|
+
export declare function validateMessages(options: {
|
|
16
|
+
customTranslations?: Record<string, Partial<Translations>>;
|
|
17
|
+
i18n?: C15TOptions['i18n'];
|
|
18
|
+
policies?: PolicyConfig[];
|
|
19
|
+
}): {
|
|
20
|
+
profiles: string[];
|
|
21
|
+
errors: string[];
|
|
22
|
+
warnings: string[];
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Gets the translations data for a given language, resolving optional policy
|
|
26
|
+
* profile/language hints and compatibility aliases.
|
|
27
|
+
*
|
|
28
|
+
* Fallback order:
|
|
29
|
+
* 1) profile + language
|
|
30
|
+
* 2) profile + fallback language
|
|
31
|
+
*/
|
|
32
|
+
export declare function getTranslationsData(acceptLanguage: string | null, customTranslations?: Record<string, Partial<Translations>>, options?: TranslationResolutionOptions): {
|
|
33
|
+
translations: CompleteTranslations;
|
|
34
|
+
language: string;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Gets the translations for a given language from options.
|
|
38
|
+
*/
|
|
39
|
+
export declare function getTranslations(acceptLanguage: string, options: {
|
|
40
|
+
customTranslations?: Record<string, Partial<Translations>>;
|
|
41
|
+
i18n?: C15TOptions['i18n'];
|
|
42
|
+
policyI18n?: PolicyConfig['i18n'];
|
|
43
|
+
logger?: LoggerLike;
|
|
44
|
+
}): Promise<{
|
|
45
|
+
translations: CompleteTranslations;
|
|
46
|
+
language: string;
|
|
47
|
+
}>;
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { type JWTPayload } from 'jose';
|
|
2
|
+
import type { JurisdictionCode, PolicyModel, PolicyScopeMode, PolicySnapshotOptions, PolicyUiMode, PolicyUiSurfaceConfig } from '../../types';
|
|
3
|
+
import type { PolicyMatchedBy } from '../init/policy';
|
|
4
|
+
export type PolicySnapshotVerificationFailureReason = 'missing' | 'malformed' | 'expired' | 'invalid';
|
|
5
|
+
export type PolicySnapshotVerificationResult = {
|
|
6
|
+
valid: true;
|
|
7
|
+
payload: PolicySnapshotPayload;
|
|
8
|
+
} | {
|
|
9
|
+
valid: false;
|
|
10
|
+
reason: PolicySnapshotVerificationFailureReason;
|
|
11
|
+
};
|
|
12
|
+
export interface PolicySnapshotUiSurface {
|
|
13
|
+
allowedActions?: PolicyUiSurfaceConfig['allowedActions'];
|
|
14
|
+
primaryActions?: PolicyUiSurfaceConfig['primaryActions'];
|
|
15
|
+
layout?: PolicyUiSurfaceConfig['layout'];
|
|
16
|
+
direction?: PolicyUiSurfaceConfig['direction'];
|
|
17
|
+
uiProfile?: PolicyUiSurfaceConfig['uiProfile'];
|
|
18
|
+
scrollLock?: PolicyUiSurfaceConfig['scrollLock'];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* JWT payload for a policy snapshot token.
|
|
22
|
+
*
|
|
23
|
+
* @remarks
|
|
24
|
+
* Fields are intentionally flattened from the nested `ResolvedPolicy` structure
|
|
25
|
+
* to keep the JWT compact. For example, `scopeMode` maps to
|
|
26
|
+
* `ResolvedPolicy.consent.scopeMode` and `uiMode` maps to
|
|
27
|
+
* `ResolvedPolicy.ui.mode`. The post handler reconstructs the nested shape
|
|
28
|
+
* when verifying the token.
|
|
29
|
+
*/
|
|
30
|
+
export interface PolicySnapshotPayload extends JWTPayload {
|
|
31
|
+
iss: string;
|
|
32
|
+
aud: string;
|
|
33
|
+
sub: string;
|
|
34
|
+
tenantId?: string;
|
|
35
|
+
policyId: string;
|
|
36
|
+
fingerprint: string;
|
|
37
|
+
matchedBy: PolicyMatchedBy;
|
|
38
|
+
country: string | null;
|
|
39
|
+
region: string | null;
|
|
40
|
+
jurisdiction: JurisdictionCode;
|
|
41
|
+
language?: string;
|
|
42
|
+
model: PolicyModel;
|
|
43
|
+
policyI18n?: {
|
|
44
|
+
language?: string;
|
|
45
|
+
messageProfile?: string;
|
|
46
|
+
};
|
|
47
|
+
expiryDays?: number;
|
|
48
|
+
scopeMode?: PolicyScopeMode;
|
|
49
|
+
uiMode?: PolicyUiMode;
|
|
50
|
+
bannerUi?: PolicySnapshotUiSurface;
|
|
51
|
+
dialogUi?: PolicySnapshotUiSurface;
|
|
52
|
+
categories?: string[];
|
|
53
|
+
preselectedCategories?: string[];
|
|
54
|
+
gpc?: boolean;
|
|
55
|
+
proofConfig?: {
|
|
56
|
+
storeIp?: boolean;
|
|
57
|
+
storeUserAgent?: boolean;
|
|
58
|
+
storeLanguage?: boolean;
|
|
59
|
+
};
|
|
60
|
+
iat: number;
|
|
61
|
+
exp: number;
|
|
62
|
+
}
|
|
63
|
+
export declare function createPolicySnapshotToken(params: {
|
|
64
|
+
options?: PolicySnapshotOptions;
|
|
65
|
+
tenantId?: string;
|
|
66
|
+
policyId: string;
|
|
67
|
+
fingerprint: string;
|
|
68
|
+
matchedBy: PolicyMatchedBy;
|
|
69
|
+
country: string | null;
|
|
70
|
+
region: string | null;
|
|
71
|
+
jurisdiction: JurisdictionCode;
|
|
72
|
+
language?: string;
|
|
73
|
+
model: PolicyModel;
|
|
74
|
+
policyI18n?: {
|
|
75
|
+
language?: string;
|
|
76
|
+
messageProfile?: string;
|
|
77
|
+
};
|
|
78
|
+
expiryDays?: number;
|
|
79
|
+
scopeMode?: PolicyScopeMode;
|
|
80
|
+
uiMode?: PolicyUiMode;
|
|
81
|
+
bannerUi?: PolicySnapshotUiSurface;
|
|
82
|
+
dialogUi?: PolicySnapshotUiSurface;
|
|
83
|
+
categories?: string[];
|
|
84
|
+
preselectedCategories?: string[];
|
|
85
|
+
gpc?: boolean;
|
|
86
|
+
proofConfig?: {
|
|
87
|
+
storeIp?: boolean;
|
|
88
|
+
storeUserAgent?: boolean;
|
|
89
|
+
storeLanguage?: boolean;
|
|
90
|
+
};
|
|
91
|
+
}): Promise<{
|
|
92
|
+
token: string;
|
|
93
|
+
payload: PolicySnapshotPayload;
|
|
94
|
+
} | undefined>;
|
|
95
|
+
export declare function verifyPolicySnapshotToken(params: {
|
|
96
|
+
token?: string;
|
|
97
|
+
options?: PolicySnapshotOptions;
|
|
98
|
+
tenantId?: string;
|
|
99
|
+
}): Promise<PolicySnapshotVerificationResult>;
|
|
@@ -4,6 +4,15 @@
|
|
|
4
4
|
* @packageDocumentation
|
|
5
5
|
*/
|
|
6
6
|
import type { Context } from 'hono';
|
|
7
|
+
export declare function buildRuntimeDecisionDedupeKey(input: {
|
|
8
|
+
tenantId?: string;
|
|
9
|
+
fingerprint: string;
|
|
10
|
+
matchedBy: string;
|
|
11
|
+
countryCode: string | null;
|
|
12
|
+
regionCode: string | null;
|
|
13
|
+
jurisdiction: string;
|
|
14
|
+
language?: string;
|
|
15
|
+
}): string;
|
|
7
16
|
/**
|
|
8
17
|
* Handles the creation of a new consent record for a subject.
|
|
9
18
|
*
|
|
@@ -19,7 +28,9 @@ export declare const postSubjectHandler: (c: Context) => Promise<Response & impo
|
|
|
19
28
|
metadata: {
|
|
20
29
|
[x: string]: import("hono/utils/types").JSONValue;
|
|
21
30
|
} | undefined;
|
|
31
|
+
appliedPreferences: {
|
|
32
|
+
[x: string]: boolean;
|
|
33
|
+
} | undefined;
|
|
22
34
|
uiSource: string | undefined;
|
|
23
35
|
givenAt: string;
|
|
24
36
|
}, import("hono/utils/http-status").ContentfulStatusCode, "json">>;
|
|
25
|
-
//# sourceMappingURL=post.handler.d.ts.map
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @packageDocumentation
|
|
5
5
|
*/
|
|
6
|
-
import type { Logger } from '
|
|
6
|
+
import type { Logger } from '../../../../logger/dist-types/index.d.ts';
|
|
7
7
|
/**
|
|
8
8
|
* Regular expression to strip protocol, trailing slashes, and port numbers from URLs
|
|
9
9
|
* Matches:
|
|
@@ -46,4 +46,3 @@ export declare const STRIP_REGEX: RegExp;
|
|
|
46
46
|
* ```
|
|
47
47
|
*/
|
|
48
48
|
export declare function isOriginTrusted(origin: string, trustedDomains: string[], logger?: Logger): boolean;
|
|
49
|
-
//# sourceMappingURL=is-origin-trusted.d.ts.map
|
|
@@ -28,4 +28,3 @@ import type { C15TContext } from '../../types';
|
|
|
28
28
|
* @see {@link isOriginTrusted} for origin validation details
|
|
29
29
|
*/
|
|
30
30
|
export declare const processCors: (request: Request, context: C15TContext, trustedOrigins?: string[]) => C15TContext;
|
|
31
|
-
//# sourceMappingURL=process-cors.d.ts.map
|