@c15t/backend 1.6.0 → 1.7.0
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 +20 -20
- package/CHANGELOG.md +27 -0
- package/dist/contracts/consent/index.d.ts +47 -2
- package/dist/contracts/consent/index.d.ts.map +1 -1
- package/dist/contracts/consent/show-banner.contract.d.ts +47 -2
- package/dist/contracts/consent/show-banner.contract.d.ts.map +1 -1
- package/dist/contracts/index.d.ts +94 -4
- package/dist/contracts/index.d.ts.map +1 -1
- package/dist/contracts.cjs +31 -2
- package/dist/contracts.js +31 -2
- package/dist/core.cjs +35 -7
- package/dist/core.d.ts +47 -2
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +42 -14
- package/dist/handlers/consent/index.d.ts +47 -2
- package/dist/handlers/consent/index.d.ts.map +1 -1
- package/dist/handlers/consent/show-banner/handler.d.ts +47 -2
- package/dist/handlers/consent/show-banner/handler.d.ts.map +1 -1
- package/dist/middleware/cors/is-origin-trusted.d.ts +1 -1
- package/dist/middleware/cors/is-origin-trusted.d.ts.map +1 -1
- package/dist/pkgs/api-router/types/router-props.d.ts +1 -1
- package/dist/pkgs/api-router/types/router-props.d.ts.map +1 -1
- package/dist/pkgs/data-model/index.cjs +1 -1
- package/dist/pkgs/data-model/index.js +2 -2
- package/dist/pkgs/data-model/schema/index.cjs +1 -1
- package/dist/pkgs/data-model/schema/index.js +2 -2
- package/dist/pkgs/db-adapters/adapters/drizzle-adapter/index.cjs +1 -1
- package/dist/pkgs/db-adapters/adapters/drizzle-adapter/index.js +1 -1
- package/dist/pkgs/db-adapters/adapters/kysely-adapter/index.cjs +1 -1
- package/dist/pkgs/db-adapters/adapters/kysely-adapter/index.js +1 -1
- package/dist/pkgs/db-adapters/adapters/kysely-adapter/tests/test-utils.d.ts +1 -1
- package/dist/pkgs/db-adapters/adapters/kysely-adapter/tests/test-utils.d.ts.map +1 -1
- package/dist/pkgs/db-adapters/adapters/memory-adapter/index.cjs +1 -1
- package/dist/pkgs/db-adapters/adapters/memory-adapter/index.js +1 -1
- package/dist/pkgs/db-adapters/adapters/prisma-adapter/index.cjs +1 -1
- package/dist/pkgs/db-adapters/adapters/prisma-adapter/index.js +1 -1
- package/dist/pkgs/db-adapters/index.cjs +1 -1
- package/dist/pkgs/db-adapters/index.js +2 -2
- package/dist/pkgs/migrations/index.cjs +1 -1
- package/dist/pkgs/migrations/index.js +2 -2
- package/dist/pkgs/types/context.d.ts +1 -1
- package/dist/pkgs/types/context.d.ts.map +1 -1
- package/dist/pkgs/types/options.d.ts +1 -1
- package/dist/pkgs/types/options.d.ts.map +1 -1
- package/dist/pkgs/utils/logger.d.ts +3 -3
- package/dist/pkgs/utils/logger.d.ts.map +1 -1
- package/dist/router.cjs +32 -3
- package/dist/router.d.ts +47 -2
- package/dist/router.d.ts.map +1 -1
- package/dist/router.js +32 -3
- package/dist/schema/index.cjs +1 -1
- package/dist/schema/index.js +2 -2
- package/dist/types/options.d.ts +1 -1
- package/dist/types/options.d.ts.map +1 -1
- package/dist/v2/contracts/consent/index.d.ts +47 -2
- package/dist/v2/contracts/consent/index.d.ts.map +1 -1
- package/dist/v2/contracts/consent/show-banner.contract.d.ts +47 -2
- package/dist/v2/contracts/consent/show-banner.contract.d.ts.map +1 -1
- package/dist/v2/contracts/index.cjs +30 -1
- package/dist/v2/contracts/index.d.ts +94 -4
- package/dist/v2/contracts/index.d.ts.map +1 -1
- package/dist/v2/contracts/index.js +30 -1
- package/dist/v2/core.cjs +34 -6
- package/dist/v2/core.d.ts +47 -2
- package/dist/v2/core.d.ts.map +1 -1
- package/dist/v2/core.js +39 -11
- package/dist/v2/db/registry/types.d.ts +1 -1
- package/dist/v2/db/registry/types.d.ts.map +1 -1
- package/dist/v2/handlers/consent/index.d.ts +47 -2
- package/dist/v2/handlers/consent/index.d.ts.map +1 -1
- package/dist/v2/handlers/consent/show-banner/handler.d.ts +47 -2
- package/dist/v2/handlers/consent/show-banner/handler.d.ts.map +1 -1
- package/dist/v2/middleware/cors/is-origin-trusted.d.ts +1 -1
- package/dist/v2/middleware/cors/is-origin-trusted.d.ts.map +1 -1
- package/dist/v2/router.cjs +31 -2
- package/dist/v2/router.d.ts +47 -2
- package/dist/v2/router.d.ts.map +1 -1
- package/dist/v2/router.js +31 -2
- package/dist/v2/types/index.d.ts +1 -1
- package/dist/v2/types/index.d.ts.map +1 -1
- package/dist/v2/utils/logger.d.ts +3 -3
- package/dist/v2/utils/logger.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +3 -3
- package/src/contracts/consent/show-banner.contract.ts +51 -1
- package/src/core.ts +1 -1
- package/src/middleware/cors/is-origin-trusted.test.ts +60 -0
- package/src/middleware/cors/is-origin-trusted.ts +7 -4
- package/src/pkgs/api-router/types/router-props.ts +1 -1
- package/src/pkgs/db-adapters/adapters/kysely-adapter/tests/postgres.test.ts +1 -1
- package/src/pkgs/db-adapters/adapters/kysely-adapter/tests/sqlite.test.ts +1 -1
- package/src/pkgs/db-adapters/adapters/kysely-adapter/tests/test-utils.ts +1 -1
- package/src/pkgs/migrations/schema-comparison.ts +1 -1
- package/src/pkgs/types/context.ts +1 -1
- package/src/pkgs/types/options.ts +1 -1
- package/src/pkgs/utils/logger.ts +6 -9
- package/src/schema/definition.ts +1 -1
- package/src/types/options.ts +1 -1
- package/src/v2/contracts/consent/show-banner.contract.ts +50 -1
- package/src/v2/core.ts +1 -1
- package/src/v2/db/registry/types.ts +1 -1
- package/src/v2/middleware/cors/is-origin-trusted.test.ts +60 -0
- package/src/v2/middleware/cors/is-origin-trusted.ts +7 -4
- package/src/v2/types/index.ts +1 -1
- package/src/v2/utils/logger.ts +6 -9
- package/src/version.ts +1 -1
package/dist/v2/router.js
CHANGED
|
@@ -415,7 +415,7 @@ const TitleDescriptionSchema = __WEBPACK_EXTERNAL_MODULE_zod__.z.object({
|
|
|
415
415
|
title: __WEBPACK_EXTERNAL_MODULE_zod__.z.string(),
|
|
416
416
|
description: __WEBPACK_EXTERNAL_MODULE_zod__.z.string()
|
|
417
417
|
});
|
|
418
|
-
const
|
|
418
|
+
const CompleteTranslationsSchema = __WEBPACK_EXTERNAL_MODULE_zod__.z.object({
|
|
419
419
|
common: __WEBPACK_EXTERNAL_MODULE_zod__.z.object({
|
|
420
420
|
acceptAll: __WEBPACK_EXTERNAL_MODULE_zod__.z.string(),
|
|
421
421
|
rejectAll: __WEBPACK_EXTERNAL_MODULE_zod__.z.string(),
|
|
@@ -430,8 +430,37 @@ const TranslationsSchema = __WEBPACK_EXTERNAL_MODULE_zod__.z.object({
|
|
|
430
430
|
marketing: TitleDescriptionSchema,
|
|
431
431
|
measurement: TitleDescriptionSchema,
|
|
432
432
|
necessary: TitleDescriptionSchema
|
|
433
|
+
}),
|
|
434
|
+
frame: __WEBPACK_EXTERNAL_MODULE_zod__.z.object({
|
|
435
|
+
title: __WEBPACK_EXTERNAL_MODULE_zod__.z.string(),
|
|
436
|
+
actionButton: __WEBPACK_EXTERNAL_MODULE_zod__.z.string()
|
|
433
437
|
})
|
|
434
438
|
});
|
|
439
|
+
const PartialTranslationsSchema = __WEBPACK_EXTERNAL_MODULE_zod__.z.object({
|
|
440
|
+
common: __WEBPACK_EXTERNAL_MODULE_zod__.z.object({
|
|
441
|
+
acceptAll: __WEBPACK_EXTERNAL_MODULE_zod__.z.string().optional(),
|
|
442
|
+
rejectAll: __WEBPACK_EXTERNAL_MODULE_zod__.z.string().optional(),
|
|
443
|
+
customize: __WEBPACK_EXTERNAL_MODULE_zod__.z.string().optional(),
|
|
444
|
+
save: __WEBPACK_EXTERNAL_MODULE_zod__.z.string().optional()
|
|
445
|
+
}).partial(),
|
|
446
|
+
cookieBanner: TitleDescriptionSchema.partial(),
|
|
447
|
+
consentManagerDialog: TitleDescriptionSchema.partial(),
|
|
448
|
+
consentTypes: __WEBPACK_EXTERNAL_MODULE_zod__.z.object({
|
|
449
|
+
experience: TitleDescriptionSchema.partial(),
|
|
450
|
+
functionality: TitleDescriptionSchema.partial(),
|
|
451
|
+
marketing: TitleDescriptionSchema.partial(),
|
|
452
|
+
measurement: TitleDescriptionSchema.partial(),
|
|
453
|
+
necessary: TitleDescriptionSchema.partial()
|
|
454
|
+
}).partial(),
|
|
455
|
+
frame: __WEBPACK_EXTERNAL_MODULE_zod__.z.object({
|
|
456
|
+
title: __WEBPACK_EXTERNAL_MODULE_zod__.z.string().optional(),
|
|
457
|
+
actionButton: __WEBPACK_EXTERNAL_MODULE_zod__.z.string().optional()
|
|
458
|
+
}).partial()
|
|
459
|
+
});
|
|
460
|
+
const TranslationsSchema = __WEBPACK_EXTERNAL_MODULE_zod__.z.union([
|
|
461
|
+
CompleteTranslationsSchema,
|
|
462
|
+
PartialTranslationsSchema
|
|
463
|
+
]);
|
|
435
464
|
const showConsentBannerContract = __WEBPACK_EXTERNAL_MODULE__orpc_contract_5a058524__.oc.route({
|
|
436
465
|
method: 'GET',
|
|
437
466
|
path: '/show-consent-banner',
|
|
@@ -1197,7 +1226,7 @@ const consentHandlers = {
|
|
|
1197
1226
|
showBanner: handler_showConsentBanner,
|
|
1198
1227
|
verify: verifyConsent
|
|
1199
1228
|
};
|
|
1200
|
-
const version = '1.
|
|
1229
|
+
const version = '1.7.0';
|
|
1201
1230
|
const statusHandler = os.meta.status.handler(({ context })=>{
|
|
1202
1231
|
const typedContext = context;
|
|
1203
1232
|
const headers = typedContext.headers;
|
package/dist/v2/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { createLogger, LoggerOptions } from '@c15t/logger';
|
|
1
2
|
import type { Translations } from '@c15t/translations';
|
|
2
|
-
import type { createLogger, LoggerOptions } from '@doubletie/logger';
|
|
3
3
|
import type { Tracer } from '@opentelemetry/api';
|
|
4
4
|
import type { OpenAPIGeneratorOptions } from '@orpc/openapi';
|
|
5
5
|
import type { FumaDB, InferFumaDB } from 'fumadb';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/v2/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/v2/types/index.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { createLogger
|
|
1
|
+
import { createLogger, type LoggerOptions } from '@c15t/logger';
|
|
2
2
|
/**
|
|
3
3
|
* Gets or creates a global logger instance
|
|
4
4
|
*
|
|
5
5
|
* @param options - Optional logger configuration options
|
|
6
6
|
* @returns The global logger instance
|
|
7
7
|
*/
|
|
8
|
-
export declare function getLogger(options?: LoggerOptions): ReturnType<typeof
|
|
8
|
+
export declare function getLogger(options?: LoggerOptions): ReturnType<typeof createLogger>;
|
|
9
9
|
/**
|
|
10
10
|
* Initializes the global logger with specific options
|
|
11
11
|
*
|
|
12
12
|
* @param options - Logger configuration options
|
|
13
13
|
* @returns The initialized global logger instance
|
|
14
14
|
*/
|
|
15
|
-
export declare function initLogger(options: LoggerOptions): ReturnType<typeof
|
|
15
|
+
export declare function initLogger(options: LoggerOptions): ReturnType<typeof createLogger>;
|
|
16
16
|
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/v2/utils/logger.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/v2/utils/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAIhE;;;;;GAKG;AACH,wBAAgB,SAAS,CACxB,OAAO,CAAC,EAAE,aAAa,GACrB,UAAU,CAAC,OAAO,YAAY,CAAC,CASjC;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CACzB,OAAO,EAAE,aAAa,GACpB,UAAU,CAAC,OAAO,YAAY,CAAC,CAGjC"}
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "1.
|
|
1
|
+
export declare const version = "1.7.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@c15t/backend",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "Consent policy engine and API for c15t. Powers the cookie banner, consent manager, and preferences centre. Webhooks, audit logs, storage adapters. Self host or use consent.io",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"consent",
|
|
@@ -173,7 +173,6 @@
|
|
|
173
173
|
"module": "./dist/server.js",
|
|
174
174
|
"types": "./dist/server.d.ts",
|
|
175
175
|
"dependencies": {
|
|
176
|
-
"@doubletie/logger": "1.0.4",
|
|
177
176
|
"@opentelemetry/api": "1.9.0",
|
|
178
177
|
"@opentelemetry/resources": "^2.0.1",
|
|
179
178
|
"@opentelemetry/sdk-node": "^0.203.0",
|
|
@@ -191,7 +190,8 @@
|
|
|
191
190
|
"neverthrow": "^8.2.0",
|
|
192
191
|
"superjson": "^2.2.2",
|
|
193
192
|
"zod": "^4.0.17",
|
|
194
|
-
"@c15t/
|
|
193
|
+
"@c15t/logger": "1.0.0",
|
|
194
|
+
"@c15t/translations": "1.7.0"
|
|
195
195
|
},
|
|
196
196
|
"devDependencies": {
|
|
197
197
|
"@electric-sql/pglite": "0.2.17",
|
|
@@ -8,7 +8,11 @@ const TitleDescriptionSchema = z.object({
|
|
|
8
8
|
description: z.string(),
|
|
9
9
|
});
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Complete translations schema for newer backend versions
|
|
13
|
+
* All fields are required for full functionality
|
|
14
|
+
*/
|
|
15
|
+
const CompleteTranslationsSchema = z.object({
|
|
12
16
|
common: z.object({
|
|
13
17
|
acceptAll: z.string(),
|
|
14
18
|
rejectAll: z.string(),
|
|
@@ -24,8 +28,54 @@ const TranslationsSchema = z.object({
|
|
|
24
28
|
measurement: TitleDescriptionSchema,
|
|
25
29
|
necessary: TitleDescriptionSchema,
|
|
26
30
|
}),
|
|
31
|
+
frame: z.object({
|
|
32
|
+
title: z.string(),
|
|
33
|
+
actionButton: z.string(),
|
|
34
|
+
}),
|
|
27
35
|
});
|
|
28
36
|
|
|
37
|
+
/**
|
|
38
|
+
* Partial translations schema for backward compatibility with older backend versions
|
|
39
|
+
* Allows missing fields to gracefully degrade functionality
|
|
40
|
+
*/
|
|
41
|
+
const PartialTranslationsSchema = z.object({
|
|
42
|
+
common: z
|
|
43
|
+
.object({
|
|
44
|
+
acceptAll: z.string().optional(),
|
|
45
|
+
rejectAll: z.string().optional(),
|
|
46
|
+
customize: z.string().optional(),
|
|
47
|
+
save: z.string().optional(),
|
|
48
|
+
})
|
|
49
|
+
.partial(),
|
|
50
|
+
cookieBanner: TitleDescriptionSchema.partial(),
|
|
51
|
+
consentManagerDialog: TitleDescriptionSchema.partial(),
|
|
52
|
+
consentTypes: z
|
|
53
|
+
.object({
|
|
54
|
+
experience: TitleDescriptionSchema.partial(),
|
|
55
|
+
functionality: TitleDescriptionSchema.partial(),
|
|
56
|
+
marketing: TitleDescriptionSchema.partial(),
|
|
57
|
+
measurement: TitleDescriptionSchema.partial(),
|
|
58
|
+
necessary: TitleDescriptionSchema.partial(),
|
|
59
|
+
})
|
|
60
|
+
.partial(),
|
|
61
|
+
frame: z
|
|
62
|
+
.object({
|
|
63
|
+
title: z.string().optional(),
|
|
64
|
+
actionButton: z.string().optional(),
|
|
65
|
+
})
|
|
66
|
+
.partial()
|
|
67
|
+
.optional(),
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Union schema that accepts both complete and partial translations
|
|
72
|
+
* Provides backward compatibility while maintaining type safety
|
|
73
|
+
*/
|
|
74
|
+
const TranslationsSchema = z.union([
|
|
75
|
+
CompleteTranslationsSchema,
|
|
76
|
+
PartialTranslationsSchema,
|
|
77
|
+
]);
|
|
78
|
+
|
|
29
79
|
export const showConsentBannerContract = oc
|
|
30
80
|
.route({
|
|
31
81
|
method: 'GET',
|
package/src/core.ts
CHANGED
|
@@ -100,5 +100,65 @@ describe('CORS utilities', () => {
|
|
|
100
100
|
false
|
|
101
101
|
);
|
|
102
102
|
});
|
|
103
|
+
|
|
104
|
+
describe('multiple subdomain levels', () => {
|
|
105
|
+
it('should match base domain when explicitly listed', () => {
|
|
106
|
+
const trustedDomains = ['my-site.com'];
|
|
107
|
+
expect(isOriginTrusted('https://my-site.com', trustedDomains)).toBe(
|
|
108
|
+
true
|
|
109
|
+
);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it('should match single-level subdomain with wildcard pattern', () => {
|
|
113
|
+
const trustedDomains = ['*.my-site.com'];
|
|
114
|
+
expect(
|
|
115
|
+
isOriginTrusted('https://foobar.my-site.com', trustedDomains)
|
|
116
|
+
).toBe(true);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it('should match multi-level subdomain with wildcard pattern', () => {
|
|
120
|
+
const trustedDomains = ['*.my-site.com'];
|
|
121
|
+
expect(
|
|
122
|
+
isOriginTrusted('https://foo.bar.my-site.com', trustedDomains)
|
|
123
|
+
).toBe(true);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it('should match three-level subdomain with wildcard pattern', () => {
|
|
127
|
+
const trustedDomains = ['*.my-site.com'];
|
|
128
|
+
expect(
|
|
129
|
+
isOriginTrusted('https://a.b.c.my-site.com', trustedDomains)
|
|
130
|
+
).toBe(true);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it('should not match base domain with wildcard pattern', () => {
|
|
134
|
+
const trustedDomains = ['*.my-site.com'];
|
|
135
|
+
expect(isOriginTrusted('https://my-site.com', trustedDomains)).toBe(
|
|
136
|
+
false
|
|
137
|
+
);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it('should not match similar domain that is not a subdomain', () => {
|
|
141
|
+
const trustedDomains = ['*.my-site.com'];
|
|
142
|
+
expect(isOriginTrusted('https://notmy-site.com', trustedDomains)).toBe(
|
|
143
|
+
false
|
|
144
|
+
);
|
|
145
|
+
expect(
|
|
146
|
+
isOriginTrusted('https://foobar-my-site.com', trustedDomains)
|
|
147
|
+
).toBe(false);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it('should match both base domain and subdomains when both are configured', () => {
|
|
151
|
+
const trustedDomains = ['my-site.com', '*.my-site.com'];
|
|
152
|
+
expect(isOriginTrusted('https://my-site.com', trustedDomains)).toBe(
|
|
153
|
+
true
|
|
154
|
+
);
|
|
155
|
+
expect(
|
|
156
|
+
isOriginTrusted('https://foobar.my-site.com', trustedDomains)
|
|
157
|
+
).toBe(true);
|
|
158
|
+
expect(
|
|
159
|
+
isOriginTrusted('https://foo.bar.my-site.com', trustedDomains)
|
|
160
|
+
).toBe(true);
|
|
161
|
+
});
|
|
162
|
+
});
|
|
103
163
|
});
|
|
104
164
|
});
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @packageDocumentation
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import type { Logger } from '@
|
|
7
|
+
import type { Logger } from '@c15t/logger';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Regular expression to strip protocol, trailing slashes, and port numbers from URLs
|
|
@@ -34,11 +34,14 @@ function matchesWildcard(
|
|
|
34
34
|
logger?: Logger
|
|
35
35
|
): boolean {
|
|
36
36
|
const wildcardDomain = wildcardPattern.slice(2); // Remove *. prefix
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
|
|
38
|
+
// Ensure the hostname is not the base domain and ends with .wildcardDomain
|
|
39
|
+
// This prevents matching domains like 'foobar-my-site.com' against '*.my-site.com'
|
|
40
|
+
const isValid =
|
|
41
|
+
hostname !== wildcardDomain && hostname.endsWith(`.${wildcardDomain}`);
|
|
39
42
|
|
|
40
43
|
logger?.debug(
|
|
41
|
-
`Wildcard match result: ${isValid} ${hostname} ends with
|
|
44
|
+
`Wildcard match result: ${isValid} ${hostname} ends with .${wildcardDomain}`
|
|
42
45
|
);
|
|
43
46
|
|
|
44
47
|
return isValid;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Logger } from '@
|
|
1
|
+
import type { Logger } from '@c15t/logger';
|
|
2
2
|
import type { Adapter } from '~/pkgs/db-adapters/types';
|
|
3
3
|
import type { createRegistry } from '~/schema/create-registry';
|
|
4
4
|
import type { DoubleTieOptions } from '../../types/options';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { LoggerOptions } from '@
|
|
1
|
+
import type { LoggerOptions } from '@c15t/logger';
|
|
2
2
|
import type { TableMetadata } from 'kysely';
|
|
3
3
|
import type { Field } from '~/pkgs/data-model';
|
|
4
4
|
import type { KyselyDatabaseType } from '~/pkgs/db-adapters/adapters/kysely-adapter/types';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { createLogger } from '@
|
|
1
|
+
import type { createLogger } from '@c15t/logger';
|
|
2
2
|
import type { DatabaseHook, EntityName } from '~/pkgs/data-model';
|
|
3
3
|
import type { Adapter } from '~/pkgs/db-adapters/types';
|
|
4
4
|
import type { createRegistry } from '~/schema/create-registry';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { LoggerOptions } from '@c15t/logger';
|
|
1
2
|
import type { Translations } from '@c15t/translations';
|
|
2
|
-
import type { LoggerOptions } from '@doubletie/logger';
|
|
3
3
|
import type { Tracer } from '@opentelemetry/api';
|
|
4
4
|
import type { DatabaseHook } from '~/pkgs/data-model';
|
|
5
5
|
import type { DatabaseConfiguration } from '~/pkgs/db-adapters/adapters/kysely-adapter/types';
|
package/src/pkgs/utils/logger.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createLogger as createDTLogger,
|
|
3
|
-
type LoggerOptions,
|
|
4
|
-
} from '@doubletie/logger';
|
|
1
|
+
import { createLogger, type LoggerOptions } from '@c15t/logger';
|
|
5
2
|
|
|
6
|
-
let globalLogger: ReturnType<typeof
|
|
3
|
+
let globalLogger: ReturnType<typeof createLogger>;
|
|
7
4
|
|
|
8
5
|
/**
|
|
9
6
|
* Gets or creates a global logger instance
|
|
@@ -13,9 +10,9 @@ let globalLogger: ReturnType<typeof createDTLogger>;
|
|
|
13
10
|
*/
|
|
14
11
|
export function getLogger(
|
|
15
12
|
options?: LoggerOptions
|
|
16
|
-
): ReturnType<typeof
|
|
13
|
+
): ReturnType<typeof createLogger> {
|
|
17
14
|
if (!globalLogger) {
|
|
18
|
-
globalLogger =
|
|
15
|
+
globalLogger = createLogger({
|
|
19
16
|
level: 'info',
|
|
20
17
|
appName: 'c15t',
|
|
21
18
|
...options,
|
|
@@ -32,7 +29,7 @@ export function getLogger(
|
|
|
32
29
|
*/
|
|
33
30
|
export function initLogger(
|
|
34
31
|
options: LoggerOptions
|
|
35
|
-
): ReturnType<typeof
|
|
36
|
-
globalLogger =
|
|
32
|
+
): ReturnType<typeof createLogger> {
|
|
33
|
+
globalLogger = createLogger(options);
|
|
37
34
|
return globalLogger;
|
|
38
35
|
}
|
package/src/schema/definition.ts
CHANGED
package/src/types/options.ts
CHANGED
|
@@ -8,7 +8,11 @@ const TitleDescriptionSchema = z.object({
|
|
|
8
8
|
description: z.string(),
|
|
9
9
|
});
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Complete translations schema for newer backend versions
|
|
13
|
+
* All fields are required for full functionality
|
|
14
|
+
*/
|
|
15
|
+
const CompleteTranslationsSchema = z.object({
|
|
12
16
|
common: z.object({
|
|
13
17
|
acceptAll: z.string(),
|
|
14
18
|
rejectAll: z.string(),
|
|
@@ -24,8 +28,53 @@ const TranslationsSchema = z.object({
|
|
|
24
28
|
measurement: TitleDescriptionSchema,
|
|
25
29
|
necessary: TitleDescriptionSchema,
|
|
26
30
|
}),
|
|
31
|
+
frame: z.object({
|
|
32
|
+
title: z.string(),
|
|
33
|
+
actionButton: z.string(),
|
|
34
|
+
}),
|
|
27
35
|
});
|
|
28
36
|
|
|
37
|
+
/**
|
|
38
|
+
* Partial translations schema for backward compatibility with older backend versions
|
|
39
|
+
* Allows missing fields to gracefully degrade functionality
|
|
40
|
+
*/
|
|
41
|
+
const PartialTranslationsSchema = z.object({
|
|
42
|
+
common: z
|
|
43
|
+
.object({
|
|
44
|
+
acceptAll: z.string().optional(),
|
|
45
|
+
rejectAll: z.string().optional(),
|
|
46
|
+
customize: z.string().optional(),
|
|
47
|
+
save: z.string().optional(),
|
|
48
|
+
})
|
|
49
|
+
.partial(),
|
|
50
|
+
cookieBanner: TitleDescriptionSchema.partial(),
|
|
51
|
+
consentManagerDialog: TitleDescriptionSchema.partial(),
|
|
52
|
+
consentTypes: z
|
|
53
|
+
.object({
|
|
54
|
+
experience: TitleDescriptionSchema.partial(),
|
|
55
|
+
functionality: TitleDescriptionSchema.partial(),
|
|
56
|
+
marketing: TitleDescriptionSchema.partial(),
|
|
57
|
+
measurement: TitleDescriptionSchema.partial(),
|
|
58
|
+
necessary: TitleDescriptionSchema.partial(),
|
|
59
|
+
})
|
|
60
|
+
.partial(),
|
|
61
|
+
frame: z
|
|
62
|
+
.object({
|
|
63
|
+
title: z.string().optional(),
|
|
64
|
+
actionButton: z.string().optional(),
|
|
65
|
+
})
|
|
66
|
+
.partial(),
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Union schema that accepts both complete and partial translations
|
|
71
|
+
* Provides backward compatibility while maintaining type safety
|
|
72
|
+
*/
|
|
73
|
+
const TranslationsSchema = z.union([
|
|
74
|
+
CompleteTranslationsSchema,
|
|
75
|
+
PartialTranslationsSchema,
|
|
76
|
+
]);
|
|
77
|
+
|
|
29
78
|
export const showConsentBannerContract = oc
|
|
30
79
|
.route({
|
|
31
80
|
method: 'GET',
|
package/src/v2/core.ts
CHANGED
|
@@ -100,5 +100,65 @@ describe('CORS utilities', () => {
|
|
|
100
100
|
false
|
|
101
101
|
);
|
|
102
102
|
});
|
|
103
|
+
|
|
104
|
+
describe('multiple subdomain levels', () => {
|
|
105
|
+
it('should match base domain when explicitly listed', () => {
|
|
106
|
+
const trustedDomains = ['my-site.com'];
|
|
107
|
+
expect(isOriginTrusted('https://my-site.com', trustedDomains)).toBe(
|
|
108
|
+
true
|
|
109
|
+
);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it('should match single-level subdomain with wildcard pattern', () => {
|
|
113
|
+
const trustedDomains = ['*.my-site.com'];
|
|
114
|
+
expect(
|
|
115
|
+
isOriginTrusted('https://foobar.my-site.com', trustedDomains)
|
|
116
|
+
).toBe(true);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it('should match multi-level subdomain with wildcard pattern', () => {
|
|
120
|
+
const trustedDomains = ['*.my-site.com'];
|
|
121
|
+
expect(
|
|
122
|
+
isOriginTrusted('https://foo.bar.my-site.com', trustedDomains)
|
|
123
|
+
).toBe(true);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it('should match three-level subdomain with wildcard pattern', () => {
|
|
127
|
+
const trustedDomains = ['*.my-site.com'];
|
|
128
|
+
expect(
|
|
129
|
+
isOriginTrusted('https://a.b.c.my-site.com', trustedDomains)
|
|
130
|
+
).toBe(true);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it('should not match base domain with wildcard pattern', () => {
|
|
134
|
+
const trustedDomains = ['*.my-site.com'];
|
|
135
|
+
expect(isOriginTrusted('https://my-site.com', trustedDomains)).toBe(
|
|
136
|
+
false
|
|
137
|
+
);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it('should not match similar domain that is not a subdomain', () => {
|
|
141
|
+
const trustedDomains = ['*.my-site.com'];
|
|
142
|
+
expect(isOriginTrusted('https://notmy-site.com', trustedDomains)).toBe(
|
|
143
|
+
false
|
|
144
|
+
);
|
|
145
|
+
expect(
|
|
146
|
+
isOriginTrusted('https://foobar-my-site.com', trustedDomains)
|
|
147
|
+
).toBe(false);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it('should match both base domain and subdomains when both are configured', () => {
|
|
151
|
+
const trustedDomains = ['my-site.com', '*.my-site.com'];
|
|
152
|
+
expect(isOriginTrusted('https://my-site.com', trustedDomains)).toBe(
|
|
153
|
+
true
|
|
154
|
+
);
|
|
155
|
+
expect(
|
|
156
|
+
isOriginTrusted('https://foobar.my-site.com', trustedDomains)
|
|
157
|
+
).toBe(true);
|
|
158
|
+
expect(
|
|
159
|
+
isOriginTrusted('https://foo.bar.my-site.com', trustedDomains)
|
|
160
|
+
).toBe(true);
|
|
161
|
+
});
|
|
162
|
+
});
|
|
103
163
|
});
|
|
104
164
|
});
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @packageDocumentation
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import type { Logger } from '@
|
|
7
|
+
import type { Logger } from '@c15t/logger';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Regular expression to strip protocol, trailing slashes, and port numbers from URLs
|
|
@@ -34,11 +34,14 @@ function matchesWildcard(
|
|
|
34
34
|
logger?: Logger
|
|
35
35
|
): boolean {
|
|
36
36
|
const wildcardDomain = wildcardPattern.slice(2); // Remove *. prefix
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
|
|
38
|
+
// Ensure the hostname is not the base domain and ends with .wildcardDomain
|
|
39
|
+
// This prevents matching domains like 'foobar-my-site.com' against '*.my-site.com'
|
|
40
|
+
const isValid =
|
|
41
|
+
hostname !== wildcardDomain && hostname.endsWith(`.${wildcardDomain}`);
|
|
39
42
|
|
|
40
43
|
logger?.debug(
|
|
41
|
-
`Wildcard match result: ${isValid} ${hostname} ends with
|
|
44
|
+
`Wildcard match result: ${isValid} ${hostname} ends with .${wildcardDomain}`
|
|
42
45
|
);
|
|
43
46
|
|
|
44
47
|
return isValid;
|
package/src/v2/types/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { createLogger, LoggerOptions } from '@c15t/logger';
|
|
1
2
|
import type { Translations } from '@c15t/translations';
|
|
2
|
-
import type { createLogger, LoggerOptions } from '@doubletie/logger';
|
|
3
3
|
import type { Tracer } from '@opentelemetry/api';
|
|
4
4
|
import type { OpenAPIGeneratorOptions } from '@orpc/openapi';
|
|
5
5
|
import type { FumaDB, InferFumaDB } from 'fumadb';
|
package/src/v2/utils/logger.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createLogger as createDTLogger,
|
|
3
|
-
type LoggerOptions,
|
|
4
|
-
} from '@doubletie/logger';
|
|
1
|
+
import { createLogger, type LoggerOptions } from '@c15t/logger';
|
|
5
2
|
|
|
6
|
-
let globalLogger: ReturnType<typeof
|
|
3
|
+
let globalLogger: ReturnType<typeof createLogger>;
|
|
7
4
|
|
|
8
5
|
/**
|
|
9
6
|
* Gets or creates a global logger instance
|
|
@@ -13,9 +10,9 @@ let globalLogger: ReturnType<typeof createDTLogger>;
|
|
|
13
10
|
*/
|
|
14
11
|
export function getLogger(
|
|
15
12
|
options?: LoggerOptions
|
|
16
|
-
): ReturnType<typeof
|
|
13
|
+
): ReturnType<typeof createLogger> {
|
|
17
14
|
if (!globalLogger) {
|
|
18
|
-
globalLogger =
|
|
15
|
+
globalLogger = createLogger({
|
|
19
16
|
level: 'info',
|
|
20
17
|
appName: 'c15t',
|
|
21
18
|
...options,
|
|
@@ -32,7 +29,7 @@ export function getLogger(
|
|
|
32
29
|
*/
|
|
33
30
|
export function initLogger(
|
|
34
31
|
options: LoggerOptions
|
|
35
|
-
): ReturnType<typeof
|
|
36
|
-
globalLogger =
|
|
32
|
+
): ReturnType<typeof createLogger> {
|
|
33
|
+
globalLogger = createLogger(options);
|
|
37
34
|
return globalLogger;
|
|
38
35
|
}
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by genversion.
|
|
2
|
-
export const version = '1.
|
|
2
|
+
export const version = '1.7.0';
|