@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.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { N as NextWordpressConfig, J as JwtAuthCredentials, q as JwtAuthResponse, a as WooCommerceConfig, d as WooCommerceResponse, W as WordPressResponse, T as Taxonomy, r as WPEntity, R as RenderedTitle, s as RenderedContent, P as Post, A as Author, F as FeaturedMedia, t as WCImage, u as WCProductVariation, b as WCProduct, g as WCCustomer, v as WCAddress, U as UpdateCustomerInput, e as WCCreateOrderInput, f as WCOrder, c as WCProductFilterParams, k as WPULikeStatsParams, l as WPULikeStats, o as WPULikeCheckParams, p as WPULikeCheckResponse, w as WPULikeVoteParams, n as WPULikeVoteResponse, h as WPGraphQLConfig, j as GQLConnection, i as GQLPostFilter, G as GQLPost } from './types-
|
|
2
|
-
export { x as AuthenticationError, B as BlockType, E as EditorBlock,
|
|
1
|
+
import { N as NextWordpressConfig, J as JwtAuthCredentials, q as JwtAuthResponse, a as WooCommerceConfig, d as WooCommerceResponse, W as WordPressResponse, T as Taxonomy, r as WPEntity, R as RenderedTitle, s as RenderedContent, P as Post, A as Author, F as FeaturedMedia, t as WCImage, u as WCProductVariation, b as WCProduct, g as WCCustomer, v as WCAddress, U as UpdateCustomerInput, e as WCCreateOrderInput, f as WCOrder, c as WCProductFilterParams, k as WPULikeStatsParams, l as WPULikeStats, o as WPULikeCheckParams, p as WPULikeCheckResponse, w as WPULikeVoteParams, n as WPULikeVoteResponse, h as WPGraphQLConfig, j as GQLConnection, i as GQLPostFilter, G as GQLPost } from './types-BELSHjQr.cjs';
|
|
2
|
+
export { x as AuthenticationError, B as BlockType, C as CookieConsentCategories, y as CookieConsentConfig, E as EditorBlock, z as EmbeddedAuthor, D as EmbeddedTerm, H as ErrorCode, I as GQLError, K as GQLPageInfo, M as MediaDetails, L as MediaSize, O as PostEmbedded, S as SearchResult, Q as TemplatePart, V as WCDimensions, X as WCOrderLineItem, Y as WCProductAttribute, Z as WCProductDefaultAttribute, _ as WCShippingLine, $ as WPGraphQLError, a0 as WPULikeItemType, m as WPULikeStatus, a1 as WooCommerceError, a2 as WooCommercePaginationHeaders, a3 as WordPressAPIError, a4 as createCookieConsentHandler, a5 as defaultMessages, a6 as defaultMessagesPl, a7 as parseCookieConsent, a8 as resolveMessage } from './types-BELSHjQr.cjs';
|
|
3
3
|
|
|
4
4
|
declare function createApplicationPasswordToken(username: string, appPassword: string): string;
|
|
5
5
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { N as NextWordpressConfig, J as JwtAuthCredentials, q as JwtAuthResponse, a as WooCommerceConfig, d as WooCommerceResponse, W as WordPressResponse, T as Taxonomy, r as WPEntity, R as RenderedTitle, s as RenderedContent, P as Post, A as Author, F as FeaturedMedia, t as WCImage, u as WCProductVariation, b as WCProduct, g as WCCustomer, v as WCAddress, U as UpdateCustomerInput, e as WCCreateOrderInput, f as WCOrder, c as WCProductFilterParams, k as WPULikeStatsParams, l as WPULikeStats, o as WPULikeCheckParams, p as WPULikeCheckResponse, w as WPULikeVoteParams, n as WPULikeVoteResponse, h as WPGraphQLConfig, j as GQLConnection, i as GQLPostFilter, G as GQLPost } from './types-
|
|
2
|
-
export { x as AuthenticationError, B as BlockType, E as EditorBlock,
|
|
1
|
+
import { N as NextWordpressConfig, J as JwtAuthCredentials, q as JwtAuthResponse, a as WooCommerceConfig, d as WooCommerceResponse, W as WordPressResponse, T as Taxonomy, r as WPEntity, R as RenderedTitle, s as RenderedContent, P as Post, A as Author, F as FeaturedMedia, t as WCImage, u as WCProductVariation, b as WCProduct, g as WCCustomer, v as WCAddress, U as UpdateCustomerInput, e as WCCreateOrderInput, f as WCOrder, c as WCProductFilterParams, k as WPULikeStatsParams, l as WPULikeStats, o as WPULikeCheckParams, p as WPULikeCheckResponse, w as WPULikeVoteParams, n as WPULikeVoteResponse, h as WPGraphQLConfig, j as GQLConnection, i as GQLPostFilter, G as GQLPost } from './types-BELSHjQr.js';
|
|
2
|
+
export { x as AuthenticationError, B as BlockType, C as CookieConsentCategories, y as CookieConsentConfig, E as EditorBlock, z as EmbeddedAuthor, D as EmbeddedTerm, H as ErrorCode, I as GQLError, K as GQLPageInfo, M as MediaDetails, L as MediaSize, O as PostEmbedded, S as SearchResult, Q as TemplatePart, V as WCDimensions, X as WCOrderLineItem, Y as WCProductAttribute, Z as WCProductDefaultAttribute, _ as WCShippingLine, $ as WPGraphQLError, a0 as WPULikeItemType, m as WPULikeStatus, a1 as WooCommerceError, a2 as WooCommercePaginationHeaders, a3 as WordPressAPIError, a4 as createCookieConsentHandler, a5 as defaultMessages, a6 as defaultMessagesPl, a7 as parseCookieConsent, a8 as resolveMessage } from './types-BELSHjQr.js';
|
|
3
3
|
|
|
4
4
|
declare function createApplicationPasswordToken(username: string, appPassword: string): string;
|
|
5
5
|
|
package/dist/index.js
CHANGED
|
@@ -4207,6 +4207,59 @@ async function resolvePreviewSlug(config, postId, previewPathname) {
|
|
|
4207
4207
|
return data.slug ?? `preview-${postId}`;
|
|
4208
4208
|
}
|
|
4209
4209
|
|
|
4210
|
+
// src/nextjs/cookieConsent.ts
|
|
4211
|
+
function createCookieConsentHandler(config) {
|
|
4212
|
+
const cookieName = config?.cookieName ?? "cookie_notice_accepted";
|
|
4213
|
+
const maxAge = config?.maxAge ?? 31536e3;
|
|
4214
|
+
return async function handler(request) {
|
|
4215
|
+
if (request.method === "GET") {
|
|
4216
|
+
const consent = parseCookieConsent(request, cookieName);
|
|
4217
|
+
return Response.json(consent ?? null);
|
|
4218
|
+
}
|
|
4219
|
+
if (request.method === "POST") {
|
|
4220
|
+
const body = await request.json();
|
|
4221
|
+
const categories = {
|
|
4222
|
+
necessary: true,
|
|
4223
|
+
analytics: body.analytics ?? false,
|
|
4224
|
+
marketing: body.marketing ?? false
|
|
4225
|
+
};
|
|
4226
|
+
return new Response(JSON.stringify(categories), {
|
|
4227
|
+
status: 200,
|
|
4228
|
+
headers: {
|
|
4229
|
+
"Content-Type": "application/json",
|
|
4230
|
+
"Set-Cookie": buildConsentCookie(cookieName, encodeURIComponent(JSON.stringify(categories)), maxAge)
|
|
4231
|
+
}
|
|
4232
|
+
});
|
|
4233
|
+
}
|
|
4234
|
+
if (request.method === "DELETE") {
|
|
4235
|
+
return new Response(null, {
|
|
4236
|
+
status: 204,
|
|
4237
|
+
headers: {
|
|
4238
|
+
"Set-Cookie": `${cookieName}=; Max-Age=0; Path=/; SameSite=Lax`
|
|
4239
|
+
}
|
|
4240
|
+
});
|
|
4241
|
+
}
|
|
4242
|
+
return Response.json({ error: "Method Not Allowed" }, { status: 405 });
|
|
4243
|
+
};
|
|
4244
|
+
}
|
|
4245
|
+
function parseCookieConsent(request, cookieName = "cookie_notice_accepted") {
|
|
4246
|
+
const header = request.headers.get("cookie") ?? "";
|
|
4247
|
+
const match = header.match(new RegExp(`(?:^|;\\s*)${cookieName}=([^;]*)`));
|
|
4248
|
+
if (!match) return null;
|
|
4249
|
+
if (match[1] === "1") return { necessary: true, analytics: true, marketing: true };
|
|
4250
|
+
try {
|
|
4251
|
+
const parsed = JSON.parse(decodeURIComponent(match[1]));
|
|
4252
|
+
if (typeof parsed !== "object" || parsed === null) return null;
|
|
4253
|
+
return { necessary: true, analytics: parsed.analytics ?? false, marketing: parsed.marketing ?? false };
|
|
4254
|
+
} catch {
|
|
4255
|
+
return null;
|
|
4256
|
+
}
|
|
4257
|
+
}
|
|
4258
|
+
function buildConsentCookie(name, value, maxAge) {
|
|
4259
|
+
const secure = process.env.NODE_ENV === "production" ? "; Secure" : "";
|
|
4260
|
+
return `${name}=${value}; Path=/; SameSite=Lax; Max-Age=${maxAge}${secure}`;
|
|
4261
|
+
}
|
|
4262
|
+
|
|
4210
4263
|
// src/auth/applicationPassword.ts
|
|
4211
4264
|
function createApplicationPasswordToken(username, appPassword) {
|
|
4212
4265
|
const encoded = Buffer.from(`${username}:${appPassword}`).toString("base64");
|
|
@@ -4258,6 +4311,6 @@ async function validateJwtToken(config, token) {
|
|
|
4258
4311
|
return response.ok;
|
|
4259
4312
|
}
|
|
4260
4313
|
|
|
4261
|
-
export { AuthenticationError, ErrorCode, WPGraphQLError, WooCommerceError, WordPressAPIError, authenticateJwt, buildACFFragment, buildPageWithACFQuery, buildPostWithACFQuery, buildPostsWithACFQuery, createApplicationPasswordToken, createAuthorsMutations, createCF7Queries, createCPTQueries, createCategoriesMutations, createCommentsMutations, createFaustAuthHandler, createMediaMutations, createMenusMutations, createPagesMutations, createPostsMutations, createPreviewHandler, createRevalidationHandler, createTagsMutations, createWPGraphQLCoreClient as createWPGraphQLClient, createWPGraphQLCoreClient, createWPGraphQLFetcher, createWPGraphQLMutationsClient, createWPGraphQLWooCommerceClient, createWPULikeClient, createWPULikeQueries, createWooCommerceClient, createWooCommerceFetcher, createWordPressClient, createWordPressMutationsClient, createYoastQueries, defaultMessages, defaultMessagesPl, extractOmnibusData, resolveBaseUrl, resolveMessage, validateJwtToken, withOmnibus, withOmnibusVariation };
|
|
4314
|
+
export { AuthenticationError, ErrorCode, WPGraphQLError, WooCommerceError, WordPressAPIError, authenticateJwt, buildACFFragment, buildPageWithACFQuery, buildPostWithACFQuery, buildPostsWithACFQuery, createApplicationPasswordToken, createAuthorsMutations, createCF7Queries, createCPTQueries, createCategoriesMutations, createCommentsMutations, createCookieConsentHandler, createFaustAuthHandler, createMediaMutations, createMenusMutations, createPagesMutations, createPostsMutations, createPreviewHandler, createRevalidationHandler, createTagsMutations, createWPGraphQLCoreClient as createWPGraphQLClient, createWPGraphQLCoreClient, createWPGraphQLFetcher, createWPGraphQLMutationsClient, createWPGraphQLWooCommerceClient, createWPULikeClient, createWPULikeQueries, createWooCommerceClient, createWooCommerceFetcher, createWordPressClient, createWordPressMutationsClient, createYoastQueries, defaultMessages, defaultMessagesPl, extractOmnibusData, parseCookieConsent, resolveBaseUrl, resolveMessage, validateJwtToken, withOmnibus, withOmnibusVariation };
|
|
4262
4315
|
//# sourceMappingURL=index.js.map
|
|
4263
4316
|
//# sourceMappingURL=index.js.map
|