@c15t/backend 1.8.0 → 2.0.0-rc.1
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/.turbo/turbo-build.log +44 -78
- package/CHANGELOG.md +23 -0
- package/dist/cache/adapters/cloudflare-kv.d.ts +46 -0
- package/dist/cache/adapters/cloudflare-kv.d.ts.map +1 -0
- package/dist/cache/adapters/index.d.ts +11 -0
- package/dist/cache/adapters/index.d.ts.map +1 -0
- package/dist/cache/adapters/memory.d.ts +47 -0
- package/dist/cache/adapters/memory.d.ts.map +1 -0
- package/dist/cache/adapters/upstash-redis.d.ts +75 -0
- package/dist/cache/adapters/upstash-redis.d.ts.map +1 -0
- package/dist/cache/gvl-resolver.d.ts +86 -0
- package/dist/cache/gvl-resolver.d.ts.map +1 -0
- package/dist/cache/index.d.ts +13 -0
- package/dist/cache/index.d.ts.map +1 -0
- package/dist/cache/keys.d.ts +51 -0
- package/dist/cache/keys.d.ts.map +1 -0
- package/dist/cache/types.d.ts +61 -0
- package/dist/cache/types.d.ts.map +1 -0
- package/dist/cache.cjs +530 -0
- package/dist/cache.js +467 -0
- package/dist/core.cjs +2569 -3840
- package/dist/core.d.ts +19 -409
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +2378 -3680
- package/dist/db/adapters/drizzle.cjs +36 -0
- package/dist/db/adapters/drizzle.d.ts.map +1 -0
- package/dist/db/adapters/index.d.ts.map +1 -0
- package/dist/db/adapters/kysely.cjs +36 -0
- package/dist/db/adapters/kysely.d.ts.map +1 -0
- package/dist/db/adapters/mongo.cjs +36 -0
- package/dist/db/adapters/mongo.d.ts.map +1 -0
- package/dist/db/adapters/prisma.cjs +36 -0
- package/dist/db/adapters/prisma.d.ts.map +1 -0
- package/dist/db/adapters/typeorm.cjs +36 -0
- package/dist/db/adapters/typeorm.d.ts.map +1 -0
- package/dist/db/adapters.cjs +18 -0
- package/dist/db/migrator/index.d.ts.map +1 -0
- package/dist/db/migrator.cjs +61 -0
- package/dist/db/registry/consent-policy.d.ts +23 -0
- package/dist/db/registry/consent-policy.d.ts.map +1 -0
- package/dist/db/registry/consent-purpose.d.ts +11 -0
- package/dist/db/registry/consent-purpose.d.ts.map +1 -0
- package/dist/db/registry/domain.d.ts +18 -0
- package/dist/db/registry/domain.d.ts.map +1 -0
- package/dist/db/registry/index.d.ts +57 -0
- package/dist/db/registry/index.d.ts.map +1 -0
- package/dist/db/registry/subject.d.ts +32 -0
- package/dist/db/registry/subject.d.ts.map +1 -0
- package/dist/db/registry/types.d.ts +10 -0
- package/dist/db/registry/types.d.ts.map +1 -0
- package/dist/db/registry/utils/generate-id.d.ts +25 -0
- package/dist/db/registry/utils/generate-id.d.ts.map +1 -0
- package/dist/db/registry/utils.d.ts +25 -0
- package/dist/db/registry/utils.d.ts.map +1 -0
- package/dist/db/schema/1.0.0/audit-log.d.ts +14 -0
- package/dist/db/schema/1.0.0/audit-log.d.ts.map +1 -0
- package/dist/db/schema/1.0.0/consent-policy.d.ts +13 -0
- package/dist/db/schema/1.0.0/consent-policy.d.ts.map +1 -0
- package/dist/db/schema/1.0.0/consent-purpose.d.ts +13 -0
- package/dist/db/schema/1.0.0/consent-purpose.d.ts.map +1 -0
- package/dist/db/schema/1.0.0/consent-record.d.ts +9 -0
- package/dist/db/schema/1.0.0/consent-record.d.ts.map +1 -0
- package/dist/db/schema/1.0.0/consent.d.ts +18 -0
- package/dist/db/schema/1.0.0/consent.d.ts.map +1 -0
- package/dist/db/schema/1.0.0/domain.d.ts +11 -0
- package/dist/db/schema/1.0.0/domain.d.ts.map +1 -0
- package/dist/db/schema/1.0.0/index.d.ts +1506 -0
- package/dist/db/schema/1.0.0/index.d.ts.map +1 -0
- package/dist/db/schema/1.0.0/subject.d.ts +11 -0
- package/dist/db/schema/1.0.0/subject.d.ts.map +1 -0
- package/dist/db/schema/2.0.0/audit-log.d.ts +16 -0
- package/dist/db/schema/2.0.0/audit-log.d.ts.map +1 -0
- package/dist/db/schema/2.0.0/consent-policy.d.ts +13 -0
- package/dist/db/schema/2.0.0/consent-policy.d.ts.map +1 -0
- package/dist/db/schema/2.0.0/consent-purpose.d.ts +10 -0
- package/dist/db/schema/2.0.0/consent-purpose.d.ts.map +1 -0
- package/dist/db/schema/2.0.0/consent.d.ts +24 -0
- package/dist/db/schema/2.0.0/consent.d.ts.map +1 -0
- package/dist/db/schema/2.0.0/domain.d.ts +10 -0
- package/dist/db/schema/2.0.0/domain.d.ts.map +1 -0
- package/dist/db/schema/2.0.0/index.d.ts +586 -0
- package/dist/db/schema/2.0.0/index.d.ts.map +1 -0
- package/dist/db/schema/2.0.0/subject.d.ts +12 -0
- package/dist/db/schema/2.0.0/subject.d.ts.map +1 -0
- package/dist/db/schema/index.d.ts +2664 -0
- package/dist/db/schema/index.d.ts.map +1 -0
- package/dist/db/schema.cjs +359 -0
- package/dist/db/schema.js +261 -0
- package/dist/db/tenant-scope.d.ts +20 -0
- package/dist/db/tenant-scope.d.ts.map +1 -0
- package/dist/define-config.cjs +36 -0
- package/dist/define-config.d.ts.map +1 -0
- package/dist/handlers/consent/check.handler.d.ts +24 -0
- package/dist/handlers/consent/check.handler.d.ts.map +1 -0
- package/dist/handlers/consent/index.d.ts +11 -339
- package/dist/handlers/consent/index.d.ts.map +1 -1
- package/dist/handlers/init/geo.d.ts +34 -0
- package/dist/handlers/init/geo.d.ts.map +1 -0
- package/dist/handlers/init/index.d.ts +157 -0
- package/dist/handlers/init/index.d.ts.map +1 -0
- package/dist/handlers/init/translations.d.ts +28 -0
- package/dist/handlers/init/translations.d.ts.map +1 -0
- package/dist/handlers/status/index.d.ts +7 -0
- package/dist/handlers/status/index.d.ts.map +1 -0
- package/dist/handlers/status/status.handler.d.ts +26 -0
- package/dist/handlers/status/status.handler.d.ts.map +1 -0
- package/dist/handlers/subject/get.handler.d.ts +32 -0
- package/dist/handlers/subject/get.handler.d.ts.map +1 -0
- package/dist/handlers/subject/index.d.ts +10 -0
- package/dist/handlers/subject/index.d.ts.map +1 -0
- package/dist/handlers/subject/list.handler.d.ts +31 -0
- package/dist/handlers/subject/list.handler.d.ts.map +1 -0
- package/dist/handlers/subject/patch.handler.d.ts +22 -0
- package/dist/handlers/subject/patch.handler.d.ts.map +1 -0
- package/dist/handlers/subject/post.handler.d.ts +25 -0
- package/dist/handlers/subject/post.handler.d.ts.map +1 -0
- package/dist/handlers/utils/consent-enrichment.d.ts +52 -0
- package/dist/handlers/utils/consent-enrichment.d.ts.map +1 -0
- package/dist/init.d.ts +20 -26
- package/dist/init.d.ts.map +1 -1
- package/dist/middleware/auth/index.d.ts +7 -0
- package/dist/middleware/auth/index.d.ts.map +1 -0
- package/dist/middleware/auth/validate-api-key.d.ts +49 -0
- package/dist/middleware/auth/validate-api-key.d.ts.map +1 -0
- package/dist/middleware/cors/cors.d.ts +13 -17
- package/dist/middleware/cors/cors.d.ts.map +1 -1
- package/dist/middleware/cors/is-origin-trusted.d.ts.map +1 -1
- package/dist/middleware/cors/process-cors.d.ts +1 -1
- package/dist/middleware/cors/process-cors.d.ts.map +1 -1
- package/dist/middleware/openapi/config.d.ts +16 -2
- package/dist/middleware/openapi/config.d.ts.map +1 -1
- package/dist/middleware/openapi/handlers.d.ts +1 -24
- package/dist/middleware/openapi/handlers.d.ts.map +1 -1
- package/dist/middleware/openapi/index.d.ts +3 -2
- package/dist/middleware/openapi/index.d.ts.map +1 -1
- package/dist/middleware/process-ip/index.d.ts +12 -0
- package/dist/middleware/process-ip/index.d.ts.map +1 -0
- package/dist/router.cjs +1288 -1776
- package/dist/router.d.ts +9 -363
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +1277 -1658
- package/dist/routes/consent.d.ts +16 -0
- package/dist/routes/consent.d.ts.map +1 -0
- package/dist/routes/index.d.ts +10 -0
- package/dist/routes/index.d.ts.map +1 -0
- package/dist/routes/init.d.ts +16 -0
- package/dist/routes/init.d.ts.map +1 -0
- package/dist/routes/status.d.ts +16 -0
- package/dist/routes/status.d.ts.map +1 -0
- package/dist/routes/subject.d.ts +16 -0
- package/dist/routes/subject.d.ts.map +1 -0
- package/dist/types/api.d.ts +5 -1
- package/dist/types/api.d.ts.map +1 -1
- package/dist/types/index.d.ts +253 -14
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types.cjs +37 -0
- package/dist/types.js +3 -0
- package/dist/utils/create-telemetry-options.d.ts +71 -0
- package/dist/utils/create-telemetry-options.d.ts.map +1 -0
- package/dist/utils/env.d.ts.map +1 -0
- package/dist/utils/extract-error-message.d.ts +9 -0
- package/dist/utils/extract-error-message.d.ts.map +1 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/instrumentation.d.ts +70 -0
- package/dist/utils/instrumentation.d.ts.map +1 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/metrics.d.ts +133 -0
- package/dist/utils/metrics.d.ts.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/package.json +143 -224
- package/rslib.config.ts +11 -34
- package/src/cache/adapters/cloudflare-kv.ts +71 -0
- package/src/cache/adapters/index.ts +22 -0
- package/src/cache/adapters/memory.ts +111 -0
- package/src/cache/adapters/upstash-redis.ts +113 -0
- package/src/cache/gvl-resolver.ts +289 -0
- package/src/cache/index.ts +34 -0
- package/src/cache/keys.ts +68 -0
- package/src/cache/types.ts +66 -0
- package/src/core.ts +254 -352
- package/src/db/migrator/index.ts +80 -0
- package/src/db/registry/consent-policy.test.ts +451 -0
- package/src/db/registry/consent-policy.ts +82 -0
- package/src/db/registry/consent-purpose.test.ts +428 -0
- package/src/db/registry/consent-purpose.ts +61 -0
- package/src/db/registry/domain.test.ts +445 -0
- package/src/db/registry/domain.ts +91 -0
- package/src/db/registry/index.ts +14 -0
- package/src/db/registry/subject.test.ts +388 -0
- package/src/db/registry/subject.ts +129 -0
- package/src/db/registry/types.ts +10 -0
- package/src/db/registry/utils/generate-id.test.ts +216 -0
- package/src/db/registry/utils/generate-id.ts +133 -0
- package/src/db/registry/utils.ts +133 -0
- package/src/db/schema/1.0.0/audit-log.ts +15 -0
- package/src/db/schema/1.0.0/consent-policy.ts +14 -0
- package/src/db/schema/1.0.0/consent-purpose.ts +14 -0
- package/src/db/schema/1.0.0/consent-record.ts +10 -0
- package/src/db/schema/1.0.0/consent.ts +20 -0
- package/src/db/schema/1.0.0/domain.ts +12 -0
- package/src/db/schema/1.0.0/index.ts +48 -0
- package/src/db/schema/1.0.0/subject.ts +12 -0
- package/src/db/schema/2.0.0/audit-log.ts +18 -0
- package/src/db/schema/2.0.0/consent-policy.ts +28 -0
- package/src/db/schema/2.0.0/consent-purpose.ts +12 -0
- package/src/db/schema/2.0.0/consent.ts +26 -0
- package/src/db/schema/2.0.0/domain.ts +12 -0
- package/src/db/schema/2.0.0/index.ts +47 -0
- package/src/db/schema/2.0.0/subject.ts +14 -0
- package/src/db/schema/index.ts +15 -0
- package/src/db/tenant-scope.test.ts +750 -0
- package/src/db/tenant-scope.ts +103 -0
- package/src/handlers/consent/check.handler.ts +126 -0
- package/src/handlers/consent/index.ts +11 -10
- package/src/handlers/init/geo.test.ts +317 -0
- package/src/handlers/init/geo.ts +195 -0
- package/src/handlers/init/index.test.ts +205 -0
- package/src/handlers/init/index.ts +114 -0
- package/src/handlers/init/translations.test.ts +121 -0
- package/src/handlers/init/translations.ts +72 -0
- package/src/handlers/status/index.ts +7 -0
- package/src/handlers/status/status.handler.test.ts +155 -0
- package/src/handlers/status/status.handler.ts +51 -0
- package/src/handlers/subject/get.handler.ts +93 -0
- package/src/handlers/subject/index.ts +10 -0
- package/src/handlers/subject/list.handler.ts +93 -0
- package/src/handlers/subject/patch.handler.ts +122 -0
- package/src/handlers/subject/post.handler.test.ts +294 -0
- package/src/handlers/subject/post.handler.ts +254 -0
- package/src/handlers/utils/consent-enrichment.test.ts +380 -0
- package/src/handlers/utils/consent-enrichment.ts +218 -0
- package/src/init.test.ts +126 -0
- package/src/init.ts +70 -297
- package/src/middleware/auth/index.ts +11 -0
- package/src/middleware/auth/validate-api-key.test.ts +86 -0
- package/src/middleware/auth/validate-api-key.ts +107 -0
- package/src/middleware/cors/cors.test.ts +96 -380
- package/src/middleware/cors/cors.ts +88 -97
- package/src/middleware/cors/is-origin-trusted.ts +2 -1
- package/src/middleware/cors/process-cors.ts +1 -1
- package/src/middleware/openapi/config.ts +8 -6
- package/src/middleware/openapi/handlers.ts +2 -100
- package/src/middleware/openapi/index.ts +3 -2
- package/src/middleware/process-ip/index.test.ts +195 -0
- package/src/middleware/process-ip/index.ts +199 -0
- package/src/router.ts +14 -7
- package/src/routes/consent.ts +52 -0
- package/src/routes/index.ts +10 -0
- package/src/routes/init.ts +102 -0
- package/src/routes/status.ts +46 -0
- package/src/routes/subject.ts +152 -0
- package/src/types/api.ts +17 -2
- package/src/types/index.ts +288 -23
- package/src/utils/create-telemetry-options.test.ts +302 -0
- package/src/utils/create-telemetry-options.ts +229 -0
- package/src/utils/extract-error-message.ts +21 -0
- package/src/utils/index.ts +3 -0
- package/src/utils/instrumentation.test.ts +185 -0
- package/src/utils/instrumentation.ts +196 -0
- package/src/utils/logger.ts +41 -0
- package/src/utils/metrics.test.ts +323 -0
- package/src/utils/metrics.ts +402 -0
- package/src/utils/telemetry-pii.test.ts +325 -0
- package/src/version.ts +1 -1
- package/tsconfig.json +2 -4
- package/LICENSE.md +0 -595
- package/dist/__tests__/server.test.d.ts +0 -2
- package/dist/__tests__/server.test.d.ts.map +0 -1
- package/dist/contracts/consent/identify.contract.d.ts +0 -24
- package/dist/contracts/consent/identify.contract.d.ts.map +0 -1
- package/dist/contracts/consent/index.d.ts +0 -340
- package/dist/contracts/consent/index.d.ts.map +0 -1
- package/dist/contracts/consent/index.test.d.ts +0 -2
- package/dist/contracts/consent/index.test.d.ts.map +0 -1
- package/dist/contracts/consent/post.contract.d.ts +0 -117
- package/dist/contracts/consent/post.contract.d.ts.map +0 -1
- package/dist/contracts/consent/post.contract.test.d.ts +0 -2
- package/dist/contracts/consent/post.contract.test.d.ts.map +0 -1
- package/dist/contracts/consent/show-banner.contract.d.ts +0 -123
- package/dist/contracts/consent/show-banner.contract.d.ts.map +0 -1
- package/dist/contracts/consent/show-banner.contract.test.d.ts +0 -2
- package/dist/contracts/consent/show-banner.contract.test.d.ts.map +0 -1
- package/dist/contracts/consent/verify.contract.d.ts +0 -81
- package/dist/contracts/consent/verify.contract.d.ts.map +0 -1
- package/dist/contracts/consent/verify.contract.test.d.ts +0 -2
- package/dist/contracts/consent/verify.contract.test.d.ts.map +0 -1
- package/dist/contracts/index.d.ts +0 -731
- package/dist/contracts/index.d.ts.map +0 -1
- package/dist/contracts/meta/index.d.ts +0 -23
- package/dist/contracts/meta/index.d.ts.map +0 -1
- package/dist/contracts/meta/index.test.d.ts +0 -2
- package/dist/contracts/meta/index.test.d.ts.map +0 -1
- package/dist/contracts/meta/status.contract.d.ts +0 -22
- package/dist/contracts/meta/status.contract.d.ts.map +0 -1
- package/dist/contracts/meta/status.contract.test.d.ts +0 -2
- package/dist/contracts/meta/status.contract.test.d.ts.map +0 -1
- package/dist/contracts/shared/jurisdiction.schema.d.ts +0 -36
- package/dist/contracts/shared/jurisdiction.schema.d.ts.map +0 -1
- package/dist/contracts.cjs +0 -799
- package/dist/contracts.js +0 -636
- package/dist/handlers/consent/identify.handler.d.ts +0 -23
- package/dist/handlers/consent/identify.handler.d.ts.map +0 -1
- package/dist/handlers/consent/identify.handler.test.d.ts +0 -2
- package/dist/handlers/consent/identify.handler.test.d.ts.map +0 -1
- package/dist/handlers/consent/post.handler.d.ts +0 -139
- package/dist/handlers/consent/post.handler.d.ts.map +0 -1
- package/dist/handlers/consent/show-banner/geo.d.ts +0 -10
- package/dist/handlers/consent/show-banner/geo.d.ts.map +0 -1
- package/dist/handlers/consent/show-banner/geo.test.d.ts +0 -2
- package/dist/handlers/consent/show-banner/geo.test.d.ts.map +0 -1
- package/dist/handlers/consent/show-banner/handler.d.ts +0 -126
- package/dist/handlers/consent/show-banner/handler.d.ts.map +0 -1
- package/dist/handlers/consent/show-banner/handler.test.d.ts +0 -2
- package/dist/handlers/consent/show-banner/handler.test.d.ts.map +0 -1
- package/dist/handlers/consent/show-banner/translations.d.ts +0 -13
- package/dist/handlers/consent/show-banner/translations.d.ts.map +0 -1
- package/dist/handlers/consent/show-banner/translations.test.d.ts +0 -2
- package/dist/handlers/consent/show-banner/translations.test.d.ts.map +0 -1
- package/dist/handlers/consent/verify.handler.d.ts +0 -103
- package/dist/handlers/consent/verify.handler.d.ts.map +0 -1
- package/dist/handlers/meta/index.d.ts +0 -23
- package/dist/handlers/meta/index.d.ts.map +0 -1
- package/dist/handlers/meta/status.handler.d.ts +0 -21
- package/dist/handlers/meta/status.handler.d.ts.map +0 -1
- package/dist/middleware/cors/cors.test.d.ts +0 -2
- package/dist/middleware/cors/cors.test.d.ts.map +0 -1
- package/dist/middleware/cors/is-origin-trusted.test.d.ts +0 -2
- package/dist/middleware/cors/is-origin-trusted.test.d.ts.map +0 -1
- package/dist/pkgs/api-router/hooks/__tests__/processor.test.d.ts +0 -2
- package/dist/pkgs/api-router/hooks/__tests__/processor.test.d.ts.map +0 -1
- package/dist/pkgs/api-router/hooks/processor.d.ts +0 -87
- package/dist/pkgs/api-router/hooks/processor.d.ts.map +0 -1
- package/dist/pkgs/api-router/telemetry.d.ts +0 -15
- package/dist/pkgs/api-router/telemetry.d.ts.map +0 -1
- package/dist/pkgs/api-router/types/router-props.d.ts +0 -32
- package/dist/pkgs/api-router/types/router-props.d.ts.map +0 -1
- package/dist/pkgs/api-router/utils/ip.d.ts +0 -44
- package/dist/pkgs/api-router/utils/ip.d.ts.map +0 -1
- package/dist/pkgs/data-model/fields/field-factory.d.ts +0 -151
- package/dist/pkgs/data-model/fields/field-factory.d.ts.map +0 -1
- package/dist/pkgs/data-model/fields/field-inference.d.ts +0 -76
- package/dist/pkgs/data-model/fields/field-inference.d.ts.map +0 -1
- package/dist/pkgs/data-model/fields/field-types.d.ts +0 -182
- package/dist/pkgs/data-model/fields/field-types.d.ts.map +0 -1
- package/dist/pkgs/data-model/fields/id-generator.d.ts +0 -19
- package/dist/pkgs/data-model/fields/id-generator.d.ts.map +0 -1
- package/dist/pkgs/data-model/fields/index.cjs +0 -159
- package/dist/pkgs/data-model/fields/index.d.ts +0 -13
- package/dist/pkgs/data-model/fields/index.d.ts.map +0 -1
- package/dist/pkgs/data-model/fields/index.js +0 -106
- package/dist/pkgs/data-model/fields/superjson-utils.d.ts +0 -12
- package/dist/pkgs/data-model/fields/superjson-utils.d.ts.map +0 -1
- package/dist/pkgs/data-model/fields/zod-fields.d.ts +0 -331
- package/dist/pkgs/data-model/fields/zod-fields.d.ts.map +0 -1
- package/dist/pkgs/data-model/hooks/create-hooks.d.ts +0 -32
- package/dist/pkgs/data-model/hooks/create-hooks.d.ts.map +0 -1
- package/dist/pkgs/data-model/hooks/index.d.ts +0 -40
- package/dist/pkgs/data-model/hooks/index.d.ts.map +0 -1
- package/dist/pkgs/data-model/hooks/types.d.ts +0 -134
- package/dist/pkgs/data-model/hooks/types.d.ts.map +0 -1
- package/dist/pkgs/data-model/hooks/update-hooks.d.ts +0 -33
- package/dist/pkgs/data-model/hooks/update-hooks.d.ts.map +0 -1
- package/dist/pkgs/data-model/hooks/update-many-hooks.d.ts +0 -55
- package/dist/pkgs/data-model/hooks/update-many-hooks.d.ts.map +0 -1
- package/dist/pkgs/data-model/hooks/utils.d.ts +0 -62
- package/dist/pkgs/data-model/hooks/utils.d.ts.map +0 -1
- package/dist/pkgs/data-model/hooks/with-hooks-factory.d.ts +0 -33
- package/dist/pkgs/data-model/hooks/with-hooks-factory.d.ts.map +0 -1
- package/dist/pkgs/data-model/index.cjs +0 -1603
- package/dist/pkgs/data-model/index.d.ts +0 -10
- package/dist/pkgs/data-model/index.d.ts.map +0 -1
- package/dist/pkgs/data-model/index.js +0 -1469
- package/dist/pkgs/data-model/schema/index.cjs +0 -1550
- package/dist/pkgs/data-model/schema/index.d.ts +0 -8
- package/dist/pkgs/data-model/schema/index.d.ts.map +0 -1
- package/dist/pkgs/data-model/schema/index.js +0 -1446
- package/dist/pkgs/data-model/schema/schemas.d.ts +0 -14
- package/dist/pkgs/data-model/schema/schemas.d.ts.map +0 -1
- package/dist/pkgs/data-model/schema/types.d.ts +0 -86
- package/dist/pkgs/data-model/schema/types.d.ts.map +0 -1
- package/dist/pkgs/db-adapters/adapter-factory.d.ts +0 -21
- package/dist/pkgs/db-adapters/adapter-factory.d.ts.map +0 -1
- package/dist/pkgs/db-adapters/adapters/drizzle-adapter/drizzle-adapter.d.ts +0 -122
- package/dist/pkgs/db-adapters/adapters/drizzle-adapter/drizzle-adapter.d.ts.map +0 -1
- package/dist/pkgs/db-adapters/adapters/drizzle-adapter/index.cjs +0 -1183
- package/dist/pkgs/db-adapters/adapters/drizzle-adapter/index.d.ts +0 -2
- package/dist/pkgs/db-adapters/adapters/drizzle-adapter/index.d.ts.map +0 -1
- package/dist/pkgs/db-adapters/adapters/drizzle-adapter/index.js +0 -1139
- package/dist/pkgs/db-adapters/adapters/index.d.ts +0 -10
- package/dist/pkgs/db-adapters/adapters/index.d.ts.map +0 -1
- package/dist/pkgs/db-adapters/adapters/kysely-adapter/dialect.d.ts +0 -70
- package/dist/pkgs/db-adapters/adapters/kysely-adapter/dialect.d.ts.map +0 -1
- package/dist/pkgs/db-adapters/adapters/kysely-adapter/index.cjs +0 -1296
- package/dist/pkgs/db-adapters/adapters/kysely-adapter/index.d.ts +0 -4
- package/dist/pkgs/db-adapters/adapters/kysely-adapter/index.d.ts.map +0 -1
- package/dist/pkgs/db-adapters/adapters/kysely-adapter/index.js +0 -1132
- package/dist/pkgs/db-adapters/adapters/kysely-adapter/kysely-adapter.d.ts +0 -99
- package/dist/pkgs/db-adapters/adapters/kysely-adapter/kysely-adapter.d.ts.map +0 -1
- package/dist/pkgs/db-adapters/adapters/kysely-adapter/tests/postgres.test.d.ts +0 -2
- package/dist/pkgs/db-adapters/adapters/kysely-adapter/tests/postgres.test.d.ts.map +0 -1
- package/dist/pkgs/db-adapters/adapters/kysely-adapter/tests/sqlite.test.d.ts +0 -2
- package/dist/pkgs/db-adapters/adapters/kysely-adapter/tests/sqlite.test.d.ts.map +0 -1
- package/dist/pkgs/db-adapters/adapters/kysely-adapter/tests/test-utils.d.ts +0 -49
- package/dist/pkgs/db-adapters/adapters/kysely-adapter/tests/test-utils.d.ts.map +0 -1
- package/dist/pkgs/db-adapters/adapters/kysely-adapter/types.d.ts +0 -278
- package/dist/pkgs/db-adapters/adapters/kysely-adapter/types.d.ts.map +0 -1
- package/dist/pkgs/db-adapters/adapters/memory-adapter/index.cjs +0 -1076
- package/dist/pkgs/db-adapters/adapters/memory-adapter/index.d.ts +0 -2
- package/dist/pkgs/db-adapters/adapters/memory-adapter/index.d.ts.map +0 -1
- package/dist/pkgs/db-adapters/adapters/memory-adapter/index.js +0 -916
- package/dist/pkgs/db-adapters/adapters/memory-adapter/memory-adapter.d.ts +0 -58
- package/dist/pkgs/db-adapters/adapters/memory-adapter/memory-adapter.d.ts.map +0 -1
- package/dist/pkgs/db-adapters/adapters/prisma-adapter/index.cjs +0 -1155
- package/dist/pkgs/db-adapters/adapters/prisma-adapter/index.d.ts +0 -2
- package/dist/pkgs/db-adapters/adapters/prisma-adapter/index.d.ts.map +0 -1
- package/dist/pkgs/db-adapters/adapters/prisma-adapter/index.js +0 -1111
- package/dist/pkgs/db-adapters/adapters/prisma-adapter/prisma-adapter.d.ts +0 -145
- package/dist/pkgs/db-adapters/adapters/prisma-adapter/prisma-adapter.d.ts.map +0 -1
- package/dist/pkgs/db-adapters/adapters/test.d.ts +0 -11
- package/dist/pkgs/db-adapters/adapters/test.d.ts.map +0 -1
- package/dist/pkgs/db-adapters/index.cjs +0 -2035
- package/dist/pkgs/db-adapters/index.d.ts +0 -16
- package/dist/pkgs/db-adapters/index.d.ts.map +0 -1
- package/dist/pkgs/db-adapters/index.js +0 -1972
- package/dist/pkgs/db-adapters/types.d.ts +0 -160
- package/dist/pkgs/db-adapters/types.d.ts.map +0 -1
- package/dist/pkgs/db-adapters/utils.d.ts +0 -36
- package/dist/pkgs/db-adapters/utils.d.ts.map +0 -1
- package/dist/pkgs/migrations/get-migration.d.ts +0 -4
- package/dist/pkgs/migrations/get-migration.d.ts.map +0 -1
- package/dist/pkgs/migrations/get-schema/get-schema.d.ts +0 -27
- package/dist/pkgs/migrations/get-schema/get-schema.d.ts.map +0 -1
- package/dist/pkgs/migrations/get-schema/index.d.ts +0 -21
- package/dist/pkgs/migrations/get-schema/index.d.ts.map +0 -1
- package/dist/pkgs/migrations/get-schema/process-fields.d.ts +0 -15
- package/dist/pkgs/migrations/get-schema/process-fields.d.ts.map +0 -1
- package/dist/pkgs/migrations/get-schema/process-tables.d.ts +0 -13
- package/dist/pkgs/migrations/get-schema/process-tables.d.ts.map +0 -1
- package/dist/pkgs/migrations/get-schema/types.d.ts +0 -17
- package/dist/pkgs/migrations/get-schema/types.d.ts.map +0 -1
- package/dist/pkgs/migrations/index.cjs +0 -1352
- package/dist/pkgs/migrations/index.d.ts +0 -18
- package/dist/pkgs/migrations/index.d.ts.map +0 -1
- package/dist/pkgs/migrations/index.js +0 -1171
- package/dist/pkgs/migrations/migration-builders.d.ts +0 -28
- package/dist/pkgs/migrations/migration-builders.d.ts.map +0 -1
- package/dist/pkgs/migrations/migration-execution.d.ts +0 -12
- package/dist/pkgs/migrations/migration-execution.d.ts.map +0 -1
- package/dist/pkgs/migrations/schema-comparison.d.ts +0 -35
- package/dist/pkgs/migrations/schema-comparison.d.ts.map +0 -1
- package/dist/pkgs/migrations/type-mapping.d.ts +0 -75
- package/dist/pkgs/migrations/type-mapping.d.ts.map +0 -1
- package/dist/pkgs/migrations/types.d.ts +0 -36
- package/dist/pkgs/migrations/types.d.ts.map +0 -1
- package/dist/pkgs/results/__tests__/error-class.test.d.ts +0 -2
- package/dist/pkgs/results/__tests__/error-class.test.d.ts.map +0 -1
- package/dist/pkgs/results/__tests__/error-codes.test.d.ts +0 -2
- package/dist/pkgs/results/__tests__/error-codes.test.d.ts.map +0 -1
- package/dist/pkgs/results/__tests__/neverthrow-integration.test.d.ts +0 -2
- package/dist/pkgs/results/__tests__/neverthrow-integration.test.d.ts.map +0 -1
- package/dist/pkgs/results/__tests__/recovery-utils.test.d.ts +0 -2
- package/dist/pkgs/results/__tests__/recovery-utils.test.d.ts.map +0 -1
- package/dist/pkgs/results/__tests__/result-helpers.test.d.ts +0 -2
- package/dist/pkgs/results/__tests__/result-helpers.test.d.ts.map +0 -1
- package/dist/pkgs/results/core/error-class.d.ts +0 -128
- package/dist/pkgs/results/core/error-class.d.ts.map +0 -1
- package/dist/pkgs/results/core/error-codes.d.ts +0 -178
- package/dist/pkgs/results/core/error-codes.d.ts.map +0 -1
- package/dist/pkgs/results/core/tracing.d.ts +0 -11
- package/dist/pkgs/results/core/tracing.d.ts.map +0 -1
- package/dist/pkgs/results/create-telemetry-options.d.ts +0 -31
- package/dist/pkgs/results/create-telemetry-options.d.ts.map +0 -1
- package/dist/pkgs/results/index.cjs +0 -462
- package/dist/pkgs/results/index.d.ts +0 -80
- package/dist/pkgs/results/index.d.ts.map +0 -1
- package/dist/pkgs/results/index.js +0 -377
- package/dist/pkgs/results/orpc-error-handler.d.ts +0 -65
- package/dist/pkgs/results/orpc-error-handler.d.ts.map +0 -1
- package/dist/pkgs/results/results/recovery-utils.d.ts +0 -115
- package/dist/pkgs/results/results/recovery-utils.d.ts.map +0 -1
- package/dist/pkgs/results/results/result-helpers.d.ts +0 -214
- package/dist/pkgs/results/results/result-helpers.d.ts.map +0 -1
- package/dist/pkgs/results/types.d.ts +0 -200
- package/dist/pkgs/results/types.d.ts.map +0 -1
- package/dist/pkgs/types/context.d.ts +0 -160
- package/dist/pkgs/types/context.d.ts.map +0 -1
- package/dist/pkgs/types/endpoints.d.ts +0 -30
- package/dist/pkgs/types/endpoints.d.ts.map +0 -1
- package/dist/pkgs/types/helper.d.ts +0 -55
- package/dist/pkgs/types/helper.d.ts.map +0 -1
- package/dist/pkgs/types/index.cjs +0 -18
- package/dist/pkgs/types/index.d.ts +0 -11
- package/dist/pkgs/types/index.d.ts.map +0 -1
- package/dist/pkgs/types/options.d.ts +0 -228
- package/dist/pkgs/types/options.d.ts.map +0 -1
- package/dist/pkgs/types/plugins.d.ts +0 -171
- package/dist/pkgs/types/plugins.d.ts.map +0 -1
- package/dist/pkgs/utils/env.d.ts.map +0 -1
- package/dist/pkgs/utils/index.d.ts +0 -4
- package/dist/pkgs/utils/index.d.ts.map +0 -1
- package/dist/pkgs/utils/logger.d.ts.map +0 -1
- package/dist/pkgs/utils/url.d.ts +0 -28
- package/dist/pkgs/utils/url.d.ts.map +0 -1
- package/dist/schema/audit-log/index.d.ts +0 -4
- package/dist/schema/audit-log/index.d.ts.map +0 -1
- package/dist/schema/audit-log/registry.d.ts +0 -96
- package/dist/schema/audit-log/registry.d.ts.map +0 -1
- package/dist/schema/audit-log/schema.d.ts +0 -45
- package/dist/schema/audit-log/schema.d.ts.map +0 -1
- package/dist/schema/audit-log/table.d.ts +0 -153
- package/dist/schema/audit-log/table.d.ts.map +0 -1
- package/dist/schema/audit-log/types.d.ts +0 -29
- package/dist/schema/audit-log/types.d.ts.map +0 -1
- package/dist/schema/consent/index.d.ts +0 -4
- package/dist/schema/consent/index.d.ts.map +0 -1
- package/dist/schema/consent/registry.d.ts +0 -150
- package/dist/schema/consent/registry.d.ts.map +0 -1
- package/dist/schema/consent/schema.d.ts +0 -53
- package/dist/schema/consent/schema.d.ts.map +0 -1
- package/dist/schema/consent/table.d.ts +0 -183
- package/dist/schema/consent/table.d.ts.map +0 -1
- package/dist/schema/consent/types.d.ts +0 -37
- package/dist/schema/consent/types.d.ts.map +0 -1
- package/dist/schema/consent-policy/index.d.ts +0 -4
- package/dist/schema/consent-policy/index.d.ts.map +0 -1
- package/dist/schema/consent-policy/registry.d.ts +0 -200
- package/dist/schema/consent-policy/registry.d.ts.map +0 -1
- package/dist/schema/consent-policy/schema.d.ts +0 -65
- package/dist/schema/consent-policy/schema.d.ts.map +0 -1
- package/dist/schema/consent-policy/table.d.ts +0 -142
- package/dist/schema/consent-policy/table.d.ts.map +0 -1
- package/dist/schema/consent-policy/types.d.ts +0 -29
- package/dist/schema/consent-policy/types.d.ts.map +0 -1
- package/dist/schema/consent-purpose/index.d.ts +0 -4
- package/dist/schema/consent-purpose/index.d.ts.map +0 -1
- package/dist/schema/consent-purpose/registry.d.ts +0 -138
- package/dist/schema/consent-purpose/registry.d.ts.map +0 -1
- package/dist/schema/consent-purpose/schema.d.ts +0 -57
- package/dist/schema/consent-purpose/schema.d.ts.map +0 -1
- package/dist/schema/consent-purpose/table.d.ts +0 -139
- package/dist/schema/consent-purpose/table.d.ts.map +0 -1
- package/dist/schema/consent-purpose/types.d.ts +0 -16
- package/dist/schema/consent-purpose/types.d.ts.map +0 -1
- package/dist/schema/consent-record/index.d.ts +0 -3
- package/dist/schema/consent-record/index.d.ts.map +0 -1
- package/dist/schema/consent-record/schema.d.ts +0 -41
- package/dist/schema/consent-record/schema.d.ts.map +0 -1
- package/dist/schema/consent-record/table.d.ts +0 -107
- package/dist/schema/consent-record/table.d.ts.map +0 -1
- package/dist/schema/consent-record/types.d.ts +0 -21
- package/dist/schema/consent-record/types.d.ts.map +0 -1
- package/dist/schema/create-registry.d.ts +0 -218
- package/dist/schema/create-registry.d.ts.map +0 -1
- package/dist/schema/definition.d.ts +0 -586
- package/dist/schema/definition.d.ts.map +0 -1
- package/dist/schema/domain/index.d.ts +0 -4
- package/dist/schema/domain/index.d.ts.map +0 -1
- package/dist/schema/domain/registry.d.ts +0 -222
- package/dist/schema/domain/registry.d.ts.map +0 -1
- package/dist/schema/domain/schema.d.ts +0 -42
- package/dist/schema/domain/schema.d.ts.map +0 -1
- package/dist/schema/domain/table.d.ts +0 -122
- package/dist/schema/domain/table.d.ts.map +0 -1
- package/dist/schema/domain/types.d.ts +0 -27
- package/dist/schema/domain/types.d.ts.map +0 -1
- package/dist/schema/index.cjs +0 -1565
- package/dist/schema/index.d.ts +0 -70
- package/dist/schema/index.d.ts.map +0 -1
- package/dist/schema/index.js +0 -1455
- package/dist/schema/schemas.d.ts +0 -98
- package/dist/schema/schemas.d.ts.map +0 -1
- package/dist/schema/subject/index.d.ts +0 -4
- package/dist/schema/subject/index.d.ts.map +0 -1
- package/dist/schema/subject/registry.d.ts +0 -110
- package/dist/schema/subject/registry.d.ts.map +0 -1
- package/dist/schema/subject/schema.d.ts +0 -40
- package/dist/schema/subject/schema.d.ts.map +0 -1
- package/dist/schema/subject/table.d.ts +0 -120
- package/dist/schema/subject/table.d.ts.map +0 -1
- package/dist/schema/subject/types.d.ts +0 -22
- package/dist/schema/subject/types.d.ts.map +0 -1
- package/dist/schema/types.d.ts +0 -108
- package/dist/schema/types.d.ts.map +0 -1
- package/dist/server.d.ts +0 -2
- package/dist/server.d.ts.map +0 -1
- package/dist/testing/contract-testing.d.ts +0 -38
- package/dist/testing/contract-testing.d.ts.map +0 -1
- package/dist/types/context.d.ts +0 -12
- package/dist/types/context.d.ts.map +0 -1
- package/dist/types/options.d.ts +0 -91
- package/dist/types/options.d.ts.map +0 -1
- package/dist/types/plugins.d.ts +0 -126
- package/dist/types/plugins.d.ts.map +0 -1
- package/dist/v2/contracts/consent/identify.contract.d.ts +0 -24
- package/dist/v2/contracts/consent/identify.contract.d.ts.map +0 -1
- package/dist/v2/contracts/consent/index.d.ts +0 -340
- package/dist/v2/contracts/consent/index.d.ts.map +0 -1
- package/dist/v2/contracts/consent/index.test.d.ts +0 -2
- package/dist/v2/contracts/consent/index.test.d.ts.map +0 -1
- package/dist/v2/contracts/consent/post.contract.d.ts +0 -117
- package/dist/v2/contracts/consent/post.contract.d.ts.map +0 -1
- package/dist/v2/contracts/consent/post.contract.test.d.ts +0 -2
- package/dist/v2/contracts/consent/post.contract.test.d.ts.map +0 -1
- package/dist/v2/contracts/consent/show-banner.contract.d.ts +0 -123
- package/dist/v2/contracts/consent/show-banner.contract.d.ts.map +0 -1
- package/dist/v2/contracts/consent/show-banner.contract.test.d.ts +0 -2
- package/dist/v2/contracts/consent/show-banner.contract.test.d.ts.map +0 -1
- package/dist/v2/contracts/consent/verify.contract.d.ts +0 -81
- package/dist/v2/contracts/consent/verify.contract.d.ts.map +0 -1
- package/dist/v2/contracts/consent/verify.contract.test.d.ts +0 -2
- package/dist/v2/contracts/consent/verify.contract.test.d.ts.map +0 -1
- package/dist/v2/contracts/index.cjs +0 -716
- package/dist/v2/contracts/index.d.ts +0 -723
- package/dist/v2/contracts/index.d.ts.map +0 -1
- package/dist/v2/contracts/index.js +0 -679
- package/dist/v2/contracts/meta/index.d.ts +0 -19
- package/dist/v2/contracts/meta/index.d.ts.map +0 -1
- package/dist/v2/contracts/meta/index.test.d.ts +0 -2
- package/dist/v2/contracts/meta/index.test.d.ts.map +0 -1
- package/dist/v2/contracts/meta/status.contract.d.ts +0 -18
- package/dist/v2/contracts/meta/status.contract.d.ts.map +0 -1
- package/dist/v2/contracts/meta/status.contract.test.d.ts +0 -2
- package/dist/v2/contracts/meta/status.contract.test.d.ts.map +0 -1
- package/dist/v2/contracts/shared/jurisdiction.schema.d.ts +0 -36
- package/dist/v2/contracts/shared/jurisdiction.schema.d.ts.map +0 -1
- package/dist/v2/contracts/test.utils.d.ts +0 -38
- package/dist/v2/contracts/test.utils.d.ts.map +0 -1
- package/dist/v2/core.cjs +0 -2350
- package/dist/v2/core.d.ts +0 -444
- package/dist/v2/core.d.ts.map +0 -1
- package/dist/v2/core.js +0 -2300
- package/dist/v2/db/adapters/drizzle.cjs +0 -36
- package/dist/v2/db/adapters/drizzle.d.ts.map +0 -1
- package/dist/v2/db/adapters/index.cjs +0 -18
- package/dist/v2/db/adapters/index.d.ts.map +0 -1
- package/dist/v2/db/adapters/index.js +0 -0
- package/dist/v2/db/adapters/kysely.cjs +0 -36
- package/dist/v2/db/adapters/kysely.d.ts.map +0 -1
- package/dist/v2/db/adapters/mongo.cjs +0 -36
- package/dist/v2/db/adapters/mongo.d.ts.map +0 -1
- package/dist/v2/db/adapters/prisma.cjs +0 -36
- package/dist/v2/db/adapters/prisma.d.ts.map +0 -1
- package/dist/v2/db/adapters/typeorm.cjs +0 -36
- package/dist/v2/db/adapters/typeorm.d.ts.map +0 -1
- package/dist/v2/db/migrator/index.cjs +0 -61
- package/dist/v2/db/migrator/index.d.ts.map +0 -1
- package/dist/v2/db/registry/audit-log.d.ts +0 -21
- package/dist/v2/db/registry/audit-log.d.ts.map +0 -1
- package/dist/v2/db/registry/audit-log.test.d.ts +0 -2
- package/dist/v2/db/registry/audit-log.test.d.ts.map +0 -1
- package/dist/v2/db/registry/consent-policy.d.ts +0 -29
- package/dist/v2/db/registry/consent-policy.d.ts.map +0 -1
- package/dist/v2/db/registry/consent-policy.test.d.ts +0 -2
- package/dist/v2/db/registry/consent-policy.test.d.ts.map +0 -1
- package/dist/v2/db/registry/consent-purpose.d.ts +0 -16
- package/dist/v2/db/registry/consent-purpose.d.ts.map +0 -1
- package/dist/v2/db/registry/consent-purpose.test.d.ts +0 -2
- package/dist/v2/db/registry/consent-purpose.test.d.ts.map +0 -1
- package/dist/v2/db/registry/consent.d.ts +0 -20
- package/dist/v2/db/registry/consent.d.ts.map +0 -1
- package/dist/v2/db/registry/consent.test.d.ts +0 -2
- package/dist/v2/db/registry/consent.test.d.ts.map +0 -1
- package/dist/v2/db/registry/domain.d.ts +0 -24
- package/dist/v2/db/registry/domain.d.ts.map +0 -1
- package/dist/v2/db/registry/domain.test.d.ts +0 -2
- package/dist/v2/db/registry/domain.test.d.ts.map +0 -1
- package/dist/v2/db/registry/index.d.ts +0 -103
- package/dist/v2/db/registry/index.d.ts.map +0 -1
- package/dist/v2/db/registry/subject.d.ts +0 -19
- package/dist/v2/db/registry/subject.d.ts.map +0 -1
- package/dist/v2/db/registry/subject.test.d.ts +0 -2
- package/dist/v2/db/registry/subject.test.d.ts.map +0 -1
- package/dist/v2/db/registry/types.d.ts +0 -10
- package/dist/v2/db/registry/types.d.ts.map +0 -1
- package/dist/v2/db/registry/utils/generate-id.d.ts +0 -25
- package/dist/v2/db/registry/utils/generate-id.d.ts.map +0 -1
- package/dist/v2/db/registry/utils/generate-id.test.d.ts +0 -2
- package/dist/v2/db/registry/utils/generate-id.test.d.ts.map +0 -1
- package/dist/v2/db/registry/utils.d.ts +0 -25
- package/dist/v2/db/registry/utils.d.ts.map +0 -1
- package/dist/v2/db/schema/1.0.0/audit-log.d.ts +0 -29
- package/dist/v2/db/schema/1.0.0/audit-log.d.ts.map +0 -1
- package/dist/v2/db/schema/1.0.0/consent-policy.d.ts +0 -45
- package/dist/v2/db/schema/1.0.0/consent-policy.d.ts.map +0 -1
- package/dist/v2/db/schema/1.0.0/consent-purpose.d.ts +0 -27
- package/dist/v2/db/schema/1.0.0/consent-purpose.d.ts.map +0 -1
- package/dist/v2/db/schema/1.0.0/consent-record.d.ts +0 -19
- package/dist/v2/db/schema/1.0.0/consent-record.d.ts.map +0 -1
- package/dist/v2/db/schema/1.0.0/consent.d.ts +0 -42
- package/dist/v2/db/schema/1.0.0/consent.d.ts.map +0 -1
- package/dist/v2/db/schema/1.0.0/domain.d.ts +0 -23
- package/dist/v2/db/schema/1.0.0/domain.d.ts.map +0 -1
- package/dist/v2/db/schema/1.0.0/index.d.ts +0 -1513
- package/dist/v2/db/schema/1.0.0/index.d.ts.map +0 -1
- package/dist/v2/db/schema/1.0.0/subject.d.ts +0 -23
- package/dist/v2/db/schema/1.0.0/subject.d.ts.map +0 -1
- package/dist/v2/db/schema/index.cjs +0 -326
- package/dist/v2/db/schema/index.d.ts +0 -1507
- package/dist/v2/db/schema/index.d.ts.map +0 -1
- package/dist/v2/db/schema/index.js +0 -241
- package/dist/v2/define-config.cjs +0 -36
- package/dist/v2/define-config.d.ts.map +0 -1
- package/dist/v2/handlers/consent/identify.handler.d.ts +0 -23
- package/dist/v2/handlers/consent/identify.handler.d.ts.map +0 -1
- package/dist/v2/handlers/consent/identify.handler.test.d.ts +0 -2
- package/dist/v2/handlers/consent/identify.handler.test.d.ts.map +0 -1
- package/dist/v2/handlers/consent/index.d.ts +0 -340
- package/dist/v2/handlers/consent/index.d.ts.map +0 -1
- package/dist/v2/handlers/consent/post.handler.d.ts +0 -139
- package/dist/v2/handlers/consent/post.handler.d.ts.map +0 -1
- package/dist/v2/handlers/consent/show-banner/geo.d.ts +0 -10
- package/dist/v2/handlers/consent/show-banner/geo.d.ts.map +0 -1
- package/dist/v2/handlers/consent/show-banner/geo.test.d.ts +0 -2
- package/dist/v2/handlers/consent/show-banner/geo.test.d.ts.map +0 -1
- package/dist/v2/handlers/consent/show-banner/handler.d.ts +0 -126
- package/dist/v2/handlers/consent/show-banner/handler.d.ts.map +0 -1
- package/dist/v2/handlers/consent/show-banner/handler.test.d.ts +0 -2
- package/dist/v2/handlers/consent/show-banner/handler.test.d.ts.map +0 -1
- package/dist/v2/handlers/consent/show-banner/translations.d.ts +0 -13
- package/dist/v2/handlers/consent/show-banner/translations.d.ts.map +0 -1
- package/dist/v2/handlers/consent/show-banner/translations.test.d.ts +0 -2
- package/dist/v2/handlers/consent/show-banner/translations.test.d.ts.map +0 -1
- package/dist/v2/handlers/consent/verify.handler.d.ts +0 -103
- package/dist/v2/handlers/consent/verify.handler.d.ts.map +0 -1
- package/dist/v2/handlers/meta/index.d.ts +0 -19
- package/dist/v2/handlers/meta/index.d.ts.map +0 -1
- package/dist/v2/handlers/meta/status.handler.d.ts +0 -17
- package/dist/v2/handlers/meta/status.handler.d.ts.map +0 -1
- package/dist/v2/init.d.ts +0 -3
- package/dist/v2/init.d.ts.map +0 -1
- package/dist/v2/init.test.d.ts +0 -2
- package/dist/v2/init.test.d.ts.map +0 -1
- package/dist/v2/middleware/cors/cors.d.ts +0 -37
- package/dist/v2/middleware/cors/cors.d.ts.map +0 -1
- package/dist/v2/middleware/cors/cors.test.d.ts +0 -2
- package/dist/v2/middleware/cors/cors.test.d.ts.map +0 -1
- package/dist/v2/middleware/cors/index.d.ts +0 -30
- package/dist/v2/middleware/cors/index.d.ts.map +0 -1
- package/dist/v2/middleware/cors/is-origin-trusted.d.ts +0 -49
- package/dist/v2/middleware/cors/is-origin-trusted.d.ts.map +0 -1
- package/dist/v2/middleware/cors/is-origin-trusted.test.d.ts +0 -2
- package/dist/v2/middleware/cors/is-origin-trusted.test.d.ts.map +0 -1
- package/dist/v2/middleware/cors/process-cors.d.ts +0 -31
- package/dist/v2/middleware/cors/process-cors.d.ts.map +0 -1
- package/dist/v2/middleware/openapi/config.d.ts +0 -28
- package/dist/v2/middleware/openapi/config.d.ts.map +0 -1
- package/dist/v2/middleware/openapi/handlers.d.ts +0 -29
- package/dist/v2/middleware/openapi/handlers.d.ts.map +0 -1
- package/dist/v2/middleware/openapi/index.d.ts +0 -11
- package/dist/v2/middleware/openapi/index.d.ts.map +0 -1
- package/dist/v2/middleware/process-ip/index.d.ts +0 -3
- package/dist/v2/middleware/process-ip/index.d.ts.map +0 -1
- package/dist/v2/router.cjs +0 -1442
- package/dist/v2/router.d.ts +0 -360
- package/dist/v2/router.d.ts.map +0 -1
- package/dist/v2/router.js +0 -1398
- package/dist/v2/types/api.d.ts +0 -27
- package/dist/v2/types/api.d.ts.map +0 -1
- package/dist/v2/types/index.cjs +0 -40
- package/dist/v2/types/index.d.ts +0 -104
- package/dist/v2/types/index.d.ts.map +0 -1
- package/dist/v2/types/index.js +0 -6
- package/dist/v2/utils/create-telemetry-options.d.ts +0 -28
- package/dist/v2/utils/create-telemetry-options.d.ts.map +0 -1
- package/dist/v2/utils/env.d.ts +0 -60
- package/dist/v2/utils/env.d.ts.map +0 -1
- package/dist/v2/utils/index.d.ts +0 -3
- package/dist/v2/utils/index.d.ts.map +0 -1
- package/dist/v2/utils/logger.d.ts +0 -16
- package/dist/v2/utils/logger.d.ts.map +0 -1
- package/src/__tests__/server.test.ts +0 -100
- package/src/contracts/consent/identify.contract.ts +0 -38
- package/src/contracts/consent/index.test.ts +0 -5
- package/src/contracts/consent/index.ts +0 -11
- package/src/contracts/consent/post.contract.test.ts +0 -521
- package/src/contracts/consent/post.contract.ts +0 -156
- package/src/contracts/consent/show-banner.contract.test.ts +0 -260
- package/src/contracts/consent/show-banner.contract.ts +0 -136
- package/src/contracts/consent/verify.contract.test.ts +0 -185
- package/src/contracts/consent/verify.contract.ts +0 -122
- package/src/contracts/index.ts +0 -20
- package/src/contracts/meta/index.test.ts +0 -5
- package/src/contracts/meta/index.ts +0 -5
- package/src/contracts/meta/status.contract.test.ts +0 -338
- package/src/contracts/meta/status.contract.ts +0 -37
- package/src/contracts/shared/jurisdiction.schema.ts +0 -30
- package/src/handlers/consent/identify.handler.test.ts +0 -473
- package/src/handlers/consent/identify.handler.ts +0 -176
- package/src/handlers/consent/post.handler.ts +0 -277
- package/src/handlers/consent/show-banner/geo.test.ts +0 -281
- package/src/handlers/consent/show-banner/geo.ts +0 -96
- package/src/handlers/consent/show-banner/handler.test.ts +0 -376
- package/src/handlers/consent/show-banner/handler.ts +0 -123
- package/src/handlers/consent/show-banner/translations.test.ts +0 -121
- package/src/handlers/consent/show-banner/translations.ts +0 -79
- package/src/handlers/consent/verify.handler.ts +0 -305
- package/src/handlers/meta/index.ts +0 -5
- package/src/handlers/meta/status.handler.ts +0 -47
- package/src/pkgs/api-router/hooks/__tests__/processor.test.ts +0 -290
- package/src/pkgs/api-router/hooks/processor.ts +0 -153
- package/src/pkgs/api-router/telemetry.ts +0 -83
- package/src/pkgs/api-router/types/router-props.ts +0 -36
- package/src/pkgs/api-router/utils/ip.ts +0 -92
- package/src/pkgs/data-model/fields/field-factory.ts +0 -208
- package/src/pkgs/data-model/fields/field-inference.ts +0 -93
- package/src/pkgs/data-model/fields/field-types.ts +0 -233
- package/src/pkgs/data-model/fields/id-generator.ts +0 -57
- package/src/pkgs/data-model/fields/index.ts +0 -37
- package/src/pkgs/data-model/fields/superjson-utils.ts +0 -17
- package/src/pkgs/data-model/fields/zod-fields.ts +0 -125
- package/src/pkgs/data-model/hooks/create-hooks.ts +0 -88
- package/src/pkgs/data-model/hooks/index.ts +0 -40
- package/src/pkgs/data-model/hooks/types.ts +0 -165
- package/src/pkgs/data-model/hooks/update-hooks.ts +0 -91
- package/src/pkgs/data-model/hooks/update-many-hooks.ts +0 -176
- package/src/pkgs/data-model/hooks/utils.ts +0 -151
- package/src/pkgs/data-model/hooks/with-hooks-factory.ts +0 -68
- package/src/pkgs/data-model/index.ts +0 -13
- package/src/pkgs/data-model/schema/index.ts +0 -19
- package/src/pkgs/data-model/schema/schemas.ts +0 -15
- package/src/pkgs/data-model/schema/types.ts +0 -105
- package/src/pkgs/db-adapters/README.md +0 -95
- package/src/pkgs/db-adapters/adapter-factory.ts +0 -68
- package/src/pkgs/db-adapters/adapters/drizzle-adapter/drizzle-adapter.ts +0 -709
- package/src/pkgs/db-adapters/adapters/drizzle-adapter/index.ts +0 -1
- package/src/pkgs/db-adapters/adapters/index.ts +0 -10
- package/src/pkgs/db-adapters/adapters/kysely-adapter/dialect.ts +0 -195
- package/src/pkgs/db-adapters/adapters/kysely-adapter/index.ts +0 -10
- package/src/pkgs/db-adapters/adapters/kysely-adapter/kysely-adapter.ts +0 -1182
- package/src/pkgs/db-adapters/adapters/kysely-adapter/tests/postgres.test.ts +0 -214
- package/src/pkgs/db-adapters/adapters/kysely-adapter/tests/sqlite.test.ts +0 -227
- package/src/pkgs/db-adapters/adapters/kysely-adapter/tests/test-utils.ts +0 -439
- package/src/pkgs/db-adapters/adapters/kysely-adapter/types.ts +0 -304
- package/src/pkgs/db-adapters/adapters/memory-adapter/index.ts +0 -1
- package/src/pkgs/db-adapters/adapters/memory-adapter/memory-adapter.ts +0 -665
- package/src/pkgs/db-adapters/adapters/prisma-adapter/index.ts +0 -1
- package/src/pkgs/db-adapters/adapters/prisma-adapter/prisma-adapter.ts +0 -586
- package/src/pkgs/db-adapters/adapters/test.ts +0 -77
- package/src/pkgs/db-adapters/index.ts +0 -28
- package/src/pkgs/db-adapters/types.ts +0 -211
- package/src/pkgs/db-adapters/utils.ts +0 -51
- package/src/pkgs/migrations/README.md +0 -73
- package/src/pkgs/migrations/get-migration.ts +0 -88
- package/src/pkgs/migrations/get-schema/get-schema.ts +0 -43
- package/src/pkgs/migrations/get-schema/index.ts +0 -20
- package/src/pkgs/migrations/get-schema/process-fields.ts +0 -65
- package/src/pkgs/migrations/get-schema/process-tables.ts +0 -66
- package/src/pkgs/migrations/get-schema/types.ts +0 -18
- package/src/pkgs/migrations/index.ts +0 -30
- package/src/pkgs/migrations/migration-builders.ts +0 -170
- package/src/pkgs/migrations/migration-execution.ts +0 -72
- package/src/pkgs/migrations/schema-comparison.ts +0 -203
- package/src/pkgs/migrations/type-mapping.ts +0 -244
- package/src/pkgs/migrations/types.ts +0 -48
- package/src/pkgs/results/README.md +0 -345
- package/src/pkgs/results/__tests__/error-class.test.ts +0 -183
- package/src/pkgs/results/__tests__/error-codes.test.ts +0 -81
- package/src/pkgs/results/__tests__/neverthrow-integration.test.ts +0 -92
- package/src/pkgs/results/__tests__/recovery-utils.test.ts +0 -140
- package/src/pkgs/results/__tests__/result-helpers.test.ts +0 -206
- package/src/pkgs/results/core/error-class.ts +0 -297
- package/src/pkgs/results/core/error-codes.ts +0 -206
- package/src/pkgs/results/core/tracing.ts +0 -65
- package/src/pkgs/results/create-telemetry-options.ts +0 -62
- package/src/pkgs/results/index.ts +0 -115
- package/src/pkgs/results/orpc-error-handler.ts +0 -137
- package/src/pkgs/results/results/recovery-utils.ts +0 -181
- package/src/pkgs/results/results/result-helpers.ts +0 -383
- package/src/pkgs/results/types.ts +0 -217
- package/src/pkgs/types/context.ts +0 -178
- package/src/pkgs/types/endpoints.ts +0 -35
- package/src/pkgs/types/helper.ts +0 -57
- package/src/pkgs/types/index.ts +0 -18
- package/src/pkgs/types/options.ts +0 -252
- package/src/pkgs/types/plugins.ts +0 -191
- package/src/pkgs/utils/index.ts +0 -3
- package/src/pkgs/utils/logger.ts +0 -35
- package/src/pkgs/utils/url.ts +0 -105
- package/src/schema/audit-log/index.ts +0 -3
- package/src/schema/audit-log/registry.ts +0 -117
- package/src/schema/audit-log/schema.ts +0 -46
- package/src/schema/audit-log/table.ts +0 -185
- package/src/schema/audit-log/types.ts +0 -29
- package/src/schema/consent/index.ts +0 -3
- package/src/schema/consent/registry.ts +0 -177
- package/src/schema/consent/schema.ts +0 -51
- package/src/schema/consent/table.ts +0 -221
- package/src/schema/consent/types.ts +0 -39
- package/src/schema/consent-policy/index.ts +0 -3
- package/src/schema/consent-policy/registry.ts +0 -352
- package/src/schema/consent-policy/schema.ts +0 -60
- package/src/schema/consent-policy/table.ts +0 -150
- package/src/schema/consent-policy/types.ts +0 -29
- package/src/schema/consent-purpose/index.ts +0 -3
- package/src/schema/consent-purpose/registry.ts +0 -168
- package/src/schema/consent-purpose/schema.ts +0 -58
- package/src/schema/consent-purpose/table.ts +0 -154
- package/src/schema/consent-purpose/types.ts +0 -16
- package/src/schema/consent-record/index.ts +0 -2
- package/src/schema/consent-record/schema.ts +0 -42
- package/src/schema/consent-record/table.ts +0 -124
- package/src/schema/consent-record/types.ts +0 -21
- package/src/schema/create-registry.ts +0 -21
- package/src/schema/definition.ts +0 -200
- package/src/schema/domain/index.ts +0 -3
- package/src/schema/domain/registry.ts +0 -296
- package/src/schema/domain/schema.ts +0 -43
- package/src/schema/domain/table.ts +0 -137
- package/src/schema/domain/types.ts +0 -27
- package/src/schema/index.ts +0 -74
- package/src/schema/schemas.ts +0 -27
- package/src/schema/subject/index.ts +0 -3
- package/src/schema/subject/registry.ts +0 -298
- package/src/schema/subject/schema.ts +0 -41
- package/src/schema/subject/table.ts +0 -138
- package/src/schema/subject/types.ts +0 -22
- package/src/schema/types.ts +0 -121
- package/src/server.ts +0 -126
- package/src/testing/contract-testing.ts +0 -400
- package/src/types/context.ts +0 -16
- package/src/types/options.ts +0 -103
- package/src/types/plugins.ts +0 -154
- package/src/v2/contracts/consent/identify.contract.ts +0 -38
- package/src/v2/contracts/consent/index.test.ts +0 -5
- package/src/v2/contracts/consent/index.ts +0 -11
- package/src/v2/contracts/consent/post.contract.test.ts +0 -521
- package/src/v2/contracts/consent/post.contract.ts +0 -156
- package/src/v2/contracts/consent/show-banner.contract.test.ts +0 -252
- package/src/v2/contracts/consent/show-banner.contract.ts +0 -136
- package/src/v2/contracts/consent/verify.contract.test.ts +0 -185
- package/src/v2/contracts/consent/verify.contract.ts +0 -122
- package/src/v2/contracts/index.ts +0 -20
- package/src/v2/contracts/meta/index.test.ts +0 -5
- package/src/v2/contracts/meta/index.ts +0 -5
- package/src/v2/contracts/meta/status.contract.test.ts +0 -226
- package/src/v2/contracts/meta/status.contract.ts +0 -34
- package/src/v2/contracts/shared/jurisdiction.schema.ts +0 -30
- package/src/v2/contracts/test.utils.ts +0 -400
- package/src/v2/core.ts +0 -379
- package/src/v2/db/migrator/index.ts +0 -80
- package/src/v2/db/registry/audit-log.test.ts +0 -77
- package/src/v2/db/registry/audit-log.ts +0 -46
- package/src/v2/db/registry/consent-policy.test.ts +0 -778
- package/src/v2/db/registry/consent-policy.ts +0 -74
- package/src/v2/db/registry/consent-purpose.test.ts +0 -485
- package/src/v2/db/registry/consent-purpose.ts +0 -41
- package/src/v2/db/registry/consent.test.ts +0 -843
- package/src/v2/db/registry/consent.ts +0 -42
- package/src/v2/db/registry/domain.test.ts +0 -463
- package/src/v2/db/registry/domain.ts +0 -51
- package/src/v2/db/registry/index.ts +0 -18
- package/src/v2/db/registry/subject.test.ts +0 -497
- package/src/v2/db/registry/subject.ts +0 -103
- package/src/v2/db/registry/types.ts +0 -10
- package/src/v2/db/registry/utils/generate-id.test.ts +0 -217
- package/src/v2/db/registry/utils/generate-id.ts +0 -134
- package/src/v2/db/registry/utils.ts +0 -134
- package/src/v2/db/schema/1.0.0/audit-log.ts +0 -32
- package/src/v2/db/schema/1.0.0/consent-policy.ts +0 -41
- package/src/v2/db/schema/1.0.0/consent-purpose.ts +0 -30
- package/src/v2/db/schema/1.0.0/consent-record.ts +0 -22
- package/src/v2/db/schema/1.0.0/consent.ts +0 -38
- package/src/v2/db/schema/1.0.0/domain.ts +0 -26
- package/src/v2/db/schema/1.0.0/index.ts +0 -56
- package/src/v2/db/schema/1.0.0/subject.ts +0 -26
- package/src/v2/db/schema/index.ts +0 -9
- package/src/v2/handlers/consent/identify.handler.test.ts +0 -453
- package/src/v2/handlers/consent/identify.handler.ts +0 -125
- package/src/v2/handlers/consent/index.ts +0 -11
- package/src/v2/handlers/consent/post.handler.ts +0 -258
- package/src/v2/handlers/consent/show-banner/geo.test.ts +0 -281
- package/src/v2/handlers/consent/show-banner/geo.ts +0 -96
- package/src/v2/handlers/consent/show-banner/handler.test.ts +0 -374
- package/src/v2/handlers/consent/show-banner/handler.ts +0 -123
- package/src/v2/handlers/consent/show-banner/translations.test.ts +0 -121
- package/src/v2/handlers/consent/show-banner/translations.ts +0 -79
- package/src/v2/handlers/consent/verify.handler.ts +0 -288
- package/src/v2/handlers/meta/index.ts +0 -5
- package/src/v2/handlers/meta/status.handler.ts +0 -43
- package/src/v2/init.test.ts +0 -120
- package/src/v2/init.ts +0 -126
- package/src/v2/middleware/cors/cors.test.ts +0 -114
- package/src/v2/middleware/cors/cors.ts +0 -195
- package/src/v2/middleware/cors/index.ts +0 -30
- package/src/v2/middleware/cors/is-origin-trusted.test.ts +0 -164
- package/src/v2/middleware/cors/is-origin-trusted.ts +0 -129
- package/src/v2/middleware/cors/process-cors.ts +0 -91
- package/src/v2/middleware/openapi/config.ts +0 -27
- package/src/v2/middleware/openapi/handlers.ts +0 -132
- package/src/v2/middleware/openapi/index.ts +0 -11
- package/src/v2/middleware/process-ip/index.ts +0 -39
- package/src/v2/router.ts +0 -8
- package/src/v2/types/api.ts +0 -32
- package/src/v2/types/index.ts +0 -121
- package/src/v2/utils/create-telemetry-options.ts +0 -115
- package/src/v2/utils/env.ts +0 -84
- package/src/v2/utils/index.ts +0 -2
- package/src/v2/utils/logger.ts +0 -35
- /package/dist/{v2/db → db}/adapters/drizzle.d.ts +0 -0
- /package/dist/{v2/db → db}/adapters/drizzle.js +0 -0
- /package/dist/{v2/db → db}/adapters/index.d.ts +0 -0
- /package/dist/{v2/db → db}/adapters/kysely.d.ts +0 -0
- /package/dist/{v2/db → db}/adapters/kysely.js +0 -0
- /package/dist/{v2/db → db}/adapters/mongo.d.ts +0 -0
- /package/dist/{v2/db → db}/adapters/mongo.js +0 -0
- /package/dist/{v2/db → db}/adapters/prisma.d.ts +0 -0
- /package/dist/{v2/db → db}/adapters/prisma.js +0 -0
- /package/dist/{v2/db → db}/adapters/typeorm.d.ts +0 -0
- /package/dist/{v2/db → db}/adapters/typeorm.js +0 -0
- /package/dist/{pkgs/types/index.js → db/adapters.js} +0 -0
- /package/dist/{v2/db → db}/migrator/index.d.ts +0 -0
- /package/dist/{v2/db/migrator/index.js → db/migrator.js} +0 -0
- /package/dist/{v2/define-config.d.ts → define-config.d.ts} +0 -0
- /package/dist/{v2/define-config.js → define-config.js} +0 -0
- /package/dist/{pkgs/utils → utils}/env.d.ts +0 -0
- /package/dist/{pkgs/utils → utils}/logger.d.ts +0 -0
- /package/src/{v2/db → db}/adapters/drizzle.ts +0 -0
- /package/src/{v2/db → db}/adapters/index.ts +0 -0
- /package/src/{v2/db → db}/adapters/kysely.ts +0 -0
- /package/src/{v2/db → db}/adapters/mongo.ts +0 -0
- /package/src/{v2/db → db}/adapters/prisma.ts +0 -0
- /package/src/{v2/db → db}/adapters/typeorm.ts +0 -0
- /package/src/{v2/define-config.ts → define-config.ts} +0 -0
- /package/src/{pkgs/utils → utils}/env.ts +0 -0
package/dist/v2/router.cjs
DELETED
|
@@ -1,1442 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_require__ = {};
|
|
3
|
-
(()=>{
|
|
4
|
-
__webpack_require__.n = (module)=>{
|
|
5
|
-
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
-
__webpack_require__.d(getter, {
|
|
7
|
-
a: getter
|
|
8
|
-
});
|
|
9
|
-
return getter;
|
|
10
|
-
};
|
|
11
|
-
})();
|
|
12
|
-
(()=>{
|
|
13
|
-
__webpack_require__.d = (exports1, definition)=>{
|
|
14
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
get: definition[key]
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
})();
|
|
20
|
-
(()=>{
|
|
21
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
|
-
})();
|
|
23
|
-
(()=>{
|
|
24
|
-
__webpack_require__.r = (exports1)=>{
|
|
25
|
-
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
|
-
value: 'Module'
|
|
27
|
-
});
|
|
28
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
29
|
-
value: true
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
})();
|
|
33
|
-
var __webpack_exports__ = {};
|
|
34
|
-
__webpack_require__.r(__webpack_exports__);
|
|
35
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
-
router: ()=>router
|
|
37
|
-
});
|
|
38
|
-
const server_namespaceObject = require("@orpc/server");
|
|
39
|
-
const contract_namespaceObject = require("@orpc/contract");
|
|
40
|
-
const external_zod_namespaceObject = require("zod");
|
|
41
|
-
const identifyUserSchema = external_zod_namespaceObject.z.object({
|
|
42
|
-
consentId: external_zod_namespaceObject.z.string(),
|
|
43
|
-
externalId: external_zod_namespaceObject.z.string(),
|
|
44
|
-
identityProvider: external_zod_namespaceObject.z.string().optional()
|
|
45
|
-
});
|
|
46
|
-
const identifyUserContract = contract_namespaceObject.oc.route({
|
|
47
|
-
method: 'PATCH',
|
|
48
|
-
path: '/consent/identify',
|
|
49
|
-
description: "Links a subject's external ID to a consent record by consent ID. This is used to identify a user across multiple devices and sessions.",
|
|
50
|
-
tags: [
|
|
51
|
-
'consent',
|
|
52
|
-
'cookie-banner'
|
|
53
|
-
]
|
|
54
|
-
}).errors({
|
|
55
|
-
CONSENT_NOT_FOUND: {
|
|
56
|
-
status: 404,
|
|
57
|
-
data: external_zod_namespaceObject.z.object({
|
|
58
|
-
consentId: external_zod_namespaceObject.z.string()
|
|
59
|
-
}),
|
|
60
|
-
error: 'Consent not found'
|
|
61
|
-
},
|
|
62
|
-
IDENTIFICATION_FAILED: {
|
|
63
|
-
status: 500,
|
|
64
|
-
data: external_zod_namespaceObject.z.object({
|
|
65
|
-
consentId: external_zod_namespaceObject.z.string()
|
|
66
|
-
}),
|
|
67
|
-
error: 'Failed to identify user'
|
|
68
|
-
}
|
|
69
|
-
}).input(identifyUserSchema).output(external_zod_namespaceObject.z.object({
|
|
70
|
-
success: external_zod_namespaceObject.z.boolean()
|
|
71
|
-
}));
|
|
72
|
-
const external_fumadb_namespaceObject = require("fumadb");
|
|
73
|
-
const schema_namespaceObject = require("fumadb/schema");
|
|
74
|
-
const auditLogTable = (0, schema_namespaceObject.table)('auditLog', {
|
|
75
|
-
id: (0, schema_namespaceObject.idColumn)('id', 'varchar(255)'),
|
|
76
|
-
entityType: (0, schema_namespaceObject.column)('entityType', 'string'),
|
|
77
|
-
entityId: (0, schema_namespaceObject.column)('entityId', 'string'),
|
|
78
|
-
actionType: (0, schema_namespaceObject.column)('actionType', 'string'),
|
|
79
|
-
subjectId: (0, schema_namespaceObject.column)('subjectId', 'string').nullable(),
|
|
80
|
-
ipAddress: (0, schema_namespaceObject.column)('ipAddress', 'string').nullable(),
|
|
81
|
-
userAgent: (0, schema_namespaceObject.column)('userAgent', 'string').nullable(),
|
|
82
|
-
changes: (0, schema_namespaceObject.column)('changes', 'json').nullable(),
|
|
83
|
-
metadata: (0, schema_namespaceObject.column)('metadata', 'json').nullable(),
|
|
84
|
-
createdAt: (0, schema_namespaceObject.column)('createdAt', 'timestamp').defaultTo$('now'),
|
|
85
|
-
eventTimezone: (0, schema_namespaceObject.column)('eventTimezone', 'string').defaultTo$(()=>'UTC')
|
|
86
|
-
});
|
|
87
|
-
external_zod_namespaceObject.z.object({
|
|
88
|
-
id: external_zod_namespaceObject.z.string(),
|
|
89
|
-
entityType: external_zod_namespaceObject.z.string(),
|
|
90
|
-
entityId: external_zod_namespaceObject.z.string(),
|
|
91
|
-
actionType: external_zod_namespaceObject.z.string(),
|
|
92
|
-
subjectId: external_zod_namespaceObject.z.string().optional(),
|
|
93
|
-
ipAddress: external_zod_namespaceObject.z.string().optional(),
|
|
94
|
-
userAgent: external_zod_namespaceObject.z.string().optional(),
|
|
95
|
-
changes: external_zod_namespaceObject.z.record(external_zod_namespaceObject.z.string(), external_zod_namespaceObject.z.unknown()).optional(),
|
|
96
|
-
metadata: external_zod_namespaceObject.z.record(external_zod_namespaceObject.z.string(), external_zod_namespaceObject.z.unknown()).optional(),
|
|
97
|
-
createdAt: external_zod_namespaceObject.z.date().prefault(()=>new Date()),
|
|
98
|
-
eventTimezone: external_zod_namespaceObject.z.string().prefault('UTC')
|
|
99
|
-
});
|
|
100
|
-
const consentTable = (0, schema_namespaceObject.table)('consent', {
|
|
101
|
-
id: (0, schema_namespaceObject.idColumn)('id', 'varchar(255)'),
|
|
102
|
-
subjectId: (0, schema_namespaceObject.column)('subjectId', 'string'),
|
|
103
|
-
domainId: (0, schema_namespaceObject.column)('domainId', 'string'),
|
|
104
|
-
policyId: (0, schema_namespaceObject.column)('policyId', 'string').nullable(),
|
|
105
|
-
purposeIds: (0, schema_namespaceObject.column)('purposeIds', 'json'),
|
|
106
|
-
metadata: (0, schema_namespaceObject.column)('metadata', 'json').nullable(),
|
|
107
|
-
ipAddress: (0, schema_namespaceObject.column)('ipAddress', 'string').nullable(),
|
|
108
|
-
userAgent: (0, schema_namespaceObject.column)('userAgent', 'string').nullable(),
|
|
109
|
-
status: (0, schema_namespaceObject.column)('status', 'string').defaultTo$(()=>'active'),
|
|
110
|
-
withdrawalReason: (0, schema_namespaceObject.column)('withdrawalReason', 'string').nullable(),
|
|
111
|
-
givenAt: (0, schema_namespaceObject.column)('givenAt', 'timestamp').defaultTo$('now'),
|
|
112
|
-
validUntil: (0, schema_namespaceObject.column)('validUntil', 'timestamp').nullable(),
|
|
113
|
-
isActive: (0, schema_namespaceObject.column)('isActive', 'bool').defaultTo$(()=>true)
|
|
114
|
-
});
|
|
115
|
-
const consentStatusSchema = external_zod_namespaceObject.z["enum"]([
|
|
116
|
-
'active',
|
|
117
|
-
'withdrawn',
|
|
118
|
-
'expired'
|
|
119
|
-
]);
|
|
120
|
-
external_zod_namespaceObject.z.object({
|
|
121
|
-
id: external_zod_namespaceObject.z.string(),
|
|
122
|
-
subjectId: external_zod_namespaceObject.z.string(),
|
|
123
|
-
domainId: external_zod_namespaceObject.z.string(),
|
|
124
|
-
purposeIds: external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.string()),
|
|
125
|
-
metadata: external_zod_namespaceObject.z.record(external_zod_namespaceObject.z.string(), external_zod_namespaceObject.z.unknown()).nullish(),
|
|
126
|
-
policyId: external_zod_namespaceObject.z.string().optional(),
|
|
127
|
-
ipAddress: external_zod_namespaceObject.z.string().nullish(),
|
|
128
|
-
userAgent: external_zod_namespaceObject.z.string().nullish(),
|
|
129
|
-
status: consentStatusSchema.prefault('active'),
|
|
130
|
-
withdrawalReason: external_zod_namespaceObject.z.string().nullish(),
|
|
131
|
-
givenAt: external_zod_namespaceObject.z.date().prefault(()=>new Date()),
|
|
132
|
-
validUntil: external_zod_namespaceObject.z.date().nullish(),
|
|
133
|
-
isActive: external_zod_namespaceObject.z.boolean().prefault(true)
|
|
134
|
-
});
|
|
135
|
-
const consentPolicyTable = (0, schema_namespaceObject.table)('consentPolicy', {
|
|
136
|
-
id: (0, schema_namespaceObject.idColumn)('id', 'varchar(255)'),
|
|
137
|
-
version: (0, schema_namespaceObject.column)('version', 'string'),
|
|
138
|
-
type: (0, schema_namespaceObject.column)('type', 'string'),
|
|
139
|
-
name: (0, schema_namespaceObject.column)('name', 'string'),
|
|
140
|
-
effectiveDate: (0, schema_namespaceObject.column)('effectiveDate', 'timestamp'),
|
|
141
|
-
expirationDate: (0, schema_namespaceObject.column)('expirationDate', 'timestamp').nullable(),
|
|
142
|
-
content: (0, schema_namespaceObject.column)('content', 'string'),
|
|
143
|
-
contentHash: (0, schema_namespaceObject.column)('contentHash', 'string'),
|
|
144
|
-
isActive: (0, schema_namespaceObject.column)('isActive', 'bool').defaultTo$(()=>true),
|
|
145
|
-
createdAt: (0, schema_namespaceObject.column)('createdAt', 'timestamp').defaultTo$('now')
|
|
146
|
-
});
|
|
147
|
-
const PolicyTypeSchema = external_zod_namespaceObject.z["enum"]([
|
|
148
|
-
'cookie_banner',
|
|
149
|
-
'privacy_policy',
|
|
150
|
-
'dpa',
|
|
151
|
-
'terms_and_conditions',
|
|
152
|
-
'marketing_communications',
|
|
153
|
-
'age_verification',
|
|
154
|
-
'other'
|
|
155
|
-
]);
|
|
156
|
-
external_zod_namespaceObject.z.object({
|
|
157
|
-
id: external_zod_namespaceObject.z.string(),
|
|
158
|
-
version: external_zod_namespaceObject.z.string(),
|
|
159
|
-
type: PolicyTypeSchema,
|
|
160
|
-
name: external_zod_namespaceObject.z.string(),
|
|
161
|
-
effectiveDate: external_zod_namespaceObject.z.date(),
|
|
162
|
-
expirationDate: external_zod_namespaceObject.z.date().nullish(),
|
|
163
|
-
content: external_zod_namespaceObject.z.string(),
|
|
164
|
-
contentHash: external_zod_namespaceObject.z.string(),
|
|
165
|
-
isActive: external_zod_namespaceObject.z.boolean().prefault(true),
|
|
166
|
-
createdAt: external_zod_namespaceObject.z.date().prefault(()=>new Date())
|
|
167
|
-
});
|
|
168
|
-
const consentPurposeTable = (0, schema_namespaceObject.table)('consentPurpose', {
|
|
169
|
-
id: (0, schema_namespaceObject.idColumn)('id', 'varchar(255)'),
|
|
170
|
-
code: (0, schema_namespaceObject.column)('code', 'string'),
|
|
171
|
-
name: (0, schema_namespaceObject.column)('name', 'string'),
|
|
172
|
-
description: (0, schema_namespaceObject.column)("description", 'string'),
|
|
173
|
-
isEssential: (0, schema_namespaceObject.column)('isEssential', 'bool'),
|
|
174
|
-
dataCategory: (0, schema_namespaceObject.column)('dataCategory', 'string').nullable(),
|
|
175
|
-
legalBasis: (0, schema_namespaceObject.column)('legalBasis', 'string').nullable(),
|
|
176
|
-
isActive: (0, schema_namespaceObject.column)('isActive', 'bool').defaultTo$(()=>true),
|
|
177
|
-
createdAt: (0, schema_namespaceObject.column)('createdAt', 'timestamp').defaultTo$('now'),
|
|
178
|
-
updatedAt: (0, schema_namespaceObject.column)('updatedAt', 'timestamp').defaultTo$('now')
|
|
179
|
-
});
|
|
180
|
-
external_zod_namespaceObject.z.object({
|
|
181
|
-
id: external_zod_namespaceObject.z.string(),
|
|
182
|
-
code: external_zod_namespaceObject.z.string(),
|
|
183
|
-
name: external_zod_namespaceObject.z.string(),
|
|
184
|
-
description: external_zod_namespaceObject.z.string(),
|
|
185
|
-
isEssential: external_zod_namespaceObject.z.boolean(),
|
|
186
|
-
dataCategory: external_zod_namespaceObject.z.string().nullish(),
|
|
187
|
-
legalBasis: external_zod_namespaceObject.z.string().nullish(),
|
|
188
|
-
isActive: external_zod_namespaceObject.z.boolean().prefault(true),
|
|
189
|
-
createdAt: external_zod_namespaceObject.z.date().prefault(()=>new Date()),
|
|
190
|
-
updatedAt: external_zod_namespaceObject.z.date().prefault(()=>new Date())
|
|
191
|
-
});
|
|
192
|
-
const consentRecordTable = (0, schema_namespaceObject.table)('consentRecord', {
|
|
193
|
-
id: (0, schema_namespaceObject.idColumn)('id', 'varchar(255)'),
|
|
194
|
-
subjectId: (0, schema_namespaceObject.column)('subjectId', 'string'),
|
|
195
|
-
consentId: (0, schema_namespaceObject.column)('consentId', 'string').nullable(),
|
|
196
|
-
actionType: (0, schema_namespaceObject.column)('actionType', 'string'),
|
|
197
|
-
details: (0, schema_namespaceObject.column)('details', 'json').nullable(),
|
|
198
|
-
createdAt: (0, schema_namespaceObject.column)('createdAt', 'timestamp').defaultTo$('now')
|
|
199
|
-
});
|
|
200
|
-
external_zod_namespaceObject.z.object({
|
|
201
|
-
id: external_zod_namespaceObject.z.string(),
|
|
202
|
-
subjectId: external_zod_namespaceObject.z.string(),
|
|
203
|
-
consentId: external_zod_namespaceObject.z.string().nullish(),
|
|
204
|
-
actionType: external_zod_namespaceObject.z.string(),
|
|
205
|
-
details: external_zod_namespaceObject.z.record(external_zod_namespaceObject.z.string(), external_zod_namespaceObject.z.unknown()).nullish(),
|
|
206
|
-
createdAt: external_zod_namespaceObject.z.date().prefault(()=>new Date())
|
|
207
|
-
});
|
|
208
|
-
const domainTable = (0, schema_namespaceObject.table)('domain', {
|
|
209
|
-
id: (0, schema_namespaceObject.idColumn)('id', 'varchar(255)'),
|
|
210
|
-
name: (0, schema_namespaceObject.column)('name', 'string').unique(),
|
|
211
|
-
description: (0, schema_namespaceObject.column)("description", 'string').nullable(),
|
|
212
|
-
allowedOrigins: (0, schema_namespaceObject.column)('allowedOrigins', 'json').nullable(),
|
|
213
|
-
isVerified: (0, schema_namespaceObject.column)('isVerified', 'bool').defaultTo$(()=>true),
|
|
214
|
-
isActive: (0, schema_namespaceObject.column)('isActive', 'bool').defaultTo$(()=>true),
|
|
215
|
-
createdAt: (0, schema_namespaceObject.column)('createdAt', 'timestamp').defaultTo$('now'),
|
|
216
|
-
updatedAt: (0, schema_namespaceObject.column)('updatedAt', 'timestamp').defaultTo$('now')
|
|
217
|
-
});
|
|
218
|
-
external_zod_namespaceObject.z.object({
|
|
219
|
-
id: external_zod_namespaceObject.z.string(),
|
|
220
|
-
name: external_zod_namespaceObject.z.string(),
|
|
221
|
-
description: external_zod_namespaceObject.z.string().nullish(),
|
|
222
|
-
allowedOrigins: external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.string()).nullish(),
|
|
223
|
-
isVerified: external_zod_namespaceObject.z.boolean().prefault(true),
|
|
224
|
-
isActive: external_zod_namespaceObject.z.boolean().prefault(true),
|
|
225
|
-
createdAt: external_zod_namespaceObject.z.date().prefault(()=>new Date()),
|
|
226
|
-
updatedAt: external_zod_namespaceObject.z.date().prefault(()=>new Date())
|
|
227
|
-
});
|
|
228
|
-
const subjectTable = (0, schema_namespaceObject.table)('subject', {
|
|
229
|
-
id: (0, schema_namespaceObject.idColumn)('id', 'varchar(255)'),
|
|
230
|
-
isIdentified: (0, schema_namespaceObject.column)('isIdentified', 'bool').defaultTo$(()=>false),
|
|
231
|
-
externalId: (0, schema_namespaceObject.column)('externalId', 'string').nullable(),
|
|
232
|
-
identityProvider: (0, schema_namespaceObject.column)('identityProvider', 'string').nullable(),
|
|
233
|
-
lastIpAddress: (0, schema_namespaceObject.column)('lastIpAddress', 'string').nullable(),
|
|
234
|
-
subjectTimezone: (0, schema_namespaceObject.column)('subjectTimezone', 'string').nullable(),
|
|
235
|
-
createdAt: (0, schema_namespaceObject.column)('createdAt', 'timestamp').defaultTo$('now'),
|
|
236
|
-
updatedAt: (0, schema_namespaceObject.column)('updatedAt', 'timestamp').defaultTo$('now')
|
|
237
|
-
});
|
|
238
|
-
external_zod_namespaceObject.z.object({
|
|
239
|
-
id: external_zod_namespaceObject.z.string(),
|
|
240
|
-
isIdentified: external_zod_namespaceObject.z.boolean().prefault(false),
|
|
241
|
-
externalId: external_zod_namespaceObject.z.string().nullish(),
|
|
242
|
-
identityProvider: external_zod_namespaceObject.z.string().nullish(),
|
|
243
|
-
lastIpAddress: external_zod_namespaceObject.z.string().optional(),
|
|
244
|
-
subjectTimezone: external_zod_namespaceObject.z.string().nullish(),
|
|
245
|
-
createdAt: external_zod_namespaceObject.z.date().prefault(()=>new Date()),
|
|
246
|
-
updatedAt: external_zod_namespaceObject.z.date().prefault(()=>new Date())
|
|
247
|
-
});
|
|
248
|
-
const v1 = (0, schema_namespaceObject.schema)({
|
|
249
|
-
version: '1.0.0',
|
|
250
|
-
tables: {
|
|
251
|
-
subject: subjectTable,
|
|
252
|
-
domain: domainTable,
|
|
253
|
-
consentPolicy: consentPolicyTable,
|
|
254
|
-
consentPurpose: consentPurposeTable,
|
|
255
|
-
consent: consentTable,
|
|
256
|
-
auditLog: auditLogTable,
|
|
257
|
-
consentRecord: consentRecordTable
|
|
258
|
-
},
|
|
259
|
-
relations: {
|
|
260
|
-
subject: ({ many })=>({
|
|
261
|
-
consents: many('consent'),
|
|
262
|
-
consentRecords: many('consentRecord'),
|
|
263
|
-
auditLogs: many('auditLog')
|
|
264
|
-
}),
|
|
265
|
-
domain: ({ many })=>({
|
|
266
|
-
consents: many('consent')
|
|
267
|
-
}),
|
|
268
|
-
consentPolicy: ({ many })=>({
|
|
269
|
-
consents: many('consent')
|
|
270
|
-
}),
|
|
271
|
-
consentPurpose: ()=>({}),
|
|
272
|
-
consent: ({ one, many })=>({
|
|
273
|
-
subject: one('subject', [
|
|
274
|
-
'subjectId',
|
|
275
|
-
'id'
|
|
276
|
-
]).foreignKey(),
|
|
277
|
-
domain: one('domain', [
|
|
278
|
-
'domainId',
|
|
279
|
-
'id'
|
|
280
|
-
]).foreignKey(),
|
|
281
|
-
policy: one('consentPolicy', [
|
|
282
|
-
'policyId',
|
|
283
|
-
'id'
|
|
284
|
-
]).foreignKey(),
|
|
285
|
-
consentRecords: many('consentRecord')
|
|
286
|
-
}),
|
|
287
|
-
consentRecord: ({ one })=>({
|
|
288
|
-
subject: one('subject', [
|
|
289
|
-
'subjectId',
|
|
290
|
-
'id'
|
|
291
|
-
]).foreignKey(),
|
|
292
|
-
consent: one('consent', [
|
|
293
|
-
'consentId',
|
|
294
|
-
'id'
|
|
295
|
-
]).foreignKey()
|
|
296
|
-
}),
|
|
297
|
-
auditLog: ({ one })=>({
|
|
298
|
-
subject: one('subject', [
|
|
299
|
-
'subjectId',
|
|
300
|
-
'id'
|
|
301
|
-
]).foreignKey()
|
|
302
|
-
})
|
|
303
|
-
}
|
|
304
|
-
});
|
|
305
|
-
(0, external_fumadb_namespaceObject.fumadb)({
|
|
306
|
-
namespace: 'c15t',
|
|
307
|
-
schemas: [
|
|
308
|
-
v1
|
|
309
|
-
]
|
|
310
|
-
});
|
|
311
|
-
const baseConsentSchema = external_zod_namespaceObject.z.object({
|
|
312
|
-
subjectId: external_zod_namespaceObject.z.string().optional(),
|
|
313
|
-
externalSubjectId: external_zod_namespaceObject.z.string().optional(),
|
|
314
|
-
identityProvider: external_zod_namespaceObject.z.string().optional(),
|
|
315
|
-
domain: external_zod_namespaceObject.z.string(),
|
|
316
|
-
type: PolicyTypeSchema,
|
|
317
|
-
metadata: external_zod_namespaceObject.z.record(external_zod_namespaceObject.z.string(), external_zod_namespaceObject.z.unknown()).optional()
|
|
318
|
-
});
|
|
319
|
-
const cookieBannerSchema = baseConsentSchema.extend({
|
|
320
|
-
type: external_zod_namespaceObject.z.literal('cookie_banner'),
|
|
321
|
-
preferences: external_zod_namespaceObject.z.record(external_zod_namespaceObject.z.string(), external_zod_namespaceObject.z.boolean())
|
|
322
|
-
});
|
|
323
|
-
const policyBasedSchema = baseConsentSchema.extend({
|
|
324
|
-
type: external_zod_namespaceObject.z["enum"]([
|
|
325
|
-
'privacy_policy',
|
|
326
|
-
'dpa',
|
|
327
|
-
'terms_and_conditions'
|
|
328
|
-
]),
|
|
329
|
-
policyId: external_zod_namespaceObject.z.string().optional(),
|
|
330
|
-
preferences: external_zod_namespaceObject.z.record(external_zod_namespaceObject.z.string(), external_zod_namespaceObject.z.boolean()).optional()
|
|
331
|
-
});
|
|
332
|
-
const otherConsentSchema = baseConsentSchema.extend({
|
|
333
|
-
type: external_zod_namespaceObject.z["enum"]([
|
|
334
|
-
'marketing_communications',
|
|
335
|
-
'age_verification',
|
|
336
|
-
'other'
|
|
337
|
-
]),
|
|
338
|
-
preferences: external_zod_namespaceObject.z.record(external_zod_namespaceObject.z.string(), external_zod_namespaceObject.z.boolean()).optional()
|
|
339
|
-
});
|
|
340
|
-
const postConsentContract = contract_namespaceObject.oc.route({
|
|
341
|
-
method: 'POST',
|
|
342
|
-
path: '/consent/set',
|
|
343
|
-
description: `Records a user's consent preferences and creates necessary consent records.
|
|
344
|
-
This endpoint handles various types of consent submissions:
|
|
345
|
-
|
|
346
|
-
1. Cookie Banner Consent:
|
|
347
|
-
- Records granular cookie preferences
|
|
348
|
-
- Supports multiple consent purposes
|
|
349
|
-
- Creates audit trail for compliance
|
|
350
|
-
|
|
351
|
-
2. Policy-Based Consent:
|
|
352
|
-
- Privacy Policy acceptance
|
|
353
|
-
- Data Processing Agreement (DPA) consent
|
|
354
|
-
- Terms and Conditions acceptance
|
|
355
|
-
- Links consent to specific policy versions
|
|
356
|
-
|
|
357
|
-
3. Other Consent Types:
|
|
358
|
-
- Marketing communications preferences
|
|
359
|
-
- Age verification consent
|
|
360
|
-
- Custom consent types
|
|
361
|
-
|
|
362
|
-
The endpoint performs the following operations:
|
|
363
|
-
- Creates or retrieves subject records
|
|
364
|
-
- Validates domain and policy information
|
|
365
|
-
- Creates consent records with audit trails
|
|
366
|
-
- Records consent purposes and preferences
|
|
367
|
-
- Generates audit logs for compliance
|
|
368
|
-
|
|
369
|
-
Use this endpoint to record user consent and maintain a compliant consent management system.`,
|
|
370
|
-
tags: [
|
|
371
|
-
'consent',
|
|
372
|
-
'cookie-banner'
|
|
373
|
-
]
|
|
374
|
-
}).errors({
|
|
375
|
-
INPUT_VALIDATION_FAILED: {
|
|
376
|
-
status: 422,
|
|
377
|
-
data: external_zod_namespaceObject.z.object({
|
|
378
|
-
formErrors: external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.string()),
|
|
379
|
-
fieldErrors: external_zod_namespaceObject.z.record(external_zod_namespaceObject.z.string(), external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.string()))
|
|
380
|
-
}),
|
|
381
|
-
error: 'Invalid input parameters'
|
|
382
|
-
},
|
|
383
|
-
SUBJECT_CREATION_FAILED: {
|
|
384
|
-
status: 400,
|
|
385
|
-
data: external_zod_namespaceObject.z.object({
|
|
386
|
-
subjectId: external_zod_namespaceObject.z.string().optional(),
|
|
387
|
-
externalSubjectId: external_zod_namespaceObject.z.string().optional()
|
|
388
|
-
}),
|
|
389
|
-
error: 'Failed to create or find subject'
|
|
390
|
-
},
|
|
391
|
-
DOMAIN_CREATION_FAILED: {
|
|
392
|
-
status: 500,
|
|
393
|
-
data: external_zod_namespaceObject.z.object({
|
|
394
|
-
domain: external_zod_namespaceObject.z.string()
|
|
395
|
-
}),
|
|
396
|
-
error: 'Failed to create or find domain'
|
|
397
|
-
},
|
|
398
|
-
POLICY_NOT_FOUND: {
|
|
399
|
-
status: 404,
|
|
400
|
-
data: external_zod_namespaceObject.z.object({
|
|
401
|
-
policyId: external_zod_namespaceObject.z.string(),
|
|
402
|
-
type: external_zod_namespaceObject.z.string()
|
|
403
|
-
}),
|
|
404
|
-
error: 'Policy not found'
|
|
405
|
-
},
|
|
406
|
-
POLICY_INACTIVE: {
|
|
407
|
-
status: 409,
|
|
408
|
-
data: external_zod_namespaceObject.z.object({
|
|
409
|
-
policyId: external_zod_namespaceObject.z.string(),
|
|
410
|
-
type: external_zod_namespaceObject.z.string()
|
|
411
|
-
}),
|
|
412
|
-
error: 'Policy is not active'
|
|
413
|
-
},
|
|
414
|
-
POLICY_CREATION_FAILED: {
|
|
415
|
-
status: 500,
|
|
416
|
-
data: external_zod_namespaceObject.z.object({
|
|
417
|
-
type: external_zod_namespaceObject.z.string()
|
|
418
|
-
}),
|
|
419
|
-
error: 'Failed to create or find policy'
|
|
420
|
-
},
|
|
421
|
-
PURPOSE_CREATION_FAILED: {
|
|
422
|
-
status: 500,
|
|
423
|
-
data: external_zod_namespaceObject.z.object({
|
|
424
|
-
purposeCode: external_zod_namespaceObject.z.string()
|
|
425
|
-
}),
|
|
426
|
-
error: 'Failed to create consent purpose'
|
|
427
|
-
},
|
|
428
|
-
CONSENT_CREATION_FAILED: {
|
|
429
|
-
status: 500,
|
|
430
|
-
data: external_zod_namespaceObject.z.object({
|
|
431
|
-
subjectId: external_zod_namespaceObject.z.string(),
|
|
432
|
-
domain: external_zod_namespaceObject.z.string()
|
|
433
|
-
}),
|
|
434
|
-
error: 'Failed to create consent record'
|
|
435
|
-
}
|
|
436
|
-
}).input(external_zod_namespaceObject.z.discriminatedUnion('type', [
|
|
437
|
-
cookieBannerSchema,
|
|
438
|
-
policyBasedSchema,
|
|
439
|
-
otherConsentSchema
|
|
440
|
-
])).output(external_zod_namespaceObject.z.object({
|
|
441
|
-
id: external_zod_namespaceObject.z.string(),
|
|
442
|
-
subjectId: external_zod_namespaceObject.z.string().optional(),
|
|
443
|
-
externalSubjectId: external_zod_namespaceObject.z.string().optional(),
|
|
444
|
-
domainId: external_zod_namespaceObject.z.string(),
|
|
445
|
-
domain: external_zod_namespaceObject.z.string(),
|
|
446
|
-
type: PolicyTypeSchema,
|
|
447
|
-
status: external_zod_namespaceObject.z.string(),
|
|
448
|
-
recordId: external_zod_namespaceObject.z.string(),
|
|
449
|
-
metadata: external_zod_namespaceObject.z.record(external_zod_namespaceObject.z.string(), external_zod_namespaceObject.z.unknown()).optional(),
|
|
450
|
-
givenAt: external_zod_namespaceObject.z.date()
|
|
451
|
-
}));
|
|
452
|
-
const types_branding = [
|
|
453
|
-
'c15t',
|
|
454
|
-
'consent',
|
|
455
|
-
'none'
|
|
456
|
-
];
|
|
457
|
-
const JurisdictionMessages = {
|
|
458
|
-
GDPR: 'GDPR or equivalent regulations require a cookie banner.',
|
|
459
|
-
CH: 'Switzerland requires similar data protection measures.',
|
|
460
|
-
BR: "Brazil's LGPD requires consent for cookies.",
|
|
461
|
-
PIPEDA: 'PIPEDA requires consent for data collection.',
|
|
462
|
-
AU: "Australia's Privacy Act mandates transparency about data collection.",
|
|
463
|
-
APPI: "Japan's APPI requires consent for data collection.",
|
|
464
|
-
PIPA: "South Korea's PIPA requires consent for data collection.",
|
|
465
|
-
NONE: 'No specific requirements'
|
|
466
|
-
};
|
|
467
|
-
const JurisdictionCodeSchema = external_zod_namespaceObject.z["enum"]([
|
|
468
|
-
'GDPR',
|
|
469
|
-
'CH',
|
|
470
|
-
'BR',
|
|
471
|
-
'PIPEDA',
|
|
472
|
-
'AU',
|
|
473
|
-
'APPI',
|
|
474
|
-
'PIPA',
|
|
475
|
-
'NONE'
|
|
476
|
-
]);
|
|
477
|
-
const JurisdictionInfoSchema = external_zod_namespaceObject.z.object({
|
|
478
|
-
code: JurisdictionCodeSchema,
|
|
479
|
-
message: external_zod_namespaceObject.z.string()
|
|
480
|
-
});
|
|
481
|
-
const TitleDescriptionSchema = external_zod_namespaceObject.z.object({
|
|
482
|
-
title: external_zod_namespaceObject.z.string(),
|
|
483
|
-
description: external_zod_namespaceObject.z.string()
|
|
484
|
-
});
|
|
485
|
-
const CompleteTranslationsSchema = external_zod_namespaceObject.z.object({
|
|
486
|
-
common: external_zod_namespaceObject.z.object({
|
|
487
|
-
acceptAll: external_zod_namespaceObject.z.string(),
|
|
488
|
-
rejectAll: external_zod_namespaceObject.z.string(),
|
|
489
|
-
customize: external_zod_namespaceObject.z.string(),
|
|
490
|
-
save: external_zod_namespaceObject.z.string()
|
|
491
|
-
}),
|
|
492
|
-
cookieBanner: TitleDescriptionSchema,
|
|
493
|
-
consentManagerDialog: TitleDescriptionSchema,
|
|
494
|
-
consentTypes: external_zod_namespaceObject.z.object({
|
|
495
|
-
experience: TitleDescriptionSchema,
|
|
496
|
-
functionality: TitleDescriptionSchema,
|
|
497
|
-
marketing: TitleDescriptionSchema,
|
|
498
|
-
measurement: TitleDescriptionSchema,
|
|
499
|
-
necessary: TitleDescriptionSchema
|
|
500
|
-
}),
|
|
501
|
-
frame: external_zod_namespaceObject.z.object({
|
|
502
|
-
title: external_zod_namespaceObject.z.string(),
|
|
503
|
-
actionButton: external_zod_namespaceObject.z.string()
|
|
504
|
-
}),
|
|
505
|
-
legalLinks: external_zod_namespaceObject.z.object({
|
|
506
|
-
privacyPolicy: external_zod_namespaceObject.z.string(),
|
|
507
|
-
termsOfService: external_zod_namespaceObject.z.string(),
|
|
508
|
-
cookiePolicy: external_zod_namespaceObject.z.string()
|
|
509
|
-
})
|
|
510
|
-
});
|
|
511
|
-
const PartialTranslationsSchema = external_zod_namespaceObject.z.object({
|
|
512
|
-
common: external_zod_namespaceObject.z.object({
|
|
513
|
-
acceptAll: external_zod_namespaceObject.z.string().optional(),
|
|
514
|
-
rejectAll: external_zod_namespaceObject.z.string().optional(),
|
|
515
|
-
customize: external_zod_namespaceObject.z.string().optional(),
|
|
516
|
-
save: external_zod_namespaceObject.z.string().optional()
|
|
517
|
-
}).partial(),
|
|
518
|
-
cookieBanner: TitleDescriptionSchema.partial(),
|
|
519
|
-
consentManagerDialog: TitleDescriptionSchema.partial(),
|
|
520
|
-
consentTypes: external_zod_namespaceObject.z.object({
|
|
521
|
-
experience: TitleDescriptionSchema.partial(),
|
|
522
|
-
functionality: TitleDescriptionSchema.partial(),
|
|
523
|
-
marketing: TitleDescriptionSchema.partial(),
|
|
524
|
-
measurement: TitleDescriptionSchema.partial(),
|
|
525
|
-
necessary: TitleDescriptionSchema.partial()
|
|
526
|
-
}).partial(),
|
|
527
|
-
frame: external_zod_namespaceObject.z.object({
|
|
528
|
-
title: external_zod_namespaceObject.z.string().optional(),
|
|
529
|
-
actionButton: external_zod_namespaceObject.z.string().optional()
|
|
530
|
-
}).partial().optional(),
|
|
531
|
-
legalLinks: external_zod_namespaceObject.z.object({
|
|
532
|
-
privacyPolicy: external_zod_namespaceObject.z.string().optional(),
|
|
533
|
-
termsOfService: external_zod_namespaceObject.z.string().optional(),
|
|
534
|
-
cookiePolicy: external_zod_namespaceObject.z.string().optional()
|
|
535
|
-
}).partial().optional()
|
|
536
|
-
});
|
|
537
|
-
const TranslationsSchema = external_zod_namespaceObject.z.union([
|
|
538
|
-
CompleteTranslationsSchema,
|
|
539
|
-
PartialTranslationsSchema
|
|
540
|
-
]);
|
|
541
|
-
const showConsentBannerContract = contract_namespaceObject.oc.route({
|
|
542
|
-
method: 'GET',
|
|
543
|
-
path: '/show-consent-banner',
|
|
544
|
-
description: `Determines if a user should see a consent banner based on their location and applicable privacy regulations.
|
|
545
|
-
This endpoint performs the following checks:
|
|
546
|
-
|
|
547
|
-
1. Detects the user's location using various header information:
|
|
548
|
-
- Cloudflare country headers
|
|
549
|
-
- Vercel IP country headers
|
|
550
|
-
- AWS CloudFront headers
|
|
551
|
-
- Custom country code headers
|
|
552
|
-
|
|
553
|
-
2. Determines the applicable jurisdiction based on the location:
|
|
554
|
-
- GDPR (EU/EEA/UK)
|
|
555
|
-
- Swiss Data Protection Act
|
|
556
|
-
- LGPD (Brazil)
|
|
557
|
-
- PIPEDA (Canada)
|
|
558
|
-
- Australian Privacy Principles
|
|
559
|
-
- APPI (Japan)
|
|
560
|
-
- PIPA (South Korea)
|
|
561
|
-
|
|
562
|
-
3. Returns detailed information about:
|
|
563
|
-
- Whether to show the consent banner
|
|
564
|
-
- The applicable jurisdiction and its requirements
|
|
565
|
-
- The user's detected location (country and region)
|
|
566
|
-
|
|
567
|
-
Use this endpoint to implement geo-targeted consent banners and ensure compliance with regional privacy regulations.`,
|
|
568
|
-
tags: [
|
|
569
|
-
'cookie-banner'
|
|
570
|
-
]
|
|
571
|
-
}).output(external_zod_namespaceObject.z.object({
|
|
572
|
-
showConsentBanner: external_zod_namespaceObject.z.boolean(),
|
|
573
|
-
jurisdiction: JurisdictionInfoSchema,
|
|
574
|
-
location: external_zod_namespaceObject.z.object({
|
|
575
|
-
countryCode: external_zod_namespaceObject.z.string().nullable(),
|
|
576
|
-
regionCode: external_zod_namespaceObject.z.string().nullable()
|
|
577
|
-
}),
|
|
578
|
-
translations: external_zod_namespaceObject.z.object({
|
|
579
|
-
language: external_zod_namespaceObject.z.string(),
|
|
580
|
-
translations: TranslationsSchema
|
|
581
|
-
}),
|
|
582
|
-
branding: external_zod_namespaceObject.z["enum"](types_branding)
|
|
583
|
-
}));
|
|
584
|
-
const verifyConsentInputSchema = external_zod_namespaceObject.z.strictObject({
|
|
585
|
-
subjectId: external_zod_namespaceObject.z.string().optional(),
|
|
586
|
-
externalSubjectId: external_zod_namespaceObject.z.string().optional(),
|
|
587
|
-
domain: external_zod_namespaceObject.z.string(),
|
|
588
|
-
type: PolicyTypeSchema,
|
|
589
|
-
policyId: external_zod_namespaceObject.z.string().optional(),
|
|
590
|
-
preferences: external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.string()).optional()
|
|
591
|
-
});
|
|
592
|
-
const verify_contract_consentSchema = external_zod_namespaceObject.z.looseObject({
|
|
593
|
-
id: external_zod_namespaceObject.z.string(),
|
|
594
|
-
purposeIds: external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.string())
|
|
595
|
-
});
|
|
596
|
-
const verifyConsentContract = contract_namespaceObject.oc.route({
|
|
597
|
-
method: 'POST',
|
|
598
|
-
path: '/consent/verify',
|
|
599
|
-
description: `Verifies if a user has given valid consent for a specific policy and domain.
|
|
600
|
-
This endpoint performs comprehensive consent verification by:
|
|
601
|
-
|
|
602
|
-
1. Validating the subject's identity (using subjectId or externalSubjectId)
|
|
603
|
-
2. Verifying the domain's existence and validity
|
|
604
|
-
3. Checking if the specified policy exists and is active
|
|
605
|
-
4. Validating that all required purposes have been consented to
|
|
606
|
-
5. Ensuring the consent record is current and valid
|
|
607
|
-
|
|
608
|
-
The endpoint supports different types of consent verification:
|
|
609
|
-
- Cookie banner consent verification
|
|
610
|
-
- Privacy policy consent verification
|
|
611
|
-
- Terms and conditions verification
|
|
612
|
-
- Marketing communications consent verification
|
|
613
|
-
- Age verification
|
|
614
|
-
- Custom consent types
|
|
615
|
-
|
|
616
|
-
Use this endpoint to ensure compliance with privacy regulations and to verify user consent before processing personal data.`,
|
|
617
|
-
tags: [
|
|
618
|
-
'consent'
|
|
619
|
-
]
|
|
620
|
-
}).errors({
|
|
621
|
-
INPUT_VALIDATION_FAILED: {
|
|
622
|
-
status: 422,
|
|
623
|
-
data: external_zod_namespaceObject.z.object({
|
|
624
|
-
formErrors: external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.string()),
|
|
625
|
-
fieldErrors: external_zod_namespaceObject.z.record(external_zod_namespaceObject.z.string(), external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.string()).optional())
|
|
626
|
-
}),
|
|
627
|
-
error: 'Invalid input parameters'
|
|
628
|
-
},
|
|
629
|
-
SUBJECT_NOT_FOUND: {
|
|
630
|
-
status: 404,
|
|
631
|
-
data: external_zod_namespaceObject.z.object({
|
|
632
|
-
subjectId: external_zod_namespaceObject.z.string().optional(),
|
|
633
|
-
externalSubjectId: external_zod_namespaceObject.z.string().optional()
|
|
634
|
-
}),
|
|
635
|
-
error: 'Subject not found'
|
|
636
|
-
},
|
|
637
|
-
DOMAIN_NOT_FOUND: {
|
|
638
|
-
status: 404,
|
|
639
|
-
data: external_zod_namespaceObject.z.object({
|
|
640
|
-
domain: external_zod_namespaceObject.z.string()
|
|
641
|
-
}),
|
|
642
|
-
error: 'Domain not found'
|
|
643
|
-
},
|
|
644
|
-
POLICY_NOT_FOUND: {
|
|
645
|
-
status: 404,
|
|
646
|
-
data: external_zod_namespaceObject.z.object({
|
|
647
|
-
policyId: external_zod_namespaceObject.z.string(),
|
|
648
|
-
type: external_zod_namespaceObject.z.string()
|
|
649
|
-
}),
|
|
650
|
-
error: 'Policy not found or invalid'
|
|
651
|
-
},
|
|
652
|
-
PURPOSES_NOT_FOUND: {
|
|
653
|
-
status: 404,
|
|
654
|
-
data: external_zod_namespaceObject.z.object({
|
|
655
|
-
preferences: external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.string()),
|
|
656
|
-
foundPurposes: external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.string())
|
|
657
|
-
}),
|
|
658
|
-
error: 'Could not find all specified purposes'
|
|
659
|
-
},
|
|
660
|
-
COOKIE_BANNER_PREFERENCES_REQUIRED: {
|
|
661
|
-
status: 400,
|
|
662
|
-
data: external_zod_namespaceObject.z.object({
|
|
663
|
-
type: external_zod_namespaceObject.z.literal('cookie_banner')
|
|
664
|
-
}),
|
|
665
|
-
error: 'Preferences are required for cookie banner consent'
|
|
666
|
-
},
|
|
667
|
-
NO_CONSENT_FOUND: {
|
|
668
|
-
status: 404,
|
|
669
|
-
data: external_zod_namespaceObject.z.object({
|
|
670
|
-
policyId: external_zod_namespaceObject.z.string(),
|
|
671
|
-
subjectId: external_zod_namespaceObject.z.string(),
|
|
672
|
-
domainId: external_zod_namespaceObject.z.string()
|
|
673
|
-
}),
|
|
674
|
-
error: 'No consent found for the given policy'
|
|
675
|
-
}
|
|
676
|
-
}).input(verifyConsentInputSchema).output(external_zod_namespaceObject.z.object({
|
|
677
|
-
isValid: external_zod_namespaceObject.z.boolean(),
|
|
678
|
-
reasons: external_zod_namespaceObject.z.array(external_zod_namespaceObject.z.string()).optional(),
|
|
679
|
-
consent: verify_contract_consentSchema.optional()
|
|
680
|
-
}));
|
|
681
|
-
const consentContracts = {
|
|
682
|
-
post: postConsentContract,
|
|
683
|
-
showBanner: showConsentBannerContract,
|
|
684
|
-
verify: verifyConsentContract,
|
|
685
|
-
identify: identifyUserContract
|
|
686
|
-
};
|
|
687
|
-
const statusContract = contract_namespaceObject.oc.route({
|
|
688
|
-
method: 'GET',
|
|
689
|
-
path: '/status',
|
|
690
|
-
description: `Returns the current operational status and health metrics of the service.
|
|
691
|
-
This endpoint provides real-time information about:
|
|
692
|
-
- Overall service status (ok/error)
|
|
693
|
-
- Current API version
|
|
694
|
-
- Server timestamp
|
|
695
|
-
- Storage system status and availability
|
|
696
|
-
- Client information (IP, User Agent, Region)
|
|
697
|
-
|
|
698
|
-
Use this endpoint for health checks, monitoring, and service status verification.`,
|
|
699
|
-
tags: [
|
|
700
|
-
'meta'
|
|
701
|
-
]
|
|
702
|
-
}).output(external_zod_namespaceObject.z.object({
|
|
703
|
-
status: external_zod_namespaceObject.z["enum"]([
|
|
704
|
-
'ok',
|
|
705
|
-
'error'
|
|
706
|
-
]),
|
|
707
|
-
version: external_zod_namespaceObject.z.string(),
|
|
708
|
-
timestamp: external_zod_namespaceObject.z.date(),
|
|
709
|
-
client: external_zod_namespaceObject.z.object({
|
|
710
|
-
ip: external_zod_namespaceObject.z.string().nullable(),
|
|
711
|
-
userAgent: external_zod_namespaceObject.z.string().nullable(),
|
|
712
|
-
region: external_zod_namespaceObject.z.object({
|
|
713
|
-
countryCode: external_zod_namespaceObject.z.string().nullable(),
|
|
714
|
-
regionCode: external_zod_namespaceObject.z.string().nullable()
|
|
715
|
-
})
|
|
716
|
-
})
|
|
717
|
-
}));
|
|
718
|
-
const metaContracts = {
|
|
719
|
-
status: statusContract
|
|
720
|
-
};
|
|
721
|
-
const config = {
|
|
722
|
-
consent: consentContracts,
|
|
723
|
-
meta: metaContracts
|
|
724
|
-
};
|
|
725
|
-
const os = (0, server_namespaceObject.implement)(config);
|
|
726
|
-
const external_base_x_namespaceObject = require("base-x");
|
|
727
|
-
var external_base_x_default = /*#__PURE__*/ __webpack_require__.n(external_base_x_namespaceObject);
|
|
728
|
-
const prefixes = {
|
|
729
|
-
auditLog: 'log',
|
|
730
|
-
consent: 'cns',
|
|
731
|
-
consentPolicy: 'pol',
|
|
732
|
-
consentPurpose: 'pur',
|
|
733
|
-
consentRecord: 'rec',
|
|
734
|
-
domain: 'dom',
|
|
735
|
-
subject: 'sub'
|
|
736
|
-
};
|
|
737
|
-
const b58 = external_base_x_default()('123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz');
|
|
738
|
-
function generateId(model) {
|
|
739
|
-
const buf = crypto.getRandomValues(new Uint8Array(20));
|
|
740
|
-
const prefix = prefixes[model];
|
|
741
|
-
const EPOCH_TIMESTAMP = 1700000000000;
|
|
742
|
-
const t = Date.now() - EPOCH_TIMESTAMP;
|
|
743
|
-
const high = Math.floor(t / 0x100000000);
|
|
744
|
-
const low = t >>> 0;
|
|
745
|
-
buf[0] = high >>> 24 & 255;
|
|
746
|
-
buf[1] = high >>> 16 & 255;
|
|
747
|
-
buf[2] = high >>> 8 & 255;
|
|
748
|
-
buf[3] = 255 & high;
|
|
749
|
-
buf[4] = low >>> 24 & 255;
|
|
750
|
-
buf[5] = low >>> 16 & 255;
|
|
751
|
-
buf[6] = low >>> 8 & 255;
|
|
752
|
-
buf[7] = 255 & low;
|
|
753
|
-
return `${prefix}_${b58.encode(buf)}`;
|
|
754
|
-
}
|
|
755
|
-
async function generateUniqueId(db, model, ctx, options = {}) {
|
|
756
|
-
const { maxRetries = 10, attempt = 0, baseDelay = 5 } = options;
|
|
757
|
-
if (attempt >= maxRetries) {
|
|
758
|
-
const error = new Error(`Failed to generate unique ID for ${model} after ${maxRetries} attempts`);
|
|
759
|
-
ctx?.logger?.error?.('ID generation failed', {
|
|
760
|
-
model,
|
|
761
|
-
maxRetries
|
|
762
|
-
});
|
|
763
|
-
throw error;
|
|
764
|
-
}
|
|
765
|
-
const id = generateId(model);
|
|
766
|
-
try {
|
|
767
|
-
const existing = await db.findFirst(model, {
|
|
768
|
-
where: (b)=>b('id', '=', id)
|
|
769
|
-
});
|
|
770
|
-
if (existing) {
|
|
771
|
-
ctx?.logger?.debug?.('ID conflict detected', {
|
|
772
|
-
id,
|
|
773
|
-
model,
|
|
774
|
-
attempt: attempt + 1,
|
|
775
|
-
maxRetries
|
|
776
|
-
});
|
|
777
|
-
const delay = Math.min(baseDelay * 2 ** attempt, 1000);
|
|
778
|
-
await new Promise((resolve)=>setTimeout(resolve, delay));
|
|
779
|
-
return generateUniqueId(db, model, ctx, {
|
|
780
|
-
maxRetries,
|
|
781
|
-
attempt: attempt + 1,
|
|
782
|
-
baseDelay
|
|
783
|
-
});
|
|
784
|
-
}
|
|
785
|
-
return id;
|
|
786
|
-
} catch (error) {
|
|
787
|
-
ctx?.logger?.error?.('Error checking ID uniqueness', {
|
|
788
|
-
error: error.message,
|
|
789
|
-
model,
|
|
790
|
-
attempt
|
|
791
|
-
});
|
|
792
|
-
if (attempt < maxRetries - 1) {
|
|
793
|
-
const delay = Math.min(baseDelay * 2 ** attempt, 2000);
|
|
794
|
-
await new Promise((resolve)=>setTimeout(resolve, delay));
|
|
795
|
-
return generateUniqueId(db, model, ctx, {
|
|
796
|
-
maxRetries,
|
|
797
|
-
attempt: attempt + 1,
|
|
798
|
-
baseDelay
|
|
799
|
-
});
|
|
800
|
-
}
|
|
801
|
-
throw error;
|
|
802
|
-
}
|
|
803
|
-
}
|
|
804
|
-
const identifyUser = os.consent.identify.handler(async ({ input, context })=>{
|
|
805
|
-
const typedContext = context;
|
|
806
|
-
const { db, logger } = typedContext;
|
|
807
|
-
logger.info('Handling identify-user request');
|
|
808
|
-
const { consentId, externalId, identityProvider = 'external' } = input;
|
|
809
|
-
const consent = await db.findFirst('consent', {
|
|
810
|
-
where: (b)=>b('id', '=', consentId)
|
|
811
|
-
});
|
|
812
|
-
if (!consent) throw new server_namespaceObject.ORPCError('CONSENT_NOT_FOUND', {
|
|
813
|
-
data: {
|
|
814
|
-
consentId
|
|
815
|
-
}
|
|
816
|
-
});
|
|
817
|
-
await db.transaction(async (tx)=>{
|
|
818
|
-
const existingSubject = await tx.findFirst('subject', {
|
|
819
|
-
where: (b)=>b.and(b('externalId', '=', externalId), b('id', '!=', consent.subjectId))
|
|
820
|
-
});
|
|
821
|
-
if (existingSubject) {
|
|
822
|
-
const currentSubjectId = consent.subjectId;
|
|
823
|
-
const oldSubjectId = existingSubject.id;
|
|
824
|
-
logger.info('Merging subjects', {
|
|
825
|
-
currentSubjectId,
|
|
826
|
-
oldSubjectId,
|
|
827
|
-
externalId,
|
|
828
|
-
identityProvider
|
|
829
|
-
});
|
|
830
|
-
await tx.updateMany('consent', {
|
|
831
|
-
where: (b)=>b('subjectId', '=', currentSubjectId),
|
|
832
|
-
set: {
|
|
833
|
-
subjectId: oldSubjectId
|
|
834
|
-
}
|
|
835
|
-
});
|
|
836
|
-
await tx.updateMany('consentRecord', {
|
|
837
|
-
where: (b)=>b('subjectId', '=', currentSubjectId),
|
|
838
|
-
set: {
|
|
839
|
-
subjectId: oldSubjectId
|
|
840
|
-
}
|
|
841
|
-
});
|
|
842
|
-
await tx.updateMany('auditLog', {
|
|
843
|
-
where: (b)=>b('subjectId', '=', currentSubjectId),
|
|
844
|
-
set: {
|
|
845
|
-
subjectId: oldSubjectId
|
|
846
|
-
}
|
|
847
|
-
});
|
|
848
|
-
await tx.deleteMany('subject', {
|
|
849
|
-
where: (b)=>b('id', '=', currentSubjectId)
|
|
850
|
-
});
|
|
851
|
-
await tx.create('auditLog', {
|
|
852
|
-
id: await generateUniqueId(tx, 'auditLog', typedContext),
|
|
853
|
-
subjectId: oldSubjectId,
|
|
854
|
-
entityType: 'consent',
|
|
855
|
-
entityId: consent.id,
|
|
856
|
-
actionType: 'identify_user',
|
|
857
|
-
ipAddress: typedContext.ipAddress || null,
|
|
858
|
-
userAgent: typedContext.userAgent || null,
|
|
859
|
-
eventTimezone: 'UTC',
|
|
860
|
-
metadata: {
|
|
861
|
-
externalId,
|
|
862
|
-
identityProvider,
|
|
863
|
-
mergedFrom: currentSubjectId
|
|
864
|
-
}
|
|
865
|
-
});
|
|
866
|
-
} else {
|
|
867
|
-
await tx.updateMany('subject', {
|
|
868
|
-
where: (b)=>b('id', '=', consent.subjectId),
|
|
869
|
-
set: {
|
|
870
|
-
externalId,
|
|
871
|
-
identityProvider,
|
|
872
|
-
isIdentified: true,
|
|
873
|
-
updatedAt: new Date()
|
|
874
|
-
}
|
|
875
|
-
});
|
|
876
|
-
await tx.create('auditLog', {
|
|
877
|
-
id: await generateUniqueId(tx, 'auditLog', typedContext),
|
|
878
|
-
subjectId: consent.subjectId,
|
|
879
|
-
entityType: 'consent',
|
|
880
|
-
entityId: consent.id,
|
|
881
|
-
actionType: 'identify_user',
|
|
882
|
-
ipAddress: typedContext.ipAddress || null,
|
|
883
|
-
userAgent: typedContext.userAgent || null,
|
|
884
|
-
eventTimezone: 'UTC',
|
|
885
|
-
metadata: {
|
|
886
|
-
externalId,
|
|
887
|
-
identityProvider
|
|
888
|
-
}
|
|
889
|
-
});
|
|
890
|
-
}
|
|
891
|
-
});
|
|
892
|
-
return {
|
|
893
|
-
success: true
|
|
894
|
-
};
|
|
895
|
-
});
|
|
896
|
-
const postConsent = os.consent.post.handler(async ({ input, context })=>{
|
|
897
|
-
const typedContext = context;
|
|
898
|
-
const logger = typedContext.logger;
|
|
899
|
-
logger.info('Handling post-consent request');
|
|
900
|
-
const { db, registry } = typedContext;
|
|
901
|
-
const { type, subjectId, identityProvider, externalSubjectId, domain, metadata, preferences } = input;
|
|
902
|
-
logger.debug('Request parameters', {
|
|
903
|
-
type,
|
|
904
|
-
subjectId,
|
|
905
|
-
identityProvider,
|
|
906
|
-
externalSubjectId,
|
|
907
|
-
domain
|
|
908
|
-
});
|
|
909
|
-
try {
|
|
910
|
-
const subject = await registry.findOrCreateSubject({
|
|
911
|
-
subjectId,
|
|
912
|
-
externalSubjectId,
|
|
913
|
-
identityProvider,
|
|
914
|
-
ipAddress: typedContext.ipAddress
|
|
915
|
-
});
|
|
916
|
-
if (!subject) throw new server_namespaceObject.ORPCError('SUBJECT_CREATION_FAILED', {
|
|
917
|
-
data: {
|
|
918
|
-
subjectId,
|
|
919
|
-
externalSubjectId
|
|
920
|
-
}
|
|
921
|
-
});
|
|
922
|
-
logger.debug('Subject found/created', {
|
|
923
|
-
subjectId: subject.id
|
|
924
|
-
});
|
|
925
|
-
const domainRecord = await typedContext.registry.findOrCreateDomain(domain);
|
|
926
|
-
if (!domainRecord) throw new server_namespaceObject.ORPCError('DOMAIN_CREATION_FAILED', {
|
|
927
|
-
data: {
|
|
928
|
-
domain
|
|
929
|
-
}
|
|
930
|
-
});
|
|
931
|
-
let policyId;
|
|
932
|
-
let purposeIds = [];
|
|
933
|
-
if ('policyId' in input && input.policyId) {
|
|
934
|
-
policyId = input.policyId;
|
|
935
|
-
const policy = await typedContext.registry.findConsentPolicyById(policyId);
|
|
936
|
-
if (!policy) throw new server_namespaceObject.ORPCError('POLICY_NOT_FOUND', {
|
|
937
|
-
data: {
|
|
938
|
-
policyId,
|
|
939
|
-
type
|
|
940
|
-
}
|
|
941
|
-
});
|
|
942
|
-
if (!policy.isActive) throw new server_namespaceObject.ORPCError('POLICY_INACTIVE', {
|
|
943
|
-
data: {
|
|
944
|
-
policyId,
|
|
945
|
-
type
|
|
946
|
-
}
|
|
947
|
-
});
|
|
948
|
-
} else {
|
|
949
|
-
const policy = await typedContext.registry.findOrCreatePolicy(type);
|
|
950
|
-
if (!policy) throw new server_namespaceObject.ORPCError('POLICY_CREATION_FAILED', {
|
|
951
|
-
data: {
|
|
952
|
-
type
|
|
953
|
-
}
|
|
954
|
-
});
|
|
955
|
-
policyId = policy.id;
|
|
956
|
-
}
|
|
957
|
-
if (preferences) {
|
|
958
|
-
const consentedPurposes = Object.entries(preferences).filter(([_, isConsented])=>isConsented).map(([purposeCode])=>purposeCode);
|
|
959
|
-
logger.debug('Consented purposes', {
|
|
960
|
-
consentedPurposes
|
|
961
|
-
});
|
|
962
|
-
const purposesRaw = await Promise.all(consentedPurposes.map((purposeCode)=>typedContext.registry.findOrCreateConsentPurposeByCode(purposeCode)));
|
|
963
|
-
const purposes = purposesRaw.map((purpose)=>purpose?.id);
|
|
964
|
-
logger.debug('Purposes: ', {
|
|
965
|
-
purposes
|
|
966
|
-
});
|
|
967
|
-
purposeIds = purposes;
|
|
968
|
-
}
|
|
969
|
-
const result = await db.transaction(async (tx)=>{
|
|
970
|
-
logger.debug('Creating consent record', {
|
|
971
|
-
subjectId: subject.id,
|
|
972
|
-
domainId: domainRecord.id,
|
|
973
|
-
policyId,
|
|
974
|
-
purposeIds
|
|
975
|
-
});
|
|
976
|
-
const consentRecord = await tx.create('consent', {
|
|
977
|
-
id: await generateUniqueId(tx, 'consent', typedContext),
|
|
978
|
-
subjectId: subject.id,
|
|
979
|
-
domainId: domainRecord.id,
|
|
980
|
-
policyId,
|
|
981
|
-
purposeIds: {
|
|
982
|
-
json: purposeIds
|
|
983
|
-
},
|
|
984
|
-
status: 'active',
|
|
985
|
-
isActive: true,
|
|
986
|
-
ipAddress: typedContext.ipAddress || null,
|
|
987
|
-
userAgent: typedContext.userAgent || null
|
|
988
|
-
});
|
|
989
|
-
logger.debug('Created consent', {
|
|
990
|
-
consentRecord: consentRecord.id
|
|
991
|
-
});
|
|
992
|
-
logger.debug('Creating consentRecord entry', {
|
|
993
|
-
subjectId: subject.id,
|
|
994
|
-
consentId: consentRecord.id,
|
|
995
|
-
actionType: 'consent_given',
|
|
996
|
-
details: metadata
|
|
997
|
-
});
|
|
998
|
-
const record = await tx.create('consentRecord', {
|
|
999
|
-
id: await generateUniqueId(tx, 'consentRecord', typedContext),
|
|
1000
|
-
subjectId: subject.id,
|
|
1001
|
-
consentId: consentRecord.id,
|
|
1002
|
-
actionType: 'consent_given',
|
|
1003
|
-
details: metadata
|
|
1004
|
-
});
|
|
1005
|
-
logger.debug('Created record entry', {
|
|
1006
|
-
record: record.id
|
|
1007
|
-
});
|
|
1008
|
-
logger.debug('Creating audit log', {
|
|
1009
|
-
subjectId: subject.id,
|
|
1010
|
-
entityType: 'consent',
|
|
1011
|
-
entityId: consentRecord.id,
|
|
1012
|
-
actionType: 'consent_given',
|
|
1013
|
-
metadata: metadata
|
|
1014
|
-
});
|
|
1015
|
-
await tx.create('auditLog', {
|
|
1016
|
-
id: await generateUniqueId(tx, 'auditLog', typedContext),
|
|
1017
|
-
subjectId: subject.id,
|
|
1018
|
-
entityType: 'consent',
|
|
1019
|
-
entityId: consentRecord.id,
|
|
1020
|
-
actionType: 'consent_given',
|
|
1021
|
-
metadata: {
|
|
1022
|
-
consentId: consentRecord.id,
|
|
1023
|
-
type
|
|
1024
|
-
},
|
|
1025
|
-
ipAddress: typedContext.ipAddress || null,
|
|
1026
|
-
userAgent: typedContext.userAgent || null,
|
|
1027
|
-
eventTimezone: 'UTC'
|
|
1028
|
-
});
|
|
1029
|
-
logger.debug('Created audit log');
|
|
1030
|
-
if (!consentRecord || !record) throw new server_namespaceObject.ORPCError('CONSENT_CREATION_FAILED', {
|
|
1031
|
-
data: {
|
|
1032
|
-
subjectId: subject.id,
|
|
1033
|
-
domain
|
|
1034
|
-
}
|
|
1035
|
-
});
|
|
1036
|
-
return {
|
|
1037
|
-
consent: consentRecord,
|
|
1038
|
-
record
|
|
1039
|
-
};
|
|
1040
|
-
});
|
|
1041
|
-
return {
|
|
1042
|
-
id: result.consent.id,
|
|
1043
|
-
subjectId: subject.id,
|
|
1044
|
-
externalSubjectId: subject.externalId ?? void 0,
|
|
1045
|
-
identityProvider: subject.identityProvider ?? void 0,
|
|
1046
|
-
domainId: domainRecord.id,
|
|
1047
|
-
domain: domainRecord.name,
|
|
1048
|
-
type,
|
|
1049
|
-
status: result.consent.status,
|
|
1050
|
-
recordId: result.record.id,
|
|
1051
|
-
metadata,
|
|
1052
|
-
givenAt: result.consent.givenAt
|
|
1053
|
-
};
|
|
1054
|
-
} catch (error) {
|
|
1055
|
-
logger.error('Error in post-consent handler', {
|
|
1056
|
-
error: error instanceof Error ? error.message : String(error),
|
|
1057
|
-
errorType: error instanceof Error ? error.constructor.name : typeof error
|
|
1058
|
-
});
|
|
1059
|
-
if (error instanceof server_namespaceObject.ORPCError) throw error;
|
|
1060
|
-
throw new server_namespaceObject.ORPCError('INTERNAL_SERVER_ERROR', {
|
|
1061
|
-
message: error instanceof Error ? error.message : String(error)
|
|
1062
|
-
});
|
|
1063
|
-
}
|
|
1064
|
-
});
|
|
1065
|
-
function checkJurisdiction(countryCode) {
|
|
1066
|
-
const jurisdictions = {
|
|
1067
|
-
EU: new Set([
|
|
1068
|
-
'AT',
|
|
1069
|
-
'BE',
|
|
1070
|
-
'BG',
|
|
1071
|
-
'HR',
|
|
1072
|
-
'CY',
|
|
1073
|
-
'CZ',
|
|
1074
|
-
'DK',
|
|
1075
|
-
'EE',
|
|
1076
|
-
'FI',
|
|
1077
|
-
'FR',
|
|
1078
|
-
'DE',
|
|
1079
|
-
'GR',
|
|
1080
|
-
'HU',
|
|
1081
|
-
'IE',
|
|
1082
|
-
'IT',
|
|
1083
|
-
'LV',
|
|
1084
|
-
'LT',
|
|
1085
|
-
'LU',
|
|
1086
|
-
'MT',
|
|
1087
|
-
'NL',
|
|
1088
|
-
'PL',
|
|
1089
|
-
'PT',
|
|
1090
|
-
'RO',
|
|
1091
|
-
'SK',
|
|
1092
|
-
'SI',
|
|
1093
|
-
'ES',
|
|
1094
|
-
'SE'
|
|
1095
|
-
]),
|
|
1096
|
-
EEA: new Set([
|
|
1097
|
-
'IS',
|
|
1098
|
-
'NO',
|
|
1099
|
-
'LI'
|
|
1100
|
-
]),
|
|
1101
|
-
UK: new Set([
|
|
1102
|
-
'GB'
|
|
1103
|
-
]),
|
|
1104
|
-
CH: new Set([
|
|
1105
|
-
'CH'
|
|
1106
|
-
]),
|
|
1107
|
-
BR: new Set([
|
|
1108
|
-
'BR'
|
|
1109
|
-
]),
|
|
1110
|
-
CA: new Set([
|
|
1111
|
-
'CA'
|
|
1112
|
-
]),
|
|
1113
|
-
AU: new Set([
|
|
1114
|
-
'AU'
|
|
1115
|
-
]),
|
|
1116
|
-
JP: new Set([
|
|
1117
|
-
'JP'
|
|
1118
|
-
]),
|
|
1119
|
-
KR: new Set([
|
|
1120
|
-
'KR'
|
|
1121
|
-
])
|
|
1122
|
-
};
|
|
1123
|
-
let showConsentBanner = true;
|
|
1124
|
-
let jurisdictionCode = 'NONE';
|
|
1125
|
-
if (countryCode) {
|
|
1126
|
-
const normalizedCountryCode = countryCode.toUpperCase();
|
|
1127
|
-
showConsentBanner = false;
|
|
1128
|
-
const jurisdictionMap = [
|
|
1129
|
-
{
|
|
1130
|
-
sets: [
|
|
1131
|
-
jurisdictions.EU,
|
|
1132
|
-
jurisdictions.EEA,
|
|
1133
|
-
jurisdictions.UK
|
|
1134
|
-
],
|
|
1135
|
-
code: 'GDPR'
|
|
1136
|
-
},
|
|
1137
|
-
{
|
|
1138
|
-
sets: [
|
|
1139
|
-
jurisdictions.CH
|
|
1140
|
-
],
|
|
1141
|
-
code: 'CH'
|
|
1142
|
-
},
|
|
1143
|
-
{
|
|
1144
|
-
sets: [
|
|
1145
|
-
jurisdictions.BR
|
|
1146
|
-
],
|
|
1147
|
-
code: 'BR'
|
|
1148
|
-
},
|
|
1149
|
-
{
|
|
1150
|
-
sets: [
|
|
1151
|
-
jurisdictions.CA
|
|
1152
|
-
],
|
|
1153
|
-
code: 'PIPEDA'
|
|
1154
|
-
},
|
|
1155
|
-
{
|
|
1156
|
-
sets: [
|
|
1157
|
-
jurisdictions.AU
|
|
1158
|
-
],
|
|
1159
|
-
code: 'AU'
|
|
1160
|
-
},
|
|
1161
|
-
{
|
|
1162
|
-
sets: [
|
|
1163
|
-
jurisdictions.JP
|
|
1164
|
-
],
|
|
1165
|
-
code: 'APPI'
|
|
1166
|
-
},
|
|
1167
|
-
{
|
|
1168
|
-
sets: [
|
|
1169
|
-
jurisdictions.KR
|
|
1170
|
-
],
|
|
1171
|
-
code: 'PIPA'
|
|
1172
|
-
}
|
|
1173
|
-
];
|
|
1174
|
-
for (const { sets, code } of jurisdictionMap)if (sets.some((set)=>set.has(normalizedCountryCode))) {
|
|
1175
|
-
jurisdictionCode = code;
|
|
1176
|
-
showConsentBanner = true;
|
|
1177
|
-
break;
|
|
1178
|
-
}
|
|
1179
|
-
}
|
|
1180
|
-
const message = JurisdictionMessages[jurisdictionCode];
|
|
1181
|
-
return {
|
|
1182
|
-
showConsentBanner,
|
|
1183
|
-
jurisdictionCode,
|
|
1184
|
-
message
|
|
1185
|
-
};
|
|
1186
|
-
}
|
|
1187
|
-
const translations_namespaceObject = require("@c15t/translations");
|
|
1188
|
-
function isSupportedBaseLanguage(lang) {
|
|
1189
|
-
return lang in translations_namespaceObject.baseTranslations;
|
|
1190
|
-
}
|
|
1191
|
-
function getPreferredLanguage(acceptLanguage, supportedLanguages) {
|
|
1192
|
-
if (!acceptLanguage) return 'en';
|
|
1193
|
-
const primaryLang = acceptLanguage.split(',')[0]?.split(';')[0]?.split('-')[0]?.toLowerCase();
|
|
1194
|
-
if (primaryLang && supportedLanguages.includes(primaryLang)) return primaryLang;
|
|
1195
|
-
return 'en';
|
|
1196
|
-
}
|
|
1197
|
-
function getTranslations(acceptLanguage, customTranslations) {
|
|
1198
|
-
const supportedDefaultLanguages = Object.keys(translations_namespaceObject.baseTranslations);
|
|
1199
|
-
const supportedCustomLanguages = Object.keys(customTranslations || {});
|
|
1200
|
-
const supportedLanguages = [
|
|
1201
|
-
...supportedDefaultLanguages,
|
|
1202
|
-
...supportedCustomLanguages
|
|
1203
|
-
];
|
|
1204
|
-
const preferredLanguage = getPreferredLanguage(acceptLanguage, supportedLanguages);
|
|
1205
|
-
const base = isSupportedBaseLanguage(preferredLanguage) ? translations_namespaceObject.baseTranslations[preferredLanguage] : translations_namespaceObject.baseTranslations.en;
|
|
1206
|
-
const custom = supportedCustomLanguages.includes(preferredLanguage) ? customTranslations?.[preferredLanguage] : {};
|
|
1207
|
-
const translations = custom ? (0, translations_namespaceObject.deepMergeTranslations)(base, custom) : base;
|
|
1208
|
-
return {
|
|
1209
|
-
translations: translations,
|
|
1210
|
-
language: preferredLanguage
|
|
1211
|
-
};
|
|
1212
|
-
}
|
|
1213
|
-
function getHeaders(headers) {
|
|
1214
|
-
if (!headers) return {
|
|
1215
|
-
countryCode: null,
|
|
1216
|
-
regionCode: null,
|
|
1217
|
-
acceptLanguage: null
|
|
1218
|
-
};
|
|
1219
|
-
const normalizeHeader = (value)=>{
|
|
1220
|
-
if (!value) return null;
|
|
1221
|
-
return Array.isArray(value) ? value[0] ?? null : value;
|
|
1222
|
-
};
|
|
1223
|
-
const countryCode = normalizeHeader(headers.get('x-c15t-country')) ?? normalizeHeader(headers.get('cf-ipcountry')) ?? normalizeHeader(headers.get('x-vercel-ip-country')) ?? normalizeHeader(headers.get('x-amz-cf-ipcountry')) ?? normalizeHeader(headers.get('x-country-code'));
|
|
1224
|
-
const regionCode = normalizeHeader(headers.get('x-c15t-region')) ?? normalizeHeader(headers.get('x-vercel-ip-country-region')) ?? normalizeHeader(headers.get('x-region-code'));
|
|
1225
|
-
const acceptLanguage = normalizeHeader(headers.get('accept-language'));
|
|
1226
|
-
return {
|
|
1227
|
-
countryCode,
|
|
1228
|
-
regionCode,
|
|
1229
|
-
acceptLanguage
|
|
1230
|
-
};
|
|
1231
|
-
}
|
|
1232
|
-
function buildResponse({ shouldShowBanner, jurisdiction, location, acceptLanguage, customTranslations, branding = 'c15t' }) {
|
|
1233
|
-
return {
|
|
1234
|
-
showConsentBanner: shouldShowBanner,
|
|
1235
|
-
jurisdiction,
|
|
1236
|
-
location,
|
|
1237
|
-
translations: getTranslations(acceptLanguage, customTranslations),
|
|
1238
|
-
branding: branding
|
|
1239
|
-
};
|
|
1240
|
-
}
|
|
1241
|
-
const handler_showConsentBanner = os.consent.showBanner.handler(({ context })=>{
|
|
1242
|
-
const typedContext = context;
|
|
1243
|
-
const { customTranslations, disableGeoLocation, branding } = typedContext.advanced ?? {};
|
|
1244
|
-
const { countryCode, regionCode, acceptLanguage } = getHeaders(typedContext.headers);
|
|
1245
|
-
if (disableGeoLocation) return buildResponse({
|
|
1246
|
-
shouldShowBanner: true,
|
|
1247
|
-
jurisdiction: {
|
|
1248
|
-
code: 'NONE',
|
|
1249
|
-
message: JurisdictionMessages.NONE
|
|
1250
|
-
},
|
|
1251
|
-
location: {
|
|
1252
|
-
countryCode: null,
|
|
1253
|
-
regionCode: null
|
|
1254
|
-
},
|
|
1255
|
-
acceptLanguage,
|
|
1256
|
-
customTranslations,
|
|
1257
|
-
branding
|
|
1258
|
-
});
|
|
1259
|
-
const { showConsentBanner, jurisdictionCode, message } = checkJurisdiction(countryCode);
|
|
1260
|
-
return buildResponse({
|
|
1261
|
-
shouldShowBanner: showConsentBanner,
|
|
1262
|
-
jurisdiction: {
|
|
1263
|
-
code: jurisdictionCode,
|
|
1264
|
-
message
|
|
1265
|
-
},
|
|
1266
|
-
location: {
|
|
1267
|
-
countryCode,
|
|
1268
|
-
regionCode
|
|
1269
|
-
},
|
|
1270
|
-
acceptLanguage,
|
|
1271
|
-
customTranslations,
|
|
1272
|
-
branding
|
|
1273
|
-
});
|
|
1274
|
-
});
|
|
1275
|
-
const verifyConsent = os.consent.verify.handler(async ({ input, context })=>{
|
|
1276
|
-
const typedContext = context;
|
|
1277
|
-
const logger = typedContext.logger;
|
|
1278
|
-
logger.info('Handling verify-consent request');
|
|
1279
|
-
const { type, subjectId, externalSubjectId, domain, policyId, preferences } = input;
|
|
1280
|
-
logger.debug('Request parameters', {
|
|
1281
|
-
type,
|
|
1282
|
-
subjectId,
|
|
1283
|
-
externalSubjectId,
|
|
1284
|
-
domain,
|
|
1285
|
-
policyId,
|
|
1286
|
-
preferences
|
|
1287
|
-
});
|
|
1288
|
-
try {
|
|
1289
|
-
const domainRecord = await typedContext.registry.findDomainByName(domain);
|
|
1290
|
-
if (!domainRecord) throw new server_namespaceObject.ORPCError('DOMAIN_NOT_FOUND', {
|
|
1291
|
-
data: {
|
|
1292
|
-
domain
|
|
1293
|
-
}
|
|
1294
|
-
});
|
|
1295
|
-
const subject = await typedContext.registry.findOrCreateSubject({
|
|
1296
|
-
subjectId,
|
|
1297
|
-
externalSubjectId,
|
|
1298
|
-
ipAddress: typedContext.ipAddress ?? 'unknown'
|
|
1299
|
-
});
|
|
1300
|
-
if (!subject) throw new server_namespaceObject.ORPCError('SUBJECT_NOT_FOUND', {
|
|
1301
|
-
data: {
|
|
1302
|
-
subjectId,
|
|
1303
|
-
externalSubjectId
|
|
1304
|
-
}
|
|
1305
|
-
});
|
|
1306
|
-
if ('cookie_banner' === type && (!preferences || 0 === preferences.length)) throw new server_namespaceObject.ORPCError('COOKIE_BANNER_PREFERENCES_REQUIRED', {
|
|
1307
|
-
data: {
|
|
1308
|
-
type: 'cookie_banner'
|
|
1309
|
-
}
|
|
1310
|
-
});
|
|
1311
|
-
const purposePromises = preferences?.map((purpose)=>typedContext.registry.findOrCreateConsentPurposeByCode(purpose));
|
|
1312
|
-
const rawPurposes = await Promise.all(purposePromises ?? []);
|
|
1313
|
-
const purposeIds = rawPurposes.filter((purpose)=>null !== purpose).map((purpose)=>purpose.id);
|
|
1314
|
-
if (purposeIds.length !== (preferences?.length ?? 0)) throw new server_namespaceObject.ORPCError('PURPOSES_NOT_FOUND', {
|
|
1315
|
-
data: {
|
|
1316
|
-
preferences: preferences ?? [],
|
|
1317
|
-
foundPurposes: rawPurposes.filter((p)=>null !== p).map((p)=>p.code)
|
|
1318
|
-
}
|
|
1319
|
-
});
|
|
1320
|
-
if (policyId) {
|
|
1321
|
-
const policy = await typedContext.registry.findConsentPolicyById(policyId);
|
|
1322
|
-
if (!policy || policy.type !== type) throw new server_namespaceObject.ORPCError('POLICY_NOT_FOUND', {
|
|
1323
|
-
data: {
|
|
1324
|
-
policyId,
|
|
1325
|
-
type
|
|
1326
|
-
}
|
|
1327
|
-
});
|
|
1328
|
-
return await checkPolicyConsent({
|
|
1329
|
-
policyId: policy.id,
|
|
1330
|
-
subjectId: subject.id,
|
|
1331
|
-
domainId: domainRecord.id,
|
|
1332
|
-
purposeIds,
|
|
1333
|
-
type,
|
|
1334
|
-
context: typedContext
|
|
1335
|
-
});
|
|
1336
|
-
}
|
|
1337
|
-
const latestPolicy = await typedContext.registry.findOrCreatePolicy(type);
|
|
1338
|
-
if (!latestPolicy) throw new server_namespaceObject.ORPCError('POLICY_NOT_FOUND', {
|
|
1339
|
-
data: {
|
|
1340
|
-
policyId: 'latest',
|
|
1341
|
-
type
|
|
1342
|
-
}
|
|
1343
|
-
});
|
|
1344
|
-
return await checkPolicyConsent({
|
|
1345
|
-
policyId: latestPolicy.id,
|
|
1346
|
-
subjectId: subject.id,
|
|
1347
|
-
domainId: domainRecord.id,
|
|
1348
|
-
purposeIds,
|
|
1349
|
-
type,
|
|
1350
|
-
context: typedContext
|
|
1351
|
-
});
|
|
1352
|
-
} catch (error) {
|
|
1353
|
-
logger.error('Error in verify-consent handler', {
|
|
1354
|
-
error: error instanceof Error ? error.message : String(error),
|
|
1355
|
-
errorType: error instanceof Error ? error.constructor.name : typeof error
|
|
1356
|
-
});
|
|
1357
|
-
if (error instanceof server_namespaceObject.ORPCError) throw error;
|
|
1358
|
-
throw new server_namespaceObject.ORPCError('INTERNAL_SERVER_ERROR', {
|
|
1359
|
-
message: error instanceof Error ? error.message : String(error)
|
|
1360
|
-
});
|
|
1361
|
-
}
|
|
1362
|
-
});
|
|
1363
|
-
async function checkPolicyConsent({ policyId, subjectId, domainId, purposeIds, type, context }) {
|
|
1364
|
-
const { registry, db } = context;
|
|
1365
|
-
const rawConsents = await db.findMany('consent', {
|
|
1366
|
-
where: (b)=>b.and(b('subjectId', '=', subjectId), b('policyId', '=', policyId), b('domainId', '=', domainId)),
|
|
1367
|
-
orderBy: [
|
|
1368
|
-
'givenAt',
|
|
1369
|
-
'desc'
|
|
1370
|
-
]
|
|
1371
|
-
});
|
|
1372
|
-
const filteredConsents = rawConsents.filter((consent)=>{
|
|
1373
|
-
if (!purposeIds) return true;
|
|
1374
|
-
return purposeIds.every((id)=>consent.purposeIds.some((purposeId)=>purposeId === id));
|
|
1375
|
-
});
|
|
1376
|
-
await registry.createAuditLog({
|
|
1377
|
-
subjectId,
|
|
1378
|
-
entityType: 'consent_policy',
|
|
1379
|
-
entityId: policyId,
|
|
1380
|
-
actionType: 'verify_consent',
|
|
1381
|
-
metadata: {
|
|
1382
|
-
type,
|
|
1383
|
-
policyId,
|
|
1384
|
-
purposeIds,
|
|
1385
|
-
success: 0 !== filteredConsents.length,
|
|
1386
|
-
...filteredConsents.length > 0 ? {
|
|
1387
|
-
consentId: filteredConsents[0]?.id
|
|
1388
|
-
} : {}
|
|
1389
|
-
},
|
|
1390
|
-
eventTimezone: 'UTC'
|
|
1391
|
-
});
|
|
1392
|
-
if (0 === rawConsents.length || 0 === filteredConsents.length) return {
|
|
1393
|
-
isValid: false
|
|
1394
|
-
};
|
|
1395
|
-
return {
|
|
1396
|
-
isValid: true,
|
|
1397
|
-
consent: filteredConsents[0]
|
|
1398
|
-
};
|
|
1399
|
-
}
|
|
1400
|
-
const consentHandlers = {
|
|
1401
|
-
post: postConsent,
|
|
1402
|
-
showBanner: handler_showConsentBanner,
|
|
1403
|
-
verify: verifyConsent,
|
|
1404
|
-
identify: identifyUser
|
|
1405
|
-
};
|
|
1406
|
-
const statusHandler = os.meta.status.handler(({ context })=>{
|
|
1407
|
-
const typedContext = context;
|
|
1408
|
-
const headers = typedContext.headers;
|
|
1409
|
-
const normalizeHeader = (value)=>{
|
|
1410
|
-
if (!value) return null;
|
|
1411
|
-
return Array.isArray(value) ? value[0] ?? null : value;
|
|
1412
|
-
};
|
|
1413
|
-
const countryCode = normalizeHeader(headers?.get('cf-ipcountry')) ?? normalizeHeader(headers?.get('x-vercel-ip-country')) ?? normalizeHeader(headers?.get('x-amz-cf-ipcountry')) ?? normalizeHeader(headers?.get('x-country-code'));
|
|
1414
|
-
const regionCode = normalizeHeader(headers?.get('x-vercel-ip-country-region')) ?? normalizeHeader(headers?.get('x-region-code'));
|
|
1415
|
-
return {
|
|
1416
|
-
status: 'ok',
|
|
1417
|
-
version: "1.8.0",
|
|
1418
|
-
timestamp: new Date(),
|
|
1419
|
-
client: {
|
|
1420
|
-
ip: typedContext.ipAddress ?? null,
|
|
1421
|
-
userAgent: typedContext.userAgent ?? null,
|
|
1422
|
-
region: {
|
|
1423
|
-
countryCode,
|
|
1424
|
-
regionCode
|
|
1425
|
-
}
|
|
1426
|
-
}
|
|
1427
|
-
};
|
|
1428
|
-
});
|
|
1429
|
-
const metaHandlers = {
|
|
1430
|
-
status: statusHandler
|
|
1431
|
-
};
|
|
1432
|
-
const router = os.router({
|
|
1433
|
-
consent: consentHandlers,
|
|
1434
|
-
meta: metaHandlers
|
|
1435
|
-
});
|
|
1436
|
-
exports.router = __webpack_exports__.router;
|
|
1437
|
-
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
1438
|
-
"router"
|
|
1439
|
-
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
1440
|
-
Object.defineProperty(exports, '__esModule', {
|
|
1441
|
-
value: true
|
|
1442
|
-
});
|