@szymonpiatek/nextwordpress 0.0.12 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/index.cjs +45 -6
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +2 -2
- package/dist/client/index.d.ts +2 -2
- package/dist/client/index.js +45 -7
- package/dist/client/index.js.map +1 -1
- package/dist/hooks/index.cjs +45 -6
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.cts +9 -2
- package/dist/hooks/index.d.ts +9 -2
- package/dist/hooks/index.js +45 -7
- package/dist/hooks/index.js.map +1 -1
- package/dist/index.cjs +55 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +54 -1
- package/dist/index.js.map +1 -1
- package/dist/server/index.cjs +55 -0
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +54 -1
- package/dist/server/index.js.map +1 -1
- package/dist/{types-WcyioRuq.d.cts → types-BELSHjQr.d.cts} +13 -1
- package/dist/{types-WcyioRuq.d.ts → types-BELSHjQr.d.ts} +13 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4209,6 +4209,59 @@ async function resolvePreviewSlug(config, postId, previewPathname) {
|
|
|
4209
4209
|
return data.slug ?? `preview-${postId}`;
|
|
4210
4210
|
}
|
|
4211
4211
|
|
|
4212
|
+
// src/nextjs/cookieConsent.ts
|
|
4213
|
+
function createCookieConsentHandler(config) {
|
|
4214
|
+
const cookieName = config?.cookieName ?? "cookie_notice_accepted";
|
|
4215
|
+
const maxAge = config?.maxAge ?? 31536e3;
|
|
4216
|
+
return async function handler(request) {
|
|
4217
|
+
if (request.method === "GET") {
|
|
4218
|
+
const consent = parseCookieConsent(request, cookieName);
|
|
4219
|
+
return Response.json(consent ?? null);
|
|
4220
|
+
}
|
|
4221
|
+
if (request.method === "POST") {
|
|
4222
|
+
const body = await request.json();
|
|
4223
|
+
const categories = {
|
|
4224
|
+
necessary: true,
|
|
4225
|
+
analytics: body.analytics ?? false,
|
|
4226
|
+
marketing: body.marketing ?? false
|
|
4227
|
+
};
|
|
4228
|
+
return new Response(JSON.stringify(categories), {
|
|
4229
|
+
status: 200,
|
|
4230
|
+
headers: {
|
|
4231
|
+
"Content-Type": "application/json",
|
|
4232
|
+
"Set-Cookie": buildConsentCookie(cookieName, encodeURIComponent(JSON.stringify(categories)), maxAge)
|
|
4233
|
+
}
|
|
4234
|
+
});
|
|
4235
|
+
}
|
|
4236
|
+
if (request.method === "DELETE") {
|
|
4237
|
+
return new Response(null, {
|
|
4238
|
+
status: 204,
|
|
4239
|
+
headers: {
|
|
4240
|
+
"Set-Cookie": `${cookieName}=; Max-Age=0; Path=/; SameSite=Lax`
|
|
4241
|
+
}
|
|
4242
|
+
});
|
|
4243
|
+
}
|
|
4244
|
+
return Response.json({ error: "Method Not Allowed" }, { status: 405 });
|
|
4245
|
+
};
|
|
4246
|
+
}
|
|
4247
|
+
function parseCookieConsent(request, cookieName = "cookie_notice_accepted") {
|
|
4248
|
+
const header = request.headers.get("cookie") ?? "";
|
|
4249
|
+
const match = header.match(new RegExp(`(?:^|;\\s*)${cookieName}=([^;]*)`));
|
|
4250
|
+
if (!match) return null;
|
|
4251
|
+
if (match[1] === "1") return { necessary: true, analytics: true, marketing: true };
|
|
4252
|
+
try {
|
|
4253
|
+
const parsed = JSON.parse(decodeURIComponent(match[1]));
|
|
4254
|
+
if (typeof parsed !== "object" || parsed === null) return null;
|
|
4255
|
+
return { necessary: true, analytics: parsed.analytics ?? false, marketing: parsed.marketing ?? false };
|
|
4256
|
+
} catch {
|
|
4257
|
+
return null;
|
|
4258
|
+
}
|
|
4259
|
+
}
|
|
4260
|
+
function buildConsentCookie(name, value, maxAge) {
|
|
4261
|
+
const secure = process.env.NODE_ENV === "production" ? "; Secure" : "";
|
|
4262
|
+
return `${name}=${value}; Path=/; SameSite=Lax; Max-Age=${maxAge}${secure}`;
|
|
4263
|
+
}
|
|
4264
|
+
|
|
4212
4265
|
// src/auth/applicationPassword.ts
|
|
4213
4266
|
function createApplicationPasswordToken(username, appPassword) {
|
|
4214
4267
|
const encoded = Buffer.from(`${username}:${appPassword}`).toString("base64");
|
|
@@ -4276,6 +4329,7 @@ exports.createCF7Queries = createCF7Queries;
|
|
|
4276
4329
|
exports.createCPTQueries = createCPTQueries;
|
|
4277
4330
|
exports.createCategoriesMutations = createCategoriesMutations;
|
|
4278
4331
|
exports.createCommentsMutations = createCommentsMutations;
|
|
4332
|
+
exports.createCookieConsentHandler = createCookieConsentHandler;
|
|
4279
4333
|
exports.createFaustAuthHandler = createFaustAuthHandler;
|
|
4280
4334
|
exports.createMediaMutations = createMediaMutations;
|
|
4281
4335
|
exports.createMenusMutations = createMenusMutations;
|
|
@@ -4299,6 +4353,7 @@ exports.createYoastQueries = createYoastQueries;
|
|
|
4299
4353
|
exports.defaultMessages = defaultMessages;
|
|
4300
4354
|
exports.defaultMessagesPl = defaultMessagesPl;
|
|
4301
4355
|
exports.extractOmnibusData = extractOmnibusData;
|
|
4356
|
+
exports.parseCookieConsent = parseCookieConsent;
|
|
4302
4357
|
exports.resolveBaseUrl = resolveBaseUrl;
|
|
4303
4358
|
exports.resolveMessage = resolveMessage;
|
|
4304
4359
|
exports.validateJwtToken = validateJwtToken;
|