@c15t/backend 1.4.2 → 1.5.0-canary-20250722085128
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 -11
- package/CHANGELOG.md +6 -0
- package/dist/core.cjs +94 -49
- package/dist/core.d.ts +2 -1
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +92 -48
- package/dist/handlers/consent/show-banner/geo.d.ts +10 -0
- package/dist/handlers/consent/show-banner/geo.d.ts.map +1 -0
- package/dist/handlers/consent/show-banner/geo.test.d.ts +2 -0
- package/dist/handlers/consent/show-banner/geo.test.d.ts.map +1 -0
- package/dist/handlers/consent/{show-banner.handler.d.ts → show-banner/handler.d.ts} +1 -10
- package/dist/handlers/consent/{show-banner.handler.d.ts.map → show-banner/handler.d.ts.map} +1 -1
- package/dist/handlers/consent/show-banner/handler.test.d.ts +2 -0
- package/dist/handlers/consent/show-banner/handler.test.d.ts.map +1 -0
- package/dist/handlers/consent/show-banner/translations.d.ts +13 -0
- package/dist/handlers/consent/show-banner/translations.d.ts.map +1 -0
- package/dist/handlers/consent/show-banner/translations.test.d.ts +2 -0
- package/dist/handlers/consent/show-banner/translations.test.d.ts.map +1 -0
- package/dist/pkgs/types/options.d.ts +10 -0
- package/dist/pkgs/types/options.d.ts.map +1 -1
- package/dist/router.cjs +89 -45
- package/dist/router.js +88 -44
- package/package.json +1 -1
- package/src/core.ts +10 -3
- package/src/handlers/consent/index.ts +1 -1
- package/src/handlers/consent/show-banner/geo.test.ts +281 -0
- package/src/handlers/consent/show-banner/geo.ts +96 -0
- package/src/handlers/consent/show-banner/handler.test.ts +376 -0
- package/src/handlers/consent/show-banner/handler.ts +120 -0
- package/src/handlers/consent/show-banner/translations.test.ts +121 -0
- package/src/handlers/consent/show-banner/translations.ts +79 -0
- package/src/pkgs/types/options.ts +13 -0
- 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/src/handlers/consent/show-banner.handler.test.ts +0 -194
- package/src/handlers/consent/show-banner.handler.ts +0 -190
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
|
|
2
|
-
> @c15t/backend@1.
|
|
2
|
+
> @c15t/backend@1.5.0-canary-20250722085128 build /home/runner/work/c15t/c15t/packages/backend
|
|
3
3
|
> rslib build
|
|
4
4
|
|
|
5
5
|
Rslib v0.6.2
|
|
6
6
|
|
|
7
|
-
ready built in [1m0.
|
|
8
|
-
ready built in [1m0.
|
|
7
|
+
ready built in [1m0.70[22m s[90m (esm)[39m
|
|
8
|
+
ready built in [1m0.70[22m s[90m (cjs)[39m
|
|
9
9
|
start generating declaration files... [90m(esm)[39m
|
|
10
10
|
start generating declaration files... [90m(cjs)[39m
|
|
11
|
-
ready declaration files generated in [1m8.
|
|
12
|
-
ready declaration files generated in [1m8.
|
|
11
|
+
ready declaration files generated in [1m8.79[22m s [90m(esm)[39m
|
|
12
|
+
ready declaration files generated in [1m8.72[22m s [90m(cjs)[39m
|
|
13
13
|
|
|
14
14
|
[34m File (esm) Size [39m
|
|
15
15
|
[2mdist/pkgs/types/[22m[36mindex.js[39m 0.00 kB
|
|
@@ -19,16 +19,16 @@ ready declaration files generated in [1m8.69[22m s [90m(cjs)[39m
|
|
|
19
19
|
[2mdist/pkgs/db-adapters/adapters/memory-adapter/[22m[36mindex.js[39m 44.3 kB
|
|
20
20
|
[2mdist/pkgs/db-adapters/adapters/prisma-adapter/[22m[36mindex.js[39m 47.5 kB
|
|
21
21
|
[2mdist/pkgs/db-adapters/adapters/drizzle-adapter/[22m[36mindex.js[39m 50.0 kB
|
|
22
|
-
[2mdist/[22m[36mrouter.js[39m 50.4 kB
|
|
23
22
|
[2mdist/pkgs/migrations/[22m[36mindex.js[39m 50.7 kB
|
|
23
|
+
[2mdist/[22m[36mrouter.js[39m 52.4 kB
|
|
24
24
|
[2mdist/pkgs/db-adapters/adapters/kysely-adapter/[22m[36mindex.js[39m 55.3 kB
|
|
25
25
|
[2mdist/pkgs/data-model/schema/[22m[36mindex.js[39m 60.9 kB
|
|
26
26
|
[2mdist/schema/[22m[36mindex.js[39m 61.2 kB
|
|
27
27
|
[2mdist/pkgs/data-model/[22m[36mindex.js[39m 61.8 kB
|
|
28
28
|
[2mdist/pkgs/db-adapters/[22m[36mindex.js[39m 89.6 kB
|
|
29
|
-
[2mdist/[22m[36mcore.js[39m
|
|
29
|
+
[2mdist/[22m[36mcore.js[39m 157.2 kB
|
|
30
30
|
|
|
31
|
-
[34mTotal:[39m
|
|
31
|
+
[34mTotal:[39m 784.1 kB
|
|
32
32
|
|
|
33
33
|
[2m -----[22m
|
|
34
34
|
|
|
@@ -39,15 +39,15 @@ ready declaration files generated in [1m8.69[22m s [90m(cjs)[39m
|
|
|
39
39
|
[2mdist/[22m[36mcontracts.cjs[39m 31.7 kB
|
|
40
40
|
[2mdist/pkgs/db-adapters/adapters/memory-adapter/[22m[36mindex.cjs[39m 45.3 kB
|
|
41
41
|
[2mdist/pkgs/db-adapters/adapters/prisma-adapter/[22m[36mindex.cjs[39m 48.4 kB
|
|
42
|
-
[2mdist/[22m[36mrouter.cjs[39m 50.2 kB
|
|
43
42
|
[2mdist/pkgs/db-adapters/adapters/drizzle-adapter/[22m[36mindex.cjs[39m 50.7 kB
|
|
43
|
+
[2mdist/[22m[36mrouter.cjs[39m 52.1 kB
|
|
44
44
|
[2mdist/pkgs/migrations/[22m[36mindex.cjs[39m 52.3 kB
|
|
45
45
|
[2mdist/pkgs/db-adapters/adapters/kysely-adapter/[22m[36mindex.cjs[39m 56.3 kB
|
|
46
46
|
[2mdist/pkgs/data-model/schema/[22m[36mindex.cjs[39m 64.0 kB
|
|
47
47
|
[2mdist/schema/[22m[36mindex.cjs[39m 64.5 kB
|
|
48
48
|
[2mdist/pkgs/data-model/[22m[36mindex.cjs[39m 66.0 kB
|
|
49
49
|
[2mdist/pkgs/db-adapters/[22m[36mindex.cjs[39m 90.8 kB
|
|
50
|
-
[2mdist/[22m[36mcore.cjs[39m
|
|
50
|
+
[2mdist/[22m[36mcore.cjs[39m 156.1 kB
|
|
51
51
|
|
|
52
|
-
[34mTotal:[39m
|
|
52
|
+
[34mTotal:[39m 804.6 kB
|
|
53
53
|
|
package/CHANGELOG.md
CHANGED
package/dist/core.cjs
CHANGED
|
@@ -38,6 +38,8 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
38
38
|
const logger_namespaceObject = require("@doubletie/logger");
|
|
39
39
|
const fetch_namespaceObject = require("@orpc/openapi/fetch");
|
|
40
40
|
const plugins_namespaceObject = require("@orpc/server/plugins");
|
|
41
|
+
const external_defu_namespaceObject = require("defu");
|
|
42
|
+
var external_defu_default = /*#__PURE__*/ __webpack_require__.n(external_defu_namespaceObject);
|
|
41
43
|
const external_neverthrow_namespaceObject = require("neverthrow");
|
|
42
44
|
const server_namespaceObject = require("@orpc/server");
|
|
43
45
|
const error_codes_ERROR_CODES = Object.freeze({
|
|
@@ -288,7 +290,6 @@ function createTelemetryOptions(appName = 'c15t', telemetryConfig) {
|
|
|
288
290
|
const resources_namespaceObject = require("@opentelemetry/resources");
|
|
289
291
|
const sdk_node_namespaceObject = require("@opentelemetry/sdk-node");
|
|
290
292
|
const sdk_trace_base_namespaceObject = require("@opentelemetry/sdk-trace-base");
|
|
291
|
-
const external_defu_namespaceObject = require("defu");
|
|
292
293
|
function utils_applyDefaultValue(inputValue, field, operation) {
|
|
293
294
|
if ('update' === operation) return inputValue;
|
|
294
295
|
if (null == inputValue && field.defaultValue) {
|
|
@@ -2233,9 +2234,7 @@ function getBaseURL(url, path) {
|
|
|
2233
2234
|
const fromEnv = env.C15T_URL || env.NEXT_PUBLIC_C15T_URL || env.PUBLIC_C15T_URL || env.NUXT_PUBLIC_C15T_URL || env.NUXT_PUBLIC_AUTH_URL || ('/' !== env.BASE_URL ? env.BASE_URL : void 0);
|
|
2234
2235
|
if (fromEnv) return withPath(fromEnv, path);
|
|
2235
2236
|
}
|
|
2236
|
-
var package_namespaceObject = {
|
|
2237
|
-
i8: "1.4.2"
|
|
2238
|
-
};
|
|
2237
|
+
var package_namespaceObject = JSON.parse('{"i8":"1.5.0-canary-20250722085128"}');
|
|
2239
2238
|
const createRegistry = (ctx)=>({
|
|
2240
2239
|
...auditLogRegistry(ctx),
|
|
2241
2240
|
...consentRegistry(ctx),
|
|
@@ -3076,46 +3075,6 @@ const postConsent = os.consent.post.handler(async ({ input, context })=>{
|
|
|
3076
3075
|
});
|
|
3077
3076
|
}
|
|
3078
3077
|
});
|
|
3079
|
-
const translations_namespaceObject = require("@c15t/translations");
|
|
3080
|
-
function getPreferredLanguage(acceptLanguage) {
|
|
3081
|
-
if (!acceptLanguage) return 'en';
|
|
3082
|
-
const primaryLang = acceptLanguage.split(',')[0]?.split(';')[0]?.split('-')[0]?.toLowerCase();
|
|
3083
|
-
if (primaryLang && primaryLang in translations_namespaceObject.baseTranslations) return primaryLang;
|
|
3084
|
-
return 'en';
|
|
3085
|
-
}
|
|
3086
|
-
const show_banner_handler_showConsentBanner = os.consent.showBanner.handler(({ context })=>{
|
|
3087
|
-
const typedContext = context;
|
|
3088
|
-
const headers = typedContext.headers;
|
|
3089
|
-
if (!headers) throw new server_namespaceObject.ORPCError('LOCATION_DETECTION_FAILED', {
|
|
3090
|
-
data: {
|
|
3091
|
-
reason: 'No headers found in request context'
|
|
3092
|
-
}
|
|
3093
|
-
});
|
|
3094
|
-
const normalizeHeader = (value)=>{
|
|
3095
|
-
if (!value) return null;
|
|
3096
|
-
return Array.isArray(value) ? value[0] ?? null : value;
|
|
3097
|
-
};
|
|
3098
|
-
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'));
|
|
3099
|
-
const regionCode = normalizeHeader(headers.get('x-c15t-region')) ?? normalizeHeader(headers.get('x-vercel-ip-country-region')) ?? normalizeHeader(headers.get('x-region-code'));
|
|
3100
|
-
const acceptLanguage = normalizeHeader(headers.get('accept-language'));
|
|
3101
|
-
const preferredLanguage = getPreferredLanguage(acceptLanguage);
|
|
3102
|
-
const { showConsentBanner, jurisdictionCode, message } = checkJurisdiction(countryCode);
|
|
3103
|
-
return {
|
|
3104
|
-
showConsentBanner,
|
|
3105
|
-
jurisdiction: {
|
|
3106
|
-
code: jurisdictionCode,
|
|
3107
|
-
message
|
|
3108
|
-
},
|
|
3109
|
-
location: {
|
|
3110
|
-
countryCode,
|
|
3111
|
-
regionCode
|
|
3112
|
-
},
|
|
3113
|
-
translations: {
|
|
3114
|
-
translations: translations_namespaceObject.baseTranslations[preferredLanguage],
|
|
3115
|
-
language: preferredLanguage
|
|
3116
|
-
}
|
|
3117
|
-
};
|
|
3118
|
-
});
|
|
3119
3078
|
function checkJurisdiction(countryCode) {
|
|
3120
3079
|
const jurisdictions = {
|
|
3121
3080
|
EU: new Set([
|
|
@@ -3177,6 +3136,7 @@ function checkJurisdiction(countryCode) {
|
|
|
3177
3136
|
let showConsentBanner = true;
|
|
3178
3137
|
let jurisdictionCode = 'NONE';
|
|
3179
3138
|
if (countryCode) {
|
|
3139
|
+
const normalizedCountryCode = countryCode.toUpperCase();
|
|
3180
3140
|
showConsentBanner = false;
|
|
3181
3141
|
const jurisdictionMap = [
|
|
3182
3142
|
{
|
|
@@ -3224,7 +3184,7 @@ function checkJurisdiction(countryCode) {
|
|
|
3224
3184
|
code: 'PIPA'
|
|
3225
3185
|
}
|
|
3226
3186
|
];
|
|
3227
|
-
for (const { sets, code } of jurisdictionMap)if (sets.some((set)=>set.has(
|
|
3187
|
+
for (const { sets, code } of jurisdictionMap)if (sets.some((set)=>set.has(normalizedCountryCode))) {
|
|
3228
3188
|
jurisdictionCode = code;
|
|
3229
3189
|
showConsentBanner = true;
|
|
3230
3190
|
break;
|
|
@@ -3237,6 +3197,91 @@ function checkJurisdiction(countryCode) {
|
|
|
3237
3197
|
message
|
|
3238
3198
|
};
|
|
3239
3199
|
}
|
|
3200
|
+
const translations_namespaceObject = require("@c15t/translations");
|
|
3201
|
+
function isSupportedBaseLanguage(lang) {
|
|
3202
|
+
return lang in translations_namespaceObject.baseTranslations;
|
|
3203
|
+
}
|
|
3204
|
+
function getPreferredLanguage(acceptLanguage, supportedLanguages) {
|
|
3205
|
+
if (!acceptLanguage) return 'en';
|
|
3206
|
+
const primaryLang = acceptLanguage.split(',')[0]?.split(';')[0]?.split('-')[0]?.toLowerCase();
|
|
3207
|
+
if (primaryLang && supportedLanguages.includes(primaryLang)) return primaryLang;
|
|
3208
|
+
return 'en';
|
|
3209
|
+
}
|
|
3210
|
+
function getTranslations(acceptLanguage, customTranslations) {
|
|
3211
|
+
const supportedDefaultLanguages = Object.keys(translations_namespaceObject.baseTranslations);
|
|
3212
|
+
const supportedCustomLanguages = Object.keys(customTranslations || {});
|
|
3213
|
+
const supportedLanguages = [
|
|
3214
|
+
...supportedDefaultLanguages,
|
|
3215
|
+
...supportedCustomLanguages
|
|
3216
|
+
];
|
|
3217
|
+
const preferredLanguage = getPreferredLanguage(acceptLanguage, supportedLanguages);
|
|
3218
|
+
const base = isSupportedBaseLanguage(preferredLanguage) ? translations_namespaceObject.baseTranslations[preferredLanguage] : translations_namespaceObject.baseTranslations.en;
|
|
3219
|
+
const custom = supportedCustomLanguages.includes(preferredLanguage) ? customTranslations?.[preferredLanguage] : {};
|
|
3220
|
+
const translations = custom ? (0, translations_namespaceObject.deepMergeTranslations)(base, custom) : base;
|
|
3221
|
+
return {
|
|
3222
|
+
translations: translations,
|
|
3223
|
+
language: preferredLanguage
|
|
3224
|
+
};
|
|
3225
|
+
}
|
|
3226
|
+
function getHeaders(headers) {
|
|
3227
|
+
if (!headers) throw new server_namespaceObject.ORPCError('LOCATION_DETECTION_FAILED', {
|
|
3228
|
+
data: {
|
|
3229
|
+
reason: 'No headers found in request context'
|
|
3230
|
+
}
|
|
3231
|
+
});
|
|
3232
|
+
const normalizeHeader = (value)=>{
|
|
3233
|
+
if (!value) return null;
|
|
3234
|
+
return Array.isArray(value) ? value[0] ?? null : value;
|
|
3235
|
+
};
|
|
3236
|
+
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'));
|
|
3237
|
+
const regionCode = normalizeHeader(headers.get('x-c15t-region')) ?? normalizeHeader(headers.get('x-vercel-ip-country-region')) ?? normalizeHeader(headers.get('x-region-code'));
|
|
3238
|
+
const acceptLanguage = normalizeHeader(headers.get('accept-language'));
|
|
3239
|
+
return {
|
|
3240
|
+
countryCode,
|
|
3241
|
+
regionCode,
|
|
3242
|
+
acceptLanguage
|
|
3243
|
+
};
|
|
3244
|
+
}
|
|
3245
|
+
function buildResponse({ shouldShowBanner, jurisdiction, location, acceptLanguage, customTranslations }) {
|
|
3246
|
+
return {
|
|
3247
|
+
showConsentBanner: shouldShowBanner,
|
|
3248
|
+
jurisdiction,
|
|
3249
|
+
location,
|
|
3250
|
+
translations: getTranslations(acceptLanguage, customTranslations)
|
|
3251
|
+
};
|
|
3252
|
+
}
|
|
3253
|
+
const handler_showConsentBanner = os.consent.showBanner.handler(({ context })=>{
|
|
3254
|
+
const typedContext = context;
|
|
3255
|
+
const { customTranslations, disableGeoLocation } = typedContext.options.advanced ?? {};
|
|
3256
|
+
const { countryCode, regionCode, acceptLanguage } = getHeaders(typedContext.headers);
|
|
3257
|
+
if (disableGeoLocation) return buildResponse({
|
|
3258
|
+
shouldShowBanner: true,
|
|
3259
|
+
jurisdiction: {
|
|
3260
|
+
code: 'NONE',
|
|
3261
|
+
message: JurisdictionMessages.NONE
|
|
3262
|
+
},
|
|
3263
|
+
location: {
|
|
3264
|
+
countryCode: null,
|
|
3265
|
+
regionCode: null
|
|
3266
|
+
},
|
|
3267
|
+
acceptLanguage,
|
|
3268
|
+
customTranslations
|
|
3269
|
+
});
|
|
3270
|
+
const { showConsentBanner, jurisdictionCode, message } = checkJurisdiction(countryCode);
|
|
3271
|
+
return buildResponse({
|
|
3272
|
+
shouldShowBanner: showConsentBanner,
|
|
3273
|
+
jurisdiction: {
|
|
3274
|
+
code: jurisdictionCode,
|
|
3275
|
+
message
|
|
3276
|
+
},
|
|
3277
|
+
location: {
|
|
3278
|
+
countryCode,
|
|
3279
|
+
regionCode
|
|
3280
|
+
},
|
|
3281
|
+
acceptLanguage,
|
|
3282
|
+
customTranslations
|
|
3283
|
+
});
|
|
3284
|
+
});
|
|
3240
3285
|
const verifyConsent = os.consent.verify.handler(async ({ input, context })=>{
|
|
3241
3286
|
const typedContext = context;
|
|
3242
3287
|
const logger = typedContext.logger;
|
|
@@ -3388,7 +3433,7 @@ async function checkPolicyConsent({ policyId, subjectId, domainId, purposeIds, t
|
|
|
3388
3433
|
}
|
|
3389
3434
|
const consentHandlers = {
|
|
3390
3435
|
post: postConsent,
|
|
3391
|
-
showBanner:
|
|
3436
|
+
showBanner: handler_showConsentBanner,
|
|
3392
3437
|
verify: verifyConsent
|
|
3393
3438
|
};
|
|
3394
3439
|
const statusHandler = os.meta.status.handler(({ context })=>{
|
|
@@ -3668,7 +3713,7 @@ const c15tInstance = (options)=>{
|
|
|
3668
3713
|
headers: request.headers,
|
|
3669
3714
|
userAgent: request.headers.get('user-agent') || void 0,
|
|
3670
3715
|
appName: options.appName || 'c15t',
|
|
3671
|
-
options,
|
|
3716
|
+
options: ctx.options,
|
|
3672
3717
|
trustedOrigins: options.trustedOrigins || [],
|
|
3673
3718
|
baseURL: options.baseURL || '/',
|
|
3674
3719
|
tables: ctx.tables
|
|
@@ -3701,7 +3746,7 @@ const c15tInstance = (options)=>{
|
|
|
3701
3746
|
status: 404
|
|
3702
3747
|
});
|
|
3703
3748
|
};
|
|
3704
|
-
const handler = async (request)=>{
|
|
3749
|
+
const handler = async (request, ctxOverride)=>{
|
|
3705
3750
|
try {
|
|
3706
3751
|
const url = new URL(request.url);
|
|
3707
3752
|
(0, logger_namespaceObject.createLogger)(options.logger)?.debug?.('Incoming request', {
|
|
@@ -3714,7 +3759,7 @@ const c15tInstance = (options)=>{
|
|
|
3714
3759
|
if (docsResponse) return docsResponse;
|
|
3715
3760
|
const ctxResult = await contextPromise;
|
|
3716
3761
|
if (!ctxResult.isOk()) throw ctxResult.error;
|
|
3717
|
-
const ctx = ctxResult.value;
|
|
3762
|
+
const ctx = external_defu_default()(ctxOverride || {}, ctxResult.value);
|
|
3718
3763
|
const basePath = options.basePath || options.baseURL || '/';
|
|
3719
3764
|
(0, logger_namespaceObject.createLogger)(options.logger)?.debug?.('[c15t] Using basePath/baseURL', {
|
|
3720
3765
|
basePath
|
package/dist/core.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DeepPartial } from './pkgs/types/helper';
|
|
1
2
|
import type { C15TContext, C15TOptions, C15TPlugin } from './types';
|
|
2
3
|
import { router } from './router';
|
|
3
4
|
/**
|
|
@@ -941,7 +942,7 @@ export declare const c15tInstance: <PluginTypes extends C15TPlugin[] = C15TPlugi
|
|
|
941
942
|
}>, import("@orpc/contract").MergedErrorMap<Record<never, never>, Record<never, never>>, Record<never, never>>;
|
|
942
943
|
};
|
|
943
944
|
};
|
|
944
|
-
handler: (request: Request) => Promise<Response>;
|
|
945
|
+
handler: (request: Request, ctxOverride?: DeepPartial<C15TContext>) => Promise<Response>;
|
|
945
946
|
};
|
|
946
947
|
export type { C15TPlugin, C15TOptions, C15TContext };
|
|
947
948
|
export type { ContractsInputs, ContractsOutputs } from './contracts';
|
package/dist/core.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"A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
2
|
import * as __WEBPACK_EXTERNAL_MODULE__orpc_openapi_fetch_89b49e61__ from "@orpc/openapi/fetch";
|
|
3
3
|
import * as __WEBPACK_EXTERNAL_MODULE__orpc_server_plugins_e445fd4f__ from "@orpc/server/plugins";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE_defu__ from "defu";
|
|
4
5
|
import * as __WEBPACK_EXTERNAL_MODULE_neverthrow__ from "neverthrow";
|
|
5
6
|
import * as __WEBPACK_EXTERNAL_MODULE__orpc_server_0dae8408__ from "@orpc/server";
|
|
6
7
|
import * as __WEBPACK_EXTERNAL_MODULE__opentelemetry_api_87359e78__ from "@opentelemetry/api";
|
|
7
8
|
import * as __WEBPACK_EXTERNAL_MODULE__opentelemetry_resources_c7ac8648__ from "@opentelemetry/resources";
|
|
8
9
|
import * as __WEBPACK_EXTERNAL_MODULE__opentelemetry_sdk_node_50b75088__ from "@opentelemetry/sdk-node";
|
|
9
10
|
import * as __WEBPACK_EXTERNAL_MODULE__opentelemetry_sdk_trace_base_5031a705__ from "@opentelemetry/sdk-trace-base";
|
|
10
|
-
import * as __WEBPACK_EXTERNAL_MODULE_defu__ from "defu";
|
|
11
11
|
import * as __WEBPACK_EXTERNAL_MODULE_superjson__ from "superjson";
|
|
12
12
|
import * as __WEBPACK_EXTERNAL_MODULE_base_x_aeb88370__ from "base-x";
|
|
13
13
|
import * as __WEBPACK_EXTERNAL_MODULE_zod__ from "zod";
|
|
@@ -2198,9 +2198,7 @@ function getBaseURL(url, path) {
|
|
|
2198
2198
|
const fromEnv = env.C15T_URL || env.NEXT_PUBLIC_C15T_URL || env.PUBLIC_C15T_URL || env.NUXT_PUBLIC_C15T_URL || env.NUXT_PUBLIC_AUTH_URL || ('/' !== env.BASE_URL ? env.BASE_URL : void 0);
|
|
2199
2199
|
if (fromEnv) return withPath(fromEnv, path);
|
|
2200
2200
|
}
|
|
2201
|
-
var package_namespaceObject = {
|
|
2202
|
-
i8: "1.4.2"
|
|
2203
|
-
};
|
|
2201
|
+
var package_namespaceObject = JSON.parse('{"i8":"1.5.0-canary-20250722085128"}');
|
|
2204
2202
|
const createRegistry = (ctx)=>({
|
|
2205
2203
|
...auditLogRegistry(ctx),
|
|
2206
2204
|
...consentRegistry(ctx),
|
|
@@ -3038,45 +3036,6 @@ const postConsent = os.consent.post.handler(async ({ input, context })=>{
|
|
|
3038
3036
|
});
|
|
3039
3037
|
}
|
|
3040
3038
|
});
|
|
3041
|
-
function getPreferredLanguage(acceptLanguage) {
|
|
3042
|
-
if (!acceptLanguage) return 'en';
|
|
3043
|
-
const primaryLang = acceptLanguage.split(',')[0]?.split(';')[0]?.split('-')[0]?.toLowerCase();
|
|
3044
|
-
if (primaryLang && primaryLang in __WEBPACK_EXTERNAL_MODULE__c15t_translations_cdae900b__.baseTranslations) return primaryLang;
|
|
3045
|
-
return 'en';
|
|
3046
|
-
}
|
|
3047
|
-
const show_banner_handler_showConsentBanner = os.consent.showBanner.handler(({ context })=>{
|
|
3048
|
-
const typedContext = context;
|
|
3049
|
-
const headers = typedContext.headers;
|
|
3050
|
-
if (!headers) throw new __WEBPACK_EXTERNAL_MODULE__orpc_server_0dae8408__.ORPCError('LOCATION_DETECTION_FAILED', {
|
|
3051
|
-
data: {
|
|
3052
|
-
reason: 'No headers found in request context'
|
|
3053
|
-
}
|
|
3054
|
-
});
|
|
3055
|
-
const normalizeHeader = (value)=>{
|
|
3056
|
-
if (!value) return null;
|
|
3057
|
-
return Array.isArray(value) ? value[0] ?? null : value;
|
|
3058
|
-
};
|
|
3059
|
-
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'));
|
|
3060
|
-
const regionCode = normalizeHeader(headers.get('x-c15t-region')) ?? normalizeHeader(headers.get('x-vercel-ip-country-region')) ?? normalizeHeader(headers.get('x-region-code'));
|
|
3061
|
-
const acceptLanguage = normalizeHeader(headers.get('accept-language'));
|
|
3062
|
-
const preferredLanguage = getPreferredLanguage(acceptLanguage);
|
|
3063
|
-
const { showConsentBanner, jurisdictionCode, message } = checkJurisdiction(countryCode);
|
|
3064
|
-
return {
|
|
3065
|
-
showConsentBanner,
|
|
3066
|
-
jurisdiction: {
|
|
3067
|
-
code: jurisdictionCode,
|
|
3068
|
-
message
|
|
3069
|
-
},
|
|
3070
|
-
location: {
|
|
3071
|
-
countryCode,
|
|
3072
|
-
regionCode
|
|
3073
|
-
},
|
|
3074
|
-
translations: {
|
|
3075
|
-
translations: __WEBPACK_EXTERNAL_MODULE__c15t_translations_cdae900b__.baseTranslations[preferredLanguage],
|
|
3076
|
-
language: preferredLanguage
|
|
3077
|
-
}
|
|
3078
|
-
};
|
|
3079
|
-
});
|
|
3080
3039
|
function checkJurisdiction(countryCode) {
|
|
3081
3040
|
const jurisdictions = {
|
|
3082
3041
|
EU: new Set([
|
|
@@ -3138,6 +3097,7 @@ function checkJurisdiction(countryCode) {
|
|
|
3138
3097
|
let showConsentBanner = true;
|
|
3139
3098
|
let jurisdictionCode = 'NONE';
|
|
3140
3099
|
if (countryCode) {
|
|
3100
|
+
const normalizedCountryCode = countryCode.toUpperCase();
|
|
3141
3101
|
showConsentBanner = false;
|
|
3142
3102
|
const jurisdictionMap = [
|
|
3143
3103
|
{
|
|
@@ -3185,7 +3145,7 @@ function checkJurisdiction(countryCode) {
|
|
|
3185
3145
|
code: 'PIPA'
|
|
3186
3146
|
}
|
|
3187
3147
|
];
|
|
3188
|
-
for (const { sets, code } of jurisdictionMap)if (sets.some((set)=>set.has(
|
|
3148
|
+
for (const { sets, code } of jurisdictionMap)if (sets.some((set)=>set.has(normalizedCountryCode))) {
|
|
3189
3149
|
jurisdictionCode = code;
|
|
3190
3150
|
showConsentBanner = true;
|
|
3191
3151
|
break;
|
|
@@ -3198,6 +3158,90 @@ function checkJurisdiction(countryCode) {
|
|
|
3198
3158
|
message
|
|
3199
3159
|
};
|
|
3200
3160
|
}
|
|
3161
|
+
function isSupportedBaseLanguage(lang) {
|
|
3162
|
+
return lang in __WEBPACK_EXTERNAL_MODULE__c15t_translations_cdae900b__.baseTranslations;
|
|
3163
|
+
}
|
|
3164
|
+
function getPreferredLanguage(acceptLanguage, supportedLanguages) {
|
|
3165
|
+
if (!acceptLanguage) return 'en';
|
|
3166
|
+
const primaryLang = acceptLanguage.split(',')[0]?.split(';')[0]?.split('-')[0]?.toLowerCase();
|
|
3167
|
+
if (primaryLang && supportedLanguages.includes(primaryLang)) return primaryLang;
|
|
3168
|
+
return 'en';
|
|
3169
|
+
}
|
|
3170
|
+
function getTranslations(acceptLanguage, customTranslations) {
|
|
3171
|
+
const supportedDefaultLanguages = Object.keys(__WEBPACK_EXTERNAL_MODULE__c15t_translations_cdae900b__.baseTranslations);
|
|
3172
|
+
const supportedCustomLanguages = Object.keys(customTranslations || {});
|
|
3173
|
+
const supportedLanguages = [
|
|
3174
|
+
...supportedDefaultLanguages,
|
|
3175
|
+
...supportedCustomLanguages
|
|
3176
|
+
];
|
|
3177
|
+
const preferredLanguage = getPreferredLanguage(acceptLanguage, supportedLanguages);
|
|
3178
|
+
const base = isSupportedBaseLanguage(preferredLanguage) ? __WEBPACK_EXTERNAL_MODULE__c15t_translations_cdae900b__.baseTranslations[preferredLanguage] : __WEBPACK_EXTERNAL_MODULE__c15t_translations_cdae900b__.baseTranslations.en;
|
|
3179
|
+
const custom = supportedCustomLanguages.includes(preferredLanguage) ? customTranslations?.[preferredLanguage] : {};
|
|
3180
|
+
const translations = custom ? (0, __WEBPACK_EXTERNAL_MODULE__c15t_translations_cdae900b__.deepMergeTranslations)(base, custom) : base;
|
|
3181
|
+
return {
|
|
3182
|
+
translations: translations,
|
|
3183
|
+
language: preferredLanguage
|
|
3184
|
+
};
|
|
3185
|
+
}
|
|
3186
|
+
function getHeaders(headers) {
|
|
3187
|
+
if (!headers) throw new __WEBPACK_EXTERNAL_MODULE__orpc_server_0dae8408__.ORPCError('LOCATION_DETECTION_FAILED', {
|
|
3188
|
+
data: {
|
|
3189
|
+
reason: 'No headers found in request context'
|
|
3190
|
+
}
|
|
3191
|
+
});
|
|
3192
|
+
const normalizeHeader = (value)=>{
|
|
3193
|
+
if (!value) return null;
|
|
3194
|
+
return Array.isArray(value) ? value[0] ?? null : value;
|
|
3195
|
+
};
|
|
3196
|
+
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'));
|
|
3197
|
+
const regionCode = normalizeHeader(headers.get('x-c15t-region')) ?? normalizeHeader(headers.get('x-vercel-ip-country-region')) ?? normalizeHeader(headers.get('x-region-code'));
|
|
3198
|
+
const acceptLanguage = normalizeHeader(headers.get('accept-language'));
|
|
3199
|
+
return {
|
|
3200
|
+
countryCode,
|
|
3201
|
+
regionCode,
|
|
3202
|
+
acceptLanguage
|
|
3203
|
+
};
|
|
3204
|
+
}
|
|
3205
|
+
function buildResponse({ shouldShowBanner, jurisdiction, location, acceptLanguage, customTranslations }) {
|
|
3206
|
+
return {
|
|
3207
|
+
showConsentBanner: shouldShowBanner,
|
|
3208
|
+
jurisdiction,
|
|
3209
|
+
location,
|
|
3210
|
+
translations: getTranslations(acceptLanguage, customTranslations)
|
|
3211
|
+
};
|
|
3212
|
+
}
|
|
3213
|
+
const handler_showConsentBanner = os.consent.showBanner.handler(({ context })=>{
|
|
3214
|
+
const typedContext = context;
|
|
3215
|
+
const { customTranslations, disableGeoLocation } = typedContext.options.advanced ?? {};
|
|
3216
|
+
const { countryCode, regionCode, acceptLanguage } = getHeaders(typedContext.headers);
|
|
3217
|
+
if (disableGeoLocation) return buildResponse({
|
|
3218
|
+
shouldShowBanner: true,
|
|
3219
|
+
jurisdiction: {
|
|
3220
|
+
code: 'NONE',
|
|
3221
|
+
message: JurisdictionMessages.NONE
|
|
3222
|
+
},
|
|
3223
|
+
location: {
|
|
3224
|
+
countryCode: null,
|
|
3225
|
+
regionCode: null
|
|
3226
|
+
},
|
|
3227
|
+
acceptLanguage,
|
|
3228
|
+
customTranslations
|
|
3229
|
+
});
|
|
3230
|
+
const { showConsentBanner, jurisdictionCode, message } = checkJurisdiction(countryCode);
|
|
3231
|
+
return buildResponse({
|
|
3232
|
+
shouldShowBanner: showConsentBanner,
|
|
3233
|
+
jurisdiction: {
|
|
3234
|
+
code: jurisdictionCode,
|
|
3235
|
+
message
|
|
3236
|
+
},
|
|
3237
|
+
location: {
|
|
3238
|
+
countryCode,
|
|
3239
|
+
regionCode
|
|
3240
|
+
},
|
|
3241
|
+
acceptLanguage,
|
|
3242
|
+
customTranslations
|
|
3243
|
+
});
|
|
3244
|
+
});
|
|
3201
3245
|
const verifyConsent = os.consent.verify.handler(async ({ input, context })=>{
|
|
3202
3246
|
const typedContext = context;
|
|
3203
3247
|
const logger = typedContext.logger;
|
|
@@ -3349,7 +3393,7 @@ async function checkPolicyConsent({ policyId, subjectId, domainId, purposeIds, t
|
|
|
3349
3393
|
}
|
|
3350
3394
|
const consentHandlers = {
|
|
3351
3395
|
post: postConsent,
|
|
3352
|
-
showBanner:
|
|
3396
|
+
showBanner: handler_showConsentBanner,
|
|
3353
3397
|
verify: verifyConsent
|
|
3354
3398
|
};
|
|
3355
3399
|
const statusHandler = os.meta.status.handler(({ context })=>{
|
|
@@ -3629,7 +3673,7 @@ const c15tInstance = (options)=>{
|
|
|
3629
3673
|
headers: request.headers,
|
|
3630
3674
|
userAgent: request.headers.get('user-agent') || void 0,
|
|
3631
3675
|
appName: options.appName || 'c15t',
|
|
3632
|
-
options,
|
|
3676
|
+
options: ctx.options,
|
|
3633
3677
|
trustedOrigins: options.trustedOrigins || [],
|
|
3634
3678
|
baseURL: options.baseURL || '/',
|
|
3635
3679
|
tables: ctx.tables
|
|
@@ -3662,7 +3706,7 @@ const c15tInstance = (options)=>{
|
|
|
3662
3706
|
status: 404
|
|
3663
3707
|
});
|
|
3664
3708
|
};
|
|
3665
|
-
const handler = async (request)=>{
|
|
3709
|
+
const handler = async (request, ctxOverride)=>{
|
|
3666
3710
|
try {
|
|
3667
3711
|
const url = new URL(request.url);
|
|
3668
3712
|
(0, __WEBPACK_EXTERNAL_MODULE__doubletie_logger_91c58a8f__.createLogger)(options.logger)?.debug?.('Incoming request', {
|
|
@@ -3675,7 +3719,7 @@ const c15tInstance = (options)=>{
|
|
|
3675
3719
|
if (docsResponse) return docsResponse;
|
|
3676
3720
|
const ctxResult = await contextPromise;
|
|
3677
3721
|
if (!ctxResult.isOk()) throw ctxResult.error;
|
|
3678
|
-
const ctx = ctxResult.value;
|
|
3722
|
+
const ctx = (0, __WEBPACK_EXTERNAL_MODULE_defu__["default"])(ctxOverride || {}, ctxResult.value);
|
|
3679
3723
|
const basePath = options.basePath || options.baseURL || '/';
|
|
3680
3724
|
(0, __WEBPACK_EXTERNAL_MODULE__doubletie_logger_91c58a8f__.createLogger)(options.logger)?.debug?.('[c15t] Using basePath/baseURL', {
|
|
3681
3725
|
basePath
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Determines if a consent banner should be shown based on country code
|
|
3
|
+
* and returns appropriate jurisdiction information
|
|
4
|
+
*/
|
|
5
|
+
export declare function checkJurisdiction(countryCode: string | null): {
|
|
6
|
+
showConsentBanner: boolean;
|
|
7
|
+
jurisdictionCode: "GDPR" | "CH" | "BR" | "PIPEDA" | "AU" | "APPI" | "PIPA" | "NONE";
|
|
8
|
+
message: "GDPR or equivalent regulations require a cookie banner." | "Switzerland requires similar data protection measures." | "Brazil's LGPD requires consent for cookies." | "PIPEDA requires consent for data collection." | "Australia's Privacy Act mandates transparency about data collection." | "Japan's APPI requires consent for data collection." | "South Korea's PIPA requires consent for data collection." | "No specific requirements";
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=geo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geo.d.ts","sourceRoot":"","sources":["../../../../src/handlers/consent/show-banner/geo.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;;;;EAsF3D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geo.test.d.ts","sourceRoot":"","sources":["../../../../src/handlers/consent/show-banner/geo.test.ts"],"names":[],"mappings":""}
|
|
@@ -416,13 +416,4 @@ export declare const showConsentBanner: import("@orpc/server").ImplementedProced
|
|
|
416
416
|
language: string;
|
|
417
417
|
};
|
|
418
418
|
}>, Record<never, never>, Record<never, never>>;
|
|
419
|
-
|
|
420
|
-
* Determines if a consent banner should be shown based on country code
|
|
421
|
-
* and returns appropriate jurisdiction information
|
|
422
|
-
*/
|
|
423
|
-
export declare function checkJurisdiction(countryCode: string | null): {
|
|
424
|
-
showConsentBanner: boolean;
|
|
425
|
-
jurisdictionCode: "GDPR" | "CH" | "BR" | "PIPEDA" | "AU" | "APPI" | "PIPA" | "NONE";
|
|
426
|
-
message: "GDPR or equivalent regulations require a cookie banner." | "Switzerland requires similar data protection measures." | "Brazil's LGPD requires consent for cookies." | "PIPEDA requires consent for data collection." | "Australia's Privacy Act mandates transparency about data collection." | "Japan's APPI requires consent for data collection." | "South Korea's PIPA requires consent for data collection." | "No specific requirements";
|
|
427
|
-
};
|
|
428
|
-
//# sourceMappingURL=show-banner.handler.d.ts.map
|
|
419
|
+
//# sourceMappingURL=handler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../../../src/handlers/consent/show-banner/handler.ts"],"names":[],"mappings":"AA8EA;;;GAGG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+CAqC7B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.test.d.ts","sourceRoot":"","sources":["../../../../src/handlers/consent/show-banner/handler.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type CompleteTranslations, type Translations } from '@c15t/translations';
|
|
2
|
+
/**
|
|
3
|
+
* Gets the translations for a given language, merging custom translations if provided.
|
|
4
|
+
*
|
|
5
|
+
* @param acceptLanguage - The `Accept-Language` header from the request.
|
|
6
|
+
* @param customTranslations - An object containing custom translations to merge with the base translations.
|
|
7
|
+
* @returns An object containing the final translations and the determined language.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getTranslations(acceptLanguage: string | null, customTranslations?: Record<string, Partial<Translations>>): {
|
|
10
|
+
translations: CompleteTranslations;
|
|
11
|
+
language: string;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=translations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../../../src/handlers/consent/show-banner/translations.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,oBAAoB,EACzB,KAAK,YAAY,EAGjB,MAAM,oBAAoB,CAAC;AAmC5B;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC9B,cAAc,EAAE,MAAM,GAAG,IAAI,EAC7B,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;kBA0B3B,oBAAoB;;EAGnD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"translations.test.d.ts","sourceRoot":"","sources":["../../../../src/handlers/consent/show-banner/translations.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { DatabaseHook } from '../data-model';
|
|
2
2
|
import type { DatabaseConfiguration } from '../db-adapters/adapters/kysely-adapter/types';
|
|
3
|
+
import type { Translations } from '@c15t/translations';
|
|
3
4
|
import type { LoggerOptions } from '@doubletie/logger';
|
|
4
5
|
import type { Tracer } from '@opentelemetry/api';
|
|
5
6
|
import type { TablesConfig } from '../../schema/types';
|
|
@@ -81,6 +82,15 @@ export interface DoubleTieOptions {
|
|
|
81
82
|
* Settings for specialized use cases
|
|
82
83
|
*/
|
|
83
84
|
advanced?: {
|
|
85
|
+
/**
|
|
86
|
+
* Disable Geo-Location detection
|
|
87
|
+
*/
|
|
88
|
+
disableGeoLocation?: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Custom Translation Strings
|
|
91
|
+
* Override the default translations with your own
|
|
92
|
+
*/
|
|
93
|
+
customTranslations?: Record<string, Partial<Translations>>;
|
|
84
94
|
/**
|
|
85
95
|
* Ip address configuration
|
|
86
96
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../src/pkgs/types/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kDAAkD,CAAC;AAE9F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,MAAM,EAAE,M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