@c15t/backend 0.0.1-rc.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +11 -0
- package/.turbo/turbo-check-types.log +5 -0
- package/.turbo/turbo-fmt.log +7 -0
- package/.turbo/turbo-lint.log +6 -0
- package/.turbo/turbo-test.log +26 -0
- package/README-next.md +223 -0
- package/README.md +164 -0
- package/dist/api/call.d.ts +176 -0
- package/dist/api/call.d.ts.map +1 -0
- package/dist/api/index.d.ts +935 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/middlewares/index.d.ts +39 -0
- package/dist/api/middlewares/index.d.ts.map +1 -0
- package/dist/api/middlewares/origin-check.d.ts +82 -0
- package/dist/api/middlewares/origin-check.d.ts.map +1 -0
- package/dist/api/middlewares/validate-context.d.ts +38 -0
- package/dist/api/middlewares/validate-context.d.ts.map +1 -0
- package/dist/api/routes/__tests__/consent.test.d.ts +2 -0
- package/dist/api/routes/__tests__/consent.test.d.ts.map +1 -0
- package/dist/api/routes/__tests__/status.test.d.ts +2 -0
- package/dist/api/routes/__tests__/status.test.d.ts.map +1 -0
- package/dist/api/routes/error.d.ts +57 -0
- package/dist/api/routes/error.d.ts.map +1 -0
- package/dist/api/routes/generate-consent-receipt.d.ts +130 -0
- package/dist/api/routes/generate-consent-receipt.d.ts.map +1 -0
- package/dist/api/routes/get-consent-history.d.ts +133 -0
- package/dist/api/routes/get-consent-history.d.ts.map +1 -0
- package/dist/api/routes/get-consent-policy.d.ts +164 -0
- package/dist/api/routes/get-consent-policy.d.ts.map +1 -0
- package/dist/api/routes/get-consent.d.ts +148 -0
- package/dist/api/routes/get-consent.d.ts.map +1 -0
- package/dist/api/routes/index.d.ts +339 -0
- package/dist/api/routes/index.d.ts.map +1 -0
- package/dist/api/routes/ok.d.ts +87 -0
- package/dist/api/routes/ok.d.ts.map +1 -0
- package/dist/api/routes/set-consent.d.ts +245 -0
- package/dist/api/routes/set-consent.d.ts.map +1 -0
- package/dist/api/routes/show-consent-banner.d.ts +127 -0
- package/dist/api/routes/show-consent-banner.d.ts.map +1 -0
- package/dist/api/routes/status.d.ts +61 -0
- package/dist/api/routes/status.d.ts.map +1 -0
- package/dist/api/routes/verify-consent.d.ts +179 -0
- package/dist/api/routes/verify-consent.d.ts.map +1 -0
- package/dist/api/routes/withdraw-consent.d.ts +194 -0
- package/dist/api/routes/withdraw-consent.d.ts.map +1 -0
- package/dist/api/to-endpoints.d.ts +35 -0
- package/dist/api/to-endpoints.d.ts.map +1 -0
- package/dist/client/index.cjs +139 -0
- package/dist/client/index.d.ts +203 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +106 -0
- package/dist/client/types.d.ts +431 -0
- package/dist/client/types.d.ts.map +1 -0
- package/dist/core.d.ts +124 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.test.d.ts +2 -0
- package/dist/core.test.d.ts.map +1 -0
- package/dist/db/adapters/drizzle-adapter/drizzle-adapter.d.ts +122 -0
- package/dist/db/adapters/drizzle-adapter/drizzle-adapter.d.ts.map +1 -0
- package/dist/db/adapters/drizzle-adapter/index.d.ts +2 -0
- package/dist/db/adapters/drizzle-adapter/index.d.ts.map +1 -0
- package/dist/db/adapters/drizzle.cjs +1531 -0
- package/dist/db/adapters/drizzle.js +1489 -0
- package/dist/db/adapters/kysely-adapter/dialect.d.ts +72 -0
- package/dist/db/adapters/kysely-adapter/dialect.d.ts.map +1 -0
- package/dist/db/adapters/kysely-adapter/index.d.ts +4 -0
- package/dist/db/adapters/kysely-adapter/index.d.ts.map +1 -0
- package/dist/db/adapters/kysely-adapter/kysely-adapter.d.ts +98 -0
- package/dist/db/adapters/kysely-adapter/kysely-adapter.d.ts.map +1 -0
- package/dist/db/adapters/kysely-adapter/types.d.ts +281 -0
- package/dist/db/adapters/kysely-adapter/types.d.ts.map +1 -0
- package/dist/db/adapters/kysely.cjs +1551 -0
- package/dist/db/adapters/kysely.js +1508 -0
- package/dist/db/adapters/memory-adapter/index.d.ts +2 -0
- package/dist/db/adapters/memory-adapter/index.d.ts.map +1 -0
- package/dist/db/adapters/memory-adapter/memory-adapter.d.ts +56 -0
- package/dist/db/adapters/memory-adapter/memory-adapter.d.ts.map +1 -0
- package/dist/db/adapters/memory.cjs +1391 -0
- package/dist/db/adapters/memory.js +1349 -0
- package/dist/db/adapters/prisma-adapter/index.d.ts +2 -0
- package/dist/db/adapters/prisma-adapter/index.d.ts.map +1 -0
- package/dist/db/adapters/prisma-adapter/prisma-adapter.d.ts +143 -0
- package/dist/db/adapters/prisma-adapter/prisma-adapter.d.ts.map +1 -0
- package/dist/db/adapters/prisma.cjs +1503 -0
- package/dist/db/adapters/prisma.js +1461 -0
- package/dist/db/adapters/types.d.ts +154 -0
- package/dist/db/adapters/types.d.ts.map +1 -0
- package/dist/db/adapters/utils.d.ts +36 -0
- package/dist/db/adapters/utils.d.ts.map +1 -0
- package/dist/db/core/fields/field-factory.d.ts +383 -0
- package/dist/db/core/fields/field-factory.d.ts.map +1 -0
- package/dist/db/core/fields/field-inference.d.ts +218 -0
- package/dist/db/core/fields/field-inference.d.ts.map +1 -0
- package/dist/db/core/fields/field-options-integration.d.ts +90 -0
- package/dist/db/core/fields/field-options-integration.d.ts.map +1 -0
- package/dist/db/core/fields/field-types.d.ts +182 -0
- package/dist/db/core/fields/field-types.d.ts.map +1 -0
- package/dist/db/core/fields/id-generator.d.ts +19 -0
- package/dist/db/core/fields/id-generator.d.ts.map +1 -0
- package/dist/db/core/fields/index.d.ts +8 -0
- package/dist/db/core/fields/index.d.ts.map +1 -0
- package/dist/db/core/fields/superjson-utils.d.ts +34 -0
- package/dist/db/core/fields/superjson-utils.d.ts.map +1 -0
- package/dist/db/core/fields/zod-fields.d.ts +1011 -0
- package/dist/db/core/fields/zod-fields.d.ts.map +1 -0
- package/dist/db/core/get-schema.d.ts +36 -0
- package/dist/db/core/get-schema.d.ts.map +1 -0
- package/dist/db/core/types.d.ts +41 -0
- package/dist/db/core/types.d.ts.map +1 -0
- package/dist/db/create-registry.d.ts +760 -0
- package/dist/db/create-registry.d.ts.map +1 -0
- package/dist/db/hooks/create-hooks.d.ts +32 -0
- package/dist/db/hooks/create-hooks.d.ts.map +1 -0
- package/dist/db/hooks/index.d.ts +40 -0
- package/dist/db/hooks/index.d.ts.map +1 -0
- package/dist/db/hooks/types.d.ts +133 -0
- package/dist/db/hooks/types.d.ts.map +1 -0
- package/dist/db/hooks/update-hooks.d.ts +33 -0
- package/dist/db/hooks/update-hooks.d.ts.map +1 -0
- package/dist/db/hooks/update-many-hooks.d.ts +55 -0
- package/dist/db/hooks/update-many-hooks.d.ts.map +1 -0
- package/dist/db/hooks/utils.d.ts +62 -0
- package/dist/db/hooks/utils.d.ts.map +1 -0
- package/dist/db/hooks/with-hooks-factory.d.ts +33 -0
- package/dist/db/hooks/with-hooks-factory.d.ts.map +1 -0
- package/dist/db/index.cjs +2458 -0
- package/dist/db/index.d.ts +11 -0
- package/dist/db/index.d.ts.map +1 -0
- package/dist/db/index.js +2404 -0
- package/dist/db/migration/get-migration.d.ts +32 -0
- package/dist/db/migration/get-migration.d.ts.map +1 -0
- package/dist/db/migration/get-schema/get-schema.d.ts +27 -0
- package/dist/db/migration/get-schema/get-schema.d.ts.map +1 -0
- package/dist/db/migration/get-schema/index.d.ts +21 -0
- package/dist/db/migration/get-schema/index.d.ts.map +1 -0
- package/dist/db/migration/get-schema/process-fields.d.ts +16 -0
- package/dist/db/migration/get-schema/process-fields.d.ts.map +1 -0
- package/dist/db/migration/get-schema/process-tables.d.ts +13 -0
- package/dist/db/migration/get-schema/process-tables.d.ts.map +1 -0
- package/dist/db/migration/get-schema/types.d.ts +17 -0
- package/dist/db/migration/get-schema/types.d.ts.map +1 -0
- package/dist/db/migration/index.cjs +1613 -0
- package/dist/db/migration/index.d.ts +14 -0
- package/dist/db/migration/index.d.ts.map +1 -0
- package/dist/db/migration/index.js +1571 -0
- package/dist/db/migration/migration-builders.d.ts +28 -0
- package/dist/db/migration/migration-builders.d.ts.map +1 -0
- package/dist/db/migration/migration-execution.d.ts +12 -0
- package/dist/db/migration/migration-execution.d.ts.map +1 -0
- package/dist/db/migration/schema-comparison.d.ts +54 -0
- package/dist/db/migration/schema-comparison.d.ts.map +1 -0
- package/dist/db/migration/type-mapping.d.ts +86 -0
- package/dist/db/migration/type-mapping.d.ts.map +1 -0
- package/dist/db/migration/types.d.ts +37 -0
- package/dist/db/migration/types.d.ts.map +1 -0
- package/dist/db/schema/audit-log/index.d.ts +4 -0
- package/dist/db/schema/audit-log/index.d.ts.map +1 -0
- package/dist/db/schema/audit-log/registry.d.ts +128 -0
- package/dist/db/schema/audit-log/registry.d.ts.map +1 -0
- package/dist/db/schema/audit-log/schema.d.ts +67 -0
- package/dist/db/schema/audit-log/schema.d.ts.map +1 -0
- package/dist/db/schema/audit-log/table.d.ts +175 -0
- package/dist/db/schema/audit-log/table.d.ts.map +1 -0
- package/dist/db/schema/audit-log/types.d.ts +29 -0
- package/dist/db/schema/audit-log/types.d.ts.map +1 -0
- package/dist/db/schema/consent/index.d.ts +4 -0
- package/dist/db/schema/consent/index.d.ts.map +1 -0
- package/dist/db/schema/consent/registry.d.ts +318 -0
- package/dist/db/schema/consent/registry.d.ts.map +1 -0
- package/dist/db/schema/consent/schema.d.ts +135 -0
- package/dist/db/schema/consent/schema.d.ts.map +1 -0
- package/dist/db/schema/consent/table.d.ts +245 -0
- package/dist/db/schema/consent/table.d.ts.map +1 -0
- package/dist/db/schema/consent/types.d.ts +37 -0
- package/dist/db/schema/consent/types.d.ts.map +1 -0
- package/dist/db/schema/consent-geo-location/index.d.ts +4 -0
- package/dist/db/schema/consent-geo-location/index.d.ts.map +1 -0
- package/dist/db/schema/consent-geo-location/registry.d.ts +96 -0
- package/dist/db/schema/consent-geo-location/registry.d.ts.map +1 -0
- package/dist/db/schema/consent-geo-location/schema.d.ts +71 -0
- package/dist/db/schema/consent-geo-location/schema.d.ts.map +1 -0
- package/dist/db/schema/consent-geo-location/table.d.ts +167 -0
- package/dist/db/schema/consent-geo-location/table.d.ts.map +1 -0
- package/dist/db/schema/consent-geo-location/types.d.ts +21 -0
- package/dist/db/schema/consent-geo-location/types.d.ts.map +1 -0
- package/dist/db/schema/consent-policy/index.d.ts +4 -0
- package/dist/db/schema/consent-policy/index.d.ts.map +1 -0
- package/dist/db/schema/consent-policy/registry.d.ts +186 -0
- package/dist/db/schema/consent-policy/registry.d.ts.map +1 -0
- package/dist/db/schema/consent-policy/schema.d.ts +68 -0
- package/dist/db/schema/consent-policy/schema.d.ts.map +1 -0
- package/dist/db/schema/consent-policy/table.d.ts +147 -0
- package/dist/db/schema/consent-policy/table.d.ts.map +1 -0
- package/dist/db/schema/consent-policy/types.d.ts +28 -0
- package/dist/db/schema/consent-policy/types.d.ts.map +1 -0
- package/dist/db/schema/consent-purpose/index.d.ts +4 -0
- package/dist/db/schema/consent-purpose/index.d.ts.map +1 -0
- package/dist/db/schema/consent-purpose/registry.d.ts +136 -0
- package/dist/db/schema/consent-purpose/registry.d.ts.map +1 -0
- package/dist/db/schema/consent-purpose/schema.d.ts +79 -0
- package/dist/db/schema/consent-purpose/schema.d.ts.map +1 -0
- package/dist/db/schema/consent-purpose/table.d.ts +161 -0
- package/dist/db/schema/consent-purpose/table.d.ts.map +1 -0
- package/dist/db/schema/consent-purpose/types.d.ts +16 -0
- package/dist/db/schema/consent-purpose/types.d.ts.map +1 -0
- package/dist/db/schema/consent-purpose-junction/index.d.ts +4 -0
- package/dist/db/schema/consent-purpose-junction/index.d.ts.map +1 -0
- package/dist/db/schema/consent-purpose-junction/registry.d.ts +109 -0
- package/dist/db/schema/consent-purpose-junction/registry.d.ts.map +1 -0
- package/dist/db/schema/consent-purpose-junction/schema.d.ts +57 -0
- package/dist/db/schema/consent-purpose-junction/schema.d.ts.map +1 -0
- package/dist/db/schema/consent-purpose-junction/table.d.ts +138 -0
- package/dist/db/schema/consent-purpose-junction/table.d.ts.map +1 -0
- package/dist/db/schema/consent-purpose-junction/types.d.ts +14 -0
- package/dist/db/schema/consent-purpose-junction/types.d.ts.map +1 -0
- package/dist/db/schema/consent-record/index.d.ts +4 -0
- package/dist/db/schema/consent-record/index.d.ts.map +1 -0
- package/dist/db/schema/consent-record/registry.d.ts +119 -0
- package/dist/db/schema/consent-record/registry.d.ts.map +1 -0
- package/dist/db/schema/consent-record/schema.d.ts +57 -0
- package/dist/db/schema/consent-record/schema.d.ts.map +1 -0
- package/dist/db/schema/consent-record/table.d.ts +123 -0
- package/dist/db/schema/consent-record/table.d.ts.map +1 -0
- package/dist/db/schema/consent-record/types.d.ts +21 -0
- package/dist/db/schema/consent-record/types.d.ts.map +1 -0
- package/dist/db/schema/consent-withdrawal/index.d.ts +4 -0
- package/dist/db/schema/consent-withdrawal/index.d.ts.map +1 -0
- package/dist/db/schema/consent-withdrawal/registry.d.ts +134 -0
- package/dist/db/schema/consent-withdrawal/registry.d.ts.map +1 -0
- package/dist/db/schema/consent-withdrawal/schema.d.ts +67 -0
- package/dist/db/schema/consent-withdrawal/schema.d.ts.map +1 -0
- package/dist/db/schema/consent-withdrawal/table.d.ts +170 -0
- package/dist/db/schema/consent-withdrawal/table.d.ts.map +1 -0
- package/dist/db/schema/consent-withdrawal/types.d.ts +28 -0
- package/dist/db/schema/consent-withdrawal/types.d.ts.map +1 -0
- package/dist/db/schema/definition.d.ts +1100 -0
- package/dist/db/schema/definition.d.ts.map +1 -0
- package/dist/db/schema/domain/index.d.ts +4 -0
- package/dist/db/schema/domain/index.d.ts.map +1 -0
- package/dist/db/schema/domain/registry.d.ts +169 -0
- package/dist/db/schema/domain/registry.d.ts.map +1 -0
- package/dist/db/schema/domain/schema.d.ts +60 -0
- package/dist/db/schema/domain/schema.d.ts.map +1 -0
- package/dist/db/schema/domain/table.d.ts +140 -0
- package/dist/db/schema/domain/table.d.ts.map +1 -0
- package/dist/db/schema/domain/types.d.ts +27 -0
- package/dist/db/schema/domain/types.d.ts.map +1 -0
- package/dist/db/schema/geo-location/index.d.ts +4 -0
- package/dist/db/schema/geo-location/index.d.ts.map +1 -0
- package/dist/db/schema/geo-location/registry.d.ts +114 -0
- package/dist/db/schema/geo-location/registry.d.ts.map +1 -0
- package/dist/db/schema/geo-location/schema.d.ts +58 -0
- package/dist/db/schema/geo-location/schema.d.ts.map +1 -0
- package/dist/db/schema/geo-location/table.d.ts +132 -0
- package/dist/db/schema/geo-location/table.d.ts.map +1 -0
- package/dist/db/schema/geo-location/types.d.ts +17 -0
- package/dist/db/schema/geo-location/types.d.ts.map +1 -0
- package/dist/db/schema/index.d.ts +85 -0
- package/dist/db/schema/index.d.ts.map +1 -0
- package/dist/db/schema/parser.d.ts +183 -0
- package/dist/db/schema/parser.d.ts.map +1 -0
- package/dist/db/schema/schemas.d.ts +383 -0
- package/dist/db/schema/schemas.d.ts.map +1 -0
- package/dist/db/schema/subject/index.d.ts +4 -0
- package/dist/db/schema/subject/index.d.ts.map +1 -0
- package/dist/db/schema/subject/registry.d.ts +141 -0
- package/dist/db/schema/subject/registry.d.ts.map +1 -0
- package/dist/db/schema/subject/schema.d.ts +56 -0
- package/dist/db/schema/subject/schema.d.ts.map +1 -0
- package/dist/db/schema/subject/table.d.ts +136 -0
- package/dist/db/schema/subject/table.d.ts.map +1 -0
- package/dist/db/schema/subject/types.d.ts +22 -0
- package/dist/db/schema/subject/types.d.ts.map +1 -0
- package/dist/db/schema/types.d.ts +136 -0
- package/dist/db/schema/types.d.ts.map +1 -0
- package/dist/db/utils/adapter-factory.d.ts +21 -0
- package/dist/db/utils/adapter-factory.d.ts.map +1 -0
- package/dist/db/utils/index.d.ts +10 -0
- package/dist/db/utils/index.d.ts.map +1 -0
- package/dist/db/utils.d.ts +4 -0
- package/dist/db/utils.d.ts.map +1 -0
- package/dist/error/codes.cjs +68 -0
- package/dist/error/codes.d.ts +175 -0
- package/dist/error/codes.d.ts.map +1 -0
- package/dist/error/codes.js +35 -0
- package/dist/error/error.d.ts +79 -0
- package/dist/error/error.d.ts.map +1 -0
- package/dist/error/index.cjs +172 -0
- package/dist/error/index.d.ts +9 -0
- package/dist/error/index.d.ts.map +1 -0
- package/dist/error/index.js +129 -0
- package/dist/error/logging.d.ts +25 -0
- package/dist/error/logging.d.ts.map +1 -0
- package/dist/error/pipeline.d.ts +19 -0
- package/dist/error/pipeline.d.ts.map +1 -0
- package/dist/error/recovery.d.ts +22 -0
- package/dist/error/recovery.d.ts.map +1 -0
- package/dist/error/results.d.ts +56 -0
- package/dist/error/results.d.ts.map +1 -0
- package/dist/index.cjs +4777 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4708 -0
- package/dist/init.d.ts +52 -0
- package/dist/init.d.ts.map +1 -0
- package/dist/init.test.d.ts +2 -0
- package/dist/init.test.d.ts.map +1 -0
- package/dist/integrations/index.cjs +281 -0
- package/dist/integrations/index.d.ts +7 -0
- package/dist/integrations/index.d.ts.map +1 -0
- package/dist/integrations/index.js +248 -0
- package/dist/integrations/next.cjs +131 -0
- package/dist/integrations/next.d.ts +29 -0
- package/dist/integrations/next.d.ts.map +1 -0
- package/dist/integrations/next.js +99 -0
- package/dist/integrations/react.cjs +182 -0
- package/dist/integrations/react.d.ts +257 -0
- package/dist/integrations/react.d.ts.map +1 -0
- package/dist/integrations/react.js +150 -0
- package/dist/plugins/geo/index.d.ts +2 -0
- package/dist/plugins/geo/index.d.ts.map +1 -0
- package/dist/test/utils.d.ts +65 -0
- package/dist/test/utils.d.ts.map +1 -0
- package/dist/types/api.d.ts +89 -0
- package/dist/types/api.d.ts.map +1 -0
- package/dist/types/context.d.ts +205 -0
- package/dist/types/context.d.ts.map +1 -0
- package/dist/types/helper.d.ts +78 -0
- package/dist/types/helper.d.ts.map +1 -0
- package/dist/types/index.cjs +19 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +0 -0
- package/dist/types/options.d.ts +172 -0
- package/dist/types/options.d.ts.map +1 -0
- package/dist/types/plugins.d.ts +442 -0
- package/dist/types/plugins.d.ts.map +1 -0
- package/dist/utils/env.d.ts +77 -0
- package/dist/utils/env.d.ts.map +1 -0
- package/dist/utils/hide-metadata.d.ts +22 -0
- package/dist/utils/hide-metadata.d.ts.map +1 -0
- package/dist/utils/index.cjs +268 -0
- package/dist/utils/index.d.ts +18 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +210 -0
- package/dist/utils/ip.d.ts +10 -0
- package/dist/utils/ip.d.ts.map +1 -0
- package/dist/utils/json.d.ts +14 -0
- package/dist/utils/json.d.ts.map +1 -0
- package/dist/utils/logger.d.ts +108 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/url.d.ts +87 -0
- package/dist/utils/url.d.ts.map +1 -0
- package/dist/utils/wildcard.d.ts +46 -0
- package/dist/utils/wildcard.d.ts.map +1 -0
- package/knip.json +37 -0
- package/package.json +146 -0
- package/rslib.config.ts +104 -0
- package/src/api/call.ts +177 -0
- package/src/api/index.ts +303 -0
- package/src/api/middlewares/index.ts +38 -0
- package/src/api/middlewares/origin-check.ts +260 -0
- package/src/api/middlewares/validate-context.ts +175 -0
- package/src/api/routes/__tests__/consent.test.ts +270 -0
- package/src/api/routes/__tests__/status.test.ts +36 -0
- package/src/api/routes/error.ts +130 -0
- package/src/api/routes/generate-consent-receipt.ts +244 -0
- package/src/api/routes/get-consent-history.ts +128 -0
- package/src/api/routes/get-consent-policy.ts +327 -0
- package/src/api/routes/get-consent.ts +230 -0
- package/src/api/routes/index.ts +12 -0
- package/src/api/routes/ok.ts +45 -0
- package/src/api/routes/set-consent.ts +328 -0
- package/src/api/routes/show-consent-banner.ts +149 -0
- package/src/api/routes/status.ts +62 -0
- package/src/api/routes/verify-consent.ts +272 -0
- package/src/api/routes/withdraw-consent.ts +293 -0
- package/src/api/to-endpoints.ts +371 -0
- package/src/client/index.ts +471 -0
- package/src/client/types.ts +458 -0
- package/src/core.test.ts +303 -0
- package/src/core.ts +267 -0
- package/src/db/adapters/drizzle-adapter/drizzle-adapter.ts +711 -0
- package/src/db/adapters/drizzle-adapter/index.ts +1 -0
- package/src/db/adapters/kysely-adapter/dialect.ts +192 -0
- package/src/db/adapters/kysely-adapter/index.ts +3 -0
- package/src/db/adapters/kysely-adapter/kysely-adapter.ts +1168 -0
- package/src/db/adapters/kysely-adapter/types.ts +307 -0
- package/src/db/adapters/memory-adapter/index.ts +1 -0
- package/src/db/adapters/memory-adapter/memory-adapter.ts +648 -0
- package/src/db/adapters/prisma-adapter/index.ts +1 -0
- package/src/db/adapters/prisma-adapter/prisma-adapter.ts +586 -0
- package/src/db/adapters/types.ts +203 -0
- package/src/db/adapters/utils.ts +51 -0
- package/src/db/core/fields/field-factory.ts +804 -0
- package/src/db/core/fields/field-inference.ts +298 -0
- package/src/db/core/fields/field-options-integration.ts +135 -0
- package/src/db/core/fields/field-types.ts +233 -0
- package/src/db/core/fields/id-generator.ts +57 -0
- package/src/db/core/fields/index.ts +56 -0
- package/src/db/core/fields/superjson-utils.ts +155 -0
- package/src/db/core/fields/zod-fields.ts +269 -0
- package/src/db/core/get-schema.ts +102 -0
- package/src/db/core/types.ts +52 -0
- package/src/db/create-registry.ts +31 -0
- package/src/db/hooks/create-hooks.ts +88 -0
- package/src/db/hooks/index.ts +39 -0
- package/src/db/hooks/types.ts +164 -0
- package/src/db/hooks/update-hooks.ts +91 -0
- package/src/db/hooks/update-many-hooks.ts +176 -0
- package/src/db/hooks/utils.ts +151 -0
- package/src/db/hooks/with-hooks-factory.ts +68 -0
- package/src/db/index.ts +32 -0
- package/src/db/migration/get-migration.ts +89 -0
- package/src/db/migration/get-schema/get-schema.ts +44 -0
- package/src/db/migration/get-schema/index.ts +20 -0
- package/src/db/migration/get-schema/process-fields.ts +66 -0
- package/src/db/migration/get-schema/process-tables.ts +68 -0
- package/src/db/migration/get-schema/types.ts +18 -0
- package/src/db/migration/index.ts +18 -0
- package/src/db/migration/migration-builders.ts +170 -0
- package/src/db/migration/migration-execution.ts +79 -0
- package/src/db/migration/schema-comparison.ts +216 -0
- package/src/db/migration/type-mapping.ts +255 -0
- package/src/db/migration/types.ts +46 -0
- package/src/db/schema/audit-log/index.ts +3 -0
- package/src/db/schema/audit-log/registry.ts +228 -0
- package/src/db/schema/audit-log/schema.ts +46 -0
- package/src/db/schema/audit-log/table.ts +185 -0
- package/src/db/schema/audit-log/types.ts +29 -0
- package/src/db/schema/consent/index.ts +3 -0
- package/src/db/schema/consent/registry.ts +381 -0
- package/src/db/schema/consent/schema.ts +65 -0
- package/src/db/schema/consent/table.ts +220 -0
- package/src/db/schema/consent/types.ts +39 -0
- package/src/db/schema/consent-geo-location/index.ts +3 -0
- package/src/db/schema/consent-geo-location/registry.ts +124 -0
- package/src/db/schema/consent-geo-location/schema.ts +51 -0
- package/src/db/schema/consent-geo-location/table.ts +169 -0
- package/src/db/schema/consent-geo-location/types.ts +21 -0
- package/src/db/schema/consent-policy/index.ts +3 -0
- package/src/db/schema/consent-policy/registry.ts +313 -0
- package/src/db/schema/consent-policy/schema.ts +47 -0
- package/src/db/schema/consent-policy/table.ts +141 -0
- package/src/db/schema/consent-policy/types.ts +28 -0
- package/src/db/schema/consent-purpose/index.ts +3 -0
- package/src/db/schema/consent-purpose/registry.ts +188 -0
- package/src/db/schema/consent-purpose/schema.ts +58 -0
- package/src/db/schema/consent-purpose/table.ts +154 -0
- package/src/db/schema/consent-purpose/types.ts +16 -0
- package/src/db/schema/consent-purpose-junction/index.ts +3 -0
- package/src/db/schema/consent-purpose-junction/registry.ts +189 -0
- package/src/db/schema/consent-purpose-junction/schema.ts +49 -0
- package/src/db/schema/consent-purpose-junction/table.ts +142 -0
- package/src/db/schema/consent-purpose-junction/types.ts +14 -0
- package/src/db/schema/consent-record/index.ts +3 -0
- package/src/db/schema/consent-record/registry.ts +209 -0
- package/src/db/schema/consent-record/schema.ts +42 -0
- package/src/db/schema/consent-record/table.ts +124 -0
- package/src/db/schema/consent-record/types.ts +21 -0
- package/src/db/schema/consent-withdrawal/index.ts +3 -0
- package/src/db/schema/consent-withdrawal/registry.ts +219 -0
- package/src/db/schema/consent-withdrawal/schema.ts +48 -0
- package/src/db/schema/consent-withdrawal/table.ts +181 -0
- package/src/db/schema/consent-withdrawal/types.ts +29 -0
- package/src/db/schema/definition.ts +196 -0
- package/src/db/schema/domain/index.ts +3 -0
- package/src/db/schema/domain/registry.ts +272 -0
- package/src/db/schema/domain/schema.ts +43 -0
- package/src/db/schema/domain/table.ts +137 -0
- package/src/db/schema/domain/types.ts +27 -0
- package/src/db/schema/geo-location/index.ts +3 -0
- package/src/db/schema/geo-location/registry.ts +159 -0
- package/src/db/schema/geo-location/schema.ts +45 -0
- package/src/db/schema/geo-location/table.ts +148 -0
- package/src/db/schema/geo-location/types.ts +18 -0
- package/src/db/schema/index.ts +96 -0
- package/src/db/schema/parser.ts +417 -0
- package/src/db/schema/schemas.ts +35 -0
- package/src/db/schema/subject/index.ts +3 -0
- package/src/db/schema/subject/registry.ts +371 -0
- package/src/db/schema/subject/schema.ts +41 -0
- package/src/db/schema/subject/table.ts +139 -0
- package/src/db/schema/subject/types.ts +22 -0
- package/src/db/schema/types.ts +154 -0
- package/src/db/utils/adapter-factory.ts +64 -0
- package/src/db/utils/index.ts +10 -0
- package/src/db/utils.ts +42 -0
- package/src/docs/ADVANCED_JSON_HANDLING.md +99 -0
- package/src/docs/neverthrow.md +171 -0
- package/src/error/codes.ts +201 -0
- package/src/error/error.ts +145 -0
- package/src/error/index.ts +23 -0
- package/src/error/logging.ts +52 -0
- package/src/error/pipeline.ts +57 -0
- package/src/error/recovery.ts +45 -0
- package/src/error/results.ts +100 -0
- package/src/index.ts +79 -0
- package/src/init.test.ts +235 -0
- package/src/init.ts +261 -0
- package/src/integrations/index.ts +10 -0
- package/src/integrations/next.ts +136 -0
- package/src/integrations/react.ts +567 -0
- package/src/plugins/geo/index.ts +563 -0
- package/src/test/utils.ts +244 -0
- package/src/types/api.ts +101 -0
- package/src/types/context.ts +235 -0
- package/src/types/helper.ts +87 -0
- package/src/types/index.ts +5 -0
- package/src/types/options.ts +189 -0
- package/src/types/plugins.ts +538 -0
- package/src/utils/env.ts +103 -0
- package/src/utils/hide-metadata.ts +21 -0
- package/src/utils/index.ts +17 -0
- package/src/utils/ip.ts +45 -0
- package/src/utils/json.ts +19 -0
- package/src/utils/logger.ts +252 -0
- package/src/utils/url.ts +194 -0
- package/src/utils/wildcard.ts +253 -0
- package/tsconfig.json +12 -0
- package/vitest.config.ts +14 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it } from 'vitest';
|
|
2
|
+
import { createMockContext } from '~/test/utils';
|
|
3
|
+
import type { C15TContext } from '~/types';
|
|
4
|
+
import { status } from '../status';
|
|
5
|
+
|
|
6
|
+
describe('Status Endpoint', () => {
|
|
7
|
+
let mockContext: C15TContext;
|
|
8
|
+
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
mockContext = createMockContext();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('should return status response', async () => {
|
|
14
|
+
const response = await status({
|
|
15
|
+
context: mockContext,
|
|
16
|
+
params: undefined,
|
|
17
|
+
query: undefined,
|
|
18
|
+
body: undefined,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
expect(response.status).toBe('ok');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('should include version in context', async () => {
|
|
25
|
+
const response = await status({
|
|
26
|
+
context: mockContext,
|
|
27
|
+
params: undefined,
|
|
28
|
+
query: undefined,
|
|
29
|
+
body: undefined,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
expect(response.status).toBe('ok');
|
|
33
|
+
expect(response.version).toBeDefined();
|
|
34
|
+
expect(typeof response.version).toBe('string');
|
|
35
|
+
});
|
|
36
|
+
});
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { HIDE_METADATA } from '~/utils/hide-metadata';
|
|
2
|
+
import { createAuthEndpoint } from '../call';
|
|
3
|
+
|
|
4
|
+
function sanitize(input: string): string {
|
|
5
|
+
return input
|
|
6
|
+
.replace(/&/g, '&')
|
|
7
|
+
.replace(/</g, '<')
|
|
8
|
+
.replace(/>/g, '>')
|
|
9
|
+
.replace(/"/g, '"')
|
|
10
|
+
.replace(/'/g, ''');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const html = (errorCode = 'Unknown') => `<!DOCTYPE html>
|
|
14
|
+
<html lang="en">
|
|
15
|
+
<head>
|
|
16
|
+
<meta charset="UTF-8">
|
|
17
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
18
|
+
<title>Authentication Error</title>
|
|
19
|
+
<style>
|
|
20
|
+
:root {
|
|
21
|
+
--bg-color: #f8f9fa;
|
|
22
|
+
--text-color: #212529;
|
|
23
|
+
--accent-color: #000000;
|
|
24
|
+
--error-color: #dc3545;
|
|
25
|
+
--border-color: #e9ecef;
|
|
26
|
+
}
|
|
27
|
+
body {
|
|
28
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
29
|
+
background-color: var(--bg-color);
|
|
30
|
+
color: var(--text-color);
|
|
31
|
+
display: flex;
|
|
32
|
+
justify-content: center;
|
|
33
|
+
align-items: center;
|
|
34
|
+
height: 100vh;
|
|
35
|
+
margin: 0;
|
|
36
|
+
line-height: 1.5;
|
|
37
|
+
}
|
|
38
|
+
.error-container {
|
|
39
|
+
background-color: #ffffff;
|
|
40
|
+
border-radius: 12px;
|
|
41
|
+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
|
|
42
|
+
padding: 2.5rem;
|
|
43
|
+
text-align: center;
|
|
44
|
+
max-width: 90%;
|
|
45
|
+
width: 400px;
|
|
46
|
+
}
|
|
47
|
+
h1 {
|
|
48
|
+
color: var(--error-color);
|
|
49
|
+
font-size: 1.75rem;
|
|
50
|
+
margin-bottom: 1rem;
|
|
51
|
+
font-weight: 600;
|
|
52
|
+
}
|
|
53
|
+
p {
|
|
54
|
+
margin-bottom: 1.5rem;
|
|
55
|
+
color: #495057;
|
|
56
|
+
}
|
|
57
|
+
.btn {
|
|
58
|
+
background-color: var(--accent-color);
|
|
59
|
+
color: #ffffff;
|
|
60
|
+
text-decoration: none;
|
|
61
|
+
padding: 0.75rem 1.5rem;
|
|
62
|
+
border-radius: 6px;
|
|
63
|
+
transition: all 0.3s ease;
|
|
64
|
+
display: inline-block;
|
|
65
|
+
font-weight: 500;
|
|
66
|
+
border: 2px solid var(--accent-color);
|
|
67
|
+
}
|
|
68
|
+
.btn:hover {
|
|
69
|
+
background-color: #131721;
|
|
70
|
+
}
|
|
71
|
+
.error-code {
|
|
72
|
+
font-size: 0.875rem;
|
|
73
|
+
color: #6c757d;
|
|
74
|
+
margin-top: 1.5rem;
|
|
75
|
+
padding-top: 1.5rem;
|
|
76
|
+
border-top: 1px solid var(--border-color);
|
|
77
|
+
}
|
|
78
|
+
.icon {
|
|
79
|
+
font-size: 3rem;
|
|
80
|
+
margin-bottom: 1rem;
|
|
81
|
+
}
|
|
82
|
+
</style>
|
|
83
|
+
</head>
|
|
84
|
+
<body>
|
|
85
|
+
<div class="error-container">
|
|
86
|
+
<div class="icon">⚠️</div>
|
|
87
|
+
<h1>C15T Error</h1>
|
|
88
|
+
<p>We encountered an issue while processing your request. Please try again or contact the application owner if the problem persists.</p>
|
|
89
|
+
<a href="/" id="returnLink" class="btn">Return to Application</a>
|
|
90
|
+
<div class="error-code">Error Code: <span id="errorCode">${sanitize(
|
|
91
|
+
errorCode
|
|
92
|
+
)}</span></div>
|
|
93
|
+
</div>
|
|
94
|
+
</body>
|
|
95
|
+
</html>`;
|
|
96
|
+
|
|
97
|
+
export const error = createAuthEndpoint(
|
|
98
|
+
'/error',
|
|
99
|
+
{
|
|
100
|
+
method: 'GET',
|
|
101
|
+
metadata: {
|
|
102
|
+
...HIDE_METADATA,
|
|
103
|
+
openapi: {
|
|
104
|
+
description: 'Displays an error page',
|
|
105
|
+
responses: {
|
|
106
|
+
'400': {
|
|
107
|
+
description: 'Error page displayed',
|
|
108
|
+
content: {
|
|
109
|
+
'text/html': {
|
|
110
|
+
schema: {
|
|
111
|
+
type: 'string',
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
async (c) => {
|
|
121
|
+
const query =
|
|
122
|
+
new URL(c.request?.url || '').searchParams.get('error') || 'Unknown';
|
|
123
|
+
return new Response(html(query), {
|
|
124
|
+
status: 400,
|
|
125
|
+
headers: {
|
|
126
|
+
'Content-Type': 'text/html',
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
);
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import crypto from 'node:crypto';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import type { ConsentRecord } from '~/db/schema/consent-record/schema';
|
|
4
|
+
import { BASE_ERROR_CODES, C15TError } from '~/error';
|
|
5
|
+
import type { C15TContext } from '../../types';
|
|
6
|
+
import { createAuthEndpoint } from '../call';
|
|
7
|
+
|
|
8
|
+
// Define the schema for validating request parameters
|
|
9
|
+
const generateConsentReceiptSchema = z.object({
|
|
10
|
+
consentId: z.string(),
|
|
11
|
+
includeSignature: z.boolean().default(true),
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Endpoint for generating a standardized consent receipt.
|
|
16
|
+
*
|
|
17
|
+
* This endpoint generates a detailed receipt document that provides formal proof of consent,
|
|
18
|
+
* following industry standards for consent documentation. The receipt includes comprehensive
|
|
19
|
+
* information about who gave consent, what they consented to, and all metadata associated
|
|
20
|
+
* with the consent event.
|
|
21
|
+
*
|
|
22
|
+
* Optionally, the receipt can include a cryptographic signature for verification purposes.
|
|
23
|
+
*
|
|
24
|
+
* @endpoint GET /consent/receipt
|
|
25
|
+
*/
|
|
26
|
+
export const generateConsentReceipt = createAuthEndpoint(
|
|
27
|
+
'/consent/receipt',
|
|
28
|
+
{
|
|
29
|
+
method: 'GET',
|
|
30
|
+
query: generateConsentReceiptSchema,
|
|
31
|
+
},
|
|
32
|
+
async (ctx) => {
|
|
33
|
+
try {
|
|
34
|
+
const validatedData = generateConsentReceiptSchema.safeParse(ctx.query);
|
|
35
|
+
|
|
36
|
+
if (!validatedData.success) {
|
|
37
|
+
throw new C15TError(
|
|
38
|
+
'The request parameters are invalid. Please ensure all required fields are correctly filled and formatted.',
|
|
39
|
+
{
|
|
40
|
+
code: BASE_ERROR_CODES.BAD_REQUEST,
|
|
41
|
+
status: 400,
|
|
42
|
+
data: {
|
|
43
|
+
details: validatedData.error.errors,
|
|
44
|
+
},
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const params = validatedData.data;
|
|
50
|
+
const { registry } = ctx.context as C15TContext;
|
|
51
|
+
|
|
52
|
+
if (!registry) {
|
|
53
|
+
throw new C15TError(
|
|
54
|
+
'The registry service is currently unavailable. Please check the service status and try again later.',
|
|
55
|
+
{
|
|
56
|
+
code: BASE_ERROR_CODES.INITIALIZATION_FAILED,
|
|
57
|
+
status: 503,
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Get the consent record with related information
|
|
63
|
+
const consentResult = await registry.findConsentById(params.consentId);
|
|
64
|
+
//@ts-expect-error
|
|
65
|
+
if (!consentResult || !consentResult.consent) {
|
|
66
|
+
throw new C15TError(
|
|
67
|
+
'The specified consent record could not be found. Please verify the consent ID and try again.',
|
|
68
|
+
{
|
|
69
|
+
code: BASE_ERROR_CODES.CONSENT_NOT_FOUND,
|
|
70
|
+
status: 404,
|
|
71
|
+
data: {
|
|
72
|
+
consentId: params.consentId,
|
|
73
|
+
},
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
//@ts-expect-error
|
|
78
|
+
const record = consentResult.consent;
|
|
79
|
+
//@ts-expect-error
|
|
80
|
+
const subjectRecord = consentResult.subject;
|
|
81
|
+
|
|
82
|
+
if (!subjectRecord) {
|
|
83
|
+
throw new C15TError(
|
|
84
|
+
'The subject associated with this consent record could not be found. Please verify the subject exists and is correctly linked.',
|
|
85
|
+
{
|
|
86
|
+
code: BASE_ERROR_CODES.NOT_FOUND,
|
|
87
|
+
status: 404,
|
|
88
|
+
data: {
|
|
89
|
+
consentId: params.consentId,
|
|
90
|
+
},
|
|
91
|
+
}
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Get consent records related to this consent
|
|
96
|
+
let records: ConsentRecord[] = [];
|
|
97
|
+
|
|
98
|
+
try {
|
|
99
|
+
if (registry.getRecords) {
|
|
100
|
+
//@ts-expect-error
|
|
101
|
+
records = await registry.getRecords(consentResult.consent.id);
|
|
102
|
+
}
|
|
103
|
+
} catch (error) {
|
|
104
|
+
// Log error but continue processing
|
|
105
|
+
if (ctx.context?.logger) {
|
|
106
|
+
ctx.context.logger.error(
|
|
107
|
+
`Error retrieving records for consent ${params.consentId}:`,
|
|
108
|
+
error
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Get domain information
|
|
114
|
+
const domain = {
|
|
115
|
+
id: record.domainId,
|
|
116
|
+
domain: record.domainId,
|
|
117
|
+
name: `Domain for ${record.domainId}`,
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
// Generate a unique receipt ID
|
|
121
|
+
const receiptId = `CR${Date.now().toString().slice(-7)}${Math.floor(Math.random() * 1000)}`;
|
|
122
|
+
|
|
123
|
+
// Map consent preferences to services and purposes
|
|
124
|
+
const services = Object.entries(record.preferences || {}).map(
|
|
125
|
+
([key, value]) => {
|
|
126
|
+
// Convert key to a more readable service name
|
|
127
|
+
const serviceName = key.charAt(0).toUpperCase() + key.slice(1);
|
|
128
|
+
|
|
129
|
+
return {
|
|
130
|
+
service: serviceName,
|
|
131
|
+
purposes: [
|
|
132
|
+
{
|
|
133
|
+
consentPurpose: key,
|
|
134
|
+
purposeDescription: `${value ? 'Enabled' : 'Disabled'} ${key} tracking and functionality`,
|
|
135
|
+
consentType: 'EXPLICIT',
|
|
136
|
+
purposeCategory: [serviceName],
|
|
137
|
+
termination: record.policyId
|
|
138
|
+
? `As specified in policy ${record.policyId}`
|
|
139
|
+
: 'Until consent is withdrawn',
|
|
140
|
+
thirdPartyDisclosure: false,
|
|
141
|
+
},
|
|
142
|
+
],
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
// Extract metadata from consent records
|
|
148
|
+
const metadata = {
|
|
149
|
+
deviceInfo:
|
|
150
|
+
//@ts-expect-error
|
|
151
|
+
records.length > 0 && records[0]?.recordMetadata?.deviceInfo
|
|
152
|
+
? //@ts-expect-error
|
|
153
|
+
records[0].recordMetadata.deviceInfo
|
|
154
|
+
: 'Not recorded',
|
|
155
|
+
ipAddress: record.ipAddress || 'Not recorded',
|
|
156
|
+
policyId: record.policyId,
|
|
157
|
+
...record.metadata,
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
// Create the receipt object
|
|
161
|
+
const receipt = {
|
|
162
|
+
version: '1.0.0',
|
|
163
|
+
jurisdiction: 'GDPR', // Default to GDPR
|
|
164
|
+
consentTimestamp: record.givenAt || new Date(),
|
|
165
|
+
collectionMethod:
|
|
166
|
+
//@ts-expect-error
|
|
167
|
+
records.length > 0 && records[0]?.recordTypeDetail
|
|
168
|
+
? //@ts-expect-error
|
|
169
|
+
records[0].recordTypeDetail
|
|
170
|
+
: 'API',
|
|
171
|
+
consentReceiptID: receiptId,
|
|
172
|
+
publicKey: process.env.CONSENT_RECEIPT_PUBLIC_KEY || 'not-configured',
|
|
173
|
+
subject: {
|
|
174
|
+
id: subjectRecord.id,
|
|
175
|
+
idType: 'UUID',
|
|
176
|
+
},
|
|
177
|
+
dataController: {
|
|
178
|
+
id: domain.domain,
|
|
179
|
+
name: domain.name || domain.domain,
|
|
180
|
+
on_behalf: [],
|
|
181
|
+
},
|
|
182
|
+
policyURL: `https://${domain.domain}/privacy`,
|
|
183
|
+
services,
|
|
184
|
+
sensitive: false,
|
|
185
|
+
spiCat: [],
|
|
186
|
+
metadata,
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
// Add signature if requested
|
|
190
|
+
if (params.includeSignature) {
|
|
191
|
+
// Create a hash of the receipt data as a signature
|
|
192
|
+
const receiptString = JSON.stringify(receipt);
|
|
193
|
+
const signature = crypto
|
|
194
|
+
.createHash('sha256')
|
|
195
|
+
.update(receiptString)
|
|
196
|
+
.digest('hex');
|
|
197
|
+
|
|
198
|
+
//@ts-expect-error
|
|
199
|
+
receipt.signature = signature;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Return the completed receipt
|
|
203
|
+
return {
|
|
204
|
+
success: true,
|
|
205
|
+
data: {
|
|
206
|
+
receipt,
|
|
207
|
+
receiptId,
|
|
208
|
+
timestamp: new Date().toISOString(),
|
|
209
|
+
},
|
|
210
|
+
};
|
|
211
|
+
} catch (error) {
|
|
212
|
+
const context = ctx.context as C15TContext;
|
|
213
|
+
context.logger?.error?.('Error generating consent receipt:', error);
|
|
214
|
+
|
|
215
|
+
if (error instanceof C15TError) {
|
|
216
|
+
throw error;
|
|
217
|
+
}
|
|
218
|
+
if (error instanceof z.ZodError) {
|
|
219
|
+
throw new C15TError(
|
|
220
|
+
'The request parameters are invalid. Please ensure all required fields are correctly filled and formatted.',
|
|
221
|
+
{
|
|
222
|
+
code: BASE_ERROR_CODES.BAD_REQUEST,
|
|
223
|
+
status: 400,
|
|
224
|
+
data: {
|
|
225
|
+
details: error.errors,
|
|
226
|
+
},
|
|
227
|
+
}
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
throw new C15TError(
|
|
232
|
+
'Failed to generate consent receipt. Please try again later or contact support if the issue persists.',
|
|
233
|
+
{
|
|
234
|
+
code: BASE_ERROR_CODES.INTERNAL_SERVER_ERROR,
|
|
235
|
+
status: 500,
|
|
236
|
+
data: {
|
|
237
|
+
details:
|
|
238
|
+
error instanceof Error ? { message: error.message } : { error },
|
|
239
|
+
},
|
|
240
|
+
}
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
);
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { EntityOutputFields } from '~/db/schema/definition';
|
|
3
|
+
import { logger } from '~/utils';
|
|
4
|
+
import { APIError } from '..';
|
|
5
|
+
import { createAuthEndpoint } from '../call';
|
|
6
|
+
|
|
7
|
+
// Define the schema for validating request parameters
|
|
8
|
+
const getConsentHistorySchema = z.object({
|
|
9
|
+
subjectId: z.string(),
|
|
10
|
+
domain: z.string().optional(),
|
|
11
|
+
limit: z.coerce.number().int().positive().max(1000).default(100),
|
|
12
|
+
offset: z.coerce.number().int().min(0).default(0),
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Endpoint for retrieving a subject's complete consent history.
|
|
17
|
+
*
|
|
18
|
+
* This endpoint returns comprehensive information about a subject's consent records,
|
|
19
|
+
* including all consent entries, withdrawals, related evidence records, and audit logs.
|
|
20
|
+
* It supports optional domain filtering and pagination to manage large result sets.
|
|
21
|
+
*
|
|
22
|
+
* @endpoint GET /consent/history
|
|
23
|
+
*/
|
|
24
|
+
export const getConsentHistory = createAuthEndpoint(
|
|
25
|
+
'/consent/history',
|
|
26
|
+
{
|
|
27
|
+
method: 'GET',
|
|
28
|
+
query: getConsentHistorySchema,
|
|
29
|
+
},
|
|
30
|
+
async (ctx) => {
|
|
31
|
+
try {
|
|
32
|
+
const params = getConsentHistorySchema.parse(ctx.query);
|
|
33
|
+
const { registry } = ctx.context;
|
|
34
|
+
|
|
35
|
+
if (!registry) {
|
|
36
|
+
throw new APIError('INTERNAL_SERVER_ERROR', {
|
|
37
|
+
message: 'Registry not available',
|
|
38
|
+
status: 503,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
let subjectConsents = await registry.findConsents({
|
|
43
|
+
subjectId: params.subjectId,
|
|
44
|
+
});
|
|
45
|
+
if (params.domain) {
|
|
46
|
+
subjectConsents = subjectConsents.filter(
|
|
47
|
+
(consent) => consent.domainId === params.domain
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Sort consents by givenAt date
|
|
52
|
+
subjectConsents.sort((a, b) => b.givenAt.getTime() - a.givenAt.getTime());
|
|
53
|
+
|
|
54
|
+
// Apply pagination
|
|
55
|
+
const start = params.offset;
|
|
56
|
+
const end = start + params.limit;
|
|
57
|
+
const paginatedConsents = subjectConsents.slice(start, end);
|
|
58
|
+
|
|
59
|
+
// Process each consent to include withdrawals and records
|
|
60
|
+
const processedConsents = await Promise.all(
|
|
61
|
+
paginatedConsents.map(async (consent) => {
|
|
62
|
+
const consentWithdrawals = await registry.getWithdrawals(consent.id);
|
|
63
|
+
const records = await registry.getRecords(consent.id);
|
|
64
|
+
|
|
65
|
+
return {
|
|
66
|
+
id: consent.id,
|
|
67
|
+
domainId: consent.domainId,
|
|
68
|
+
status: consent.status as string,
|
|
69
|
+
givenAt: consent.givenAt.toISOString(),
|
|
70
|
+
consentWithdrawals: consentWithdrawals.map((consentWithdrawal) => ({
|
|
71
|
+
id: consentWithdrawal.id,
|
|
72
|
+
createdAt: consentWithdrawal.createdAt.toISOString(),
|
|
73
|
+
reason: consentWithdrawal.withdrawalReason,
|
|
74
|
+
method: consentWithdrawal.withdrawalMethod,
|
|
75
|
+
actor:
|
|
76
|
+
(consentWithdrawal.metadata as Record<string, unknown>)
|
|
77
|
+
?.actor || 'system',
|
|
78
|
+
metadata: consentWithdrawal.metadata,
|
|
79
|
+
})),
|
|
80
|
+
consentRecords: records.map(
|
|
81
|
+
(record: EntityOutputFields<'consentRecord'>) => ({
|
|
82
|
+
id: record.id,
|
|
83
|
+
createdAt: record.createdAt.toISOString(),
|
|
84
|
+
type: record.actionType,
|
|
85
|
+
details: record.id,
|
|
86
|
+
})
|
|
87
|
+
),
|
|
88
|
+
};
|
|
89
|
+
})
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
// Get audit logs if available
|
|
93
|
+
let auditLogs: Array<{
|
|
94
|
+
id: string;
|
|
95
|
+
createdAt: string;
|
|
96
|
+
actionType: string;
|
|
97
|
+
details: Record<string, unknown>;
|
|
98
|
+
}> = [];
|
|
99
|
+
if ('findAuditLogs' in registry) {
|
|
100
|
+
const logs = await registry.findAuditLogs(params.subjectId);
|
|
101
|
+
auditLogs = logs.map((log: EntityOutputFields<'auditLog'>) => ({
|
|
102
|
+
id: log.id,
|
|
103
|
+
createdAt: log.createdAt.toISOString(),
|
|
104
|
+
actionType: log.actionType as string,
|
|
105
|
+
details: log.changes as Record<string, unknown>,
|
|
106
|
+
}));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const response = {
|
|
110
|
+
success: true,
|
|
111
|
+
data: {
|
|
112
|
+
consents: processedConsents,
|
|
113
|
+
auditLogs,
|
|
114
|
+
pagination: {
|
|
115
|
+
total: subjectConsents.length,
|
|
116
|
+
offset: params.offset,
|
|
117
|
+
limit: params.limit,
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
return response;
|
|
123
|
+
} catch (error) {
|
|
124
|
+
logger.error('Error getting consent history:', error);
|
|
125
|
+
throw error;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
);
|