@tokenoftrust/storefront-runner 7.9.11 → 7.10.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/apps/storefront/src/components/content/storefront/Seo.astro +3 -1
- package/apps/storefront/src/lib/content/seo/meta.ts +28 -0
- package/apps/storefront/src/lib/content/shared/rawMarketingHtml.ts +10 -0
- package/apps/storefront/src/pages/[...slug].astro +2 -1
- package/apps/storefront/src/pages/api/compliance/preflight.ts +18 -4
- package/apps/storefront/src/pages/index.astro +1 -0
- package/package.json +1 -1
- package/packages/cli/src/declared-config.mjs +27 -1
- package/packages/public-runtime/src/checkout-orders.ts +2 -0
- package/packages/public-runtime/src/declared-tenant-config.mjs +27 -1
- package/packages/public-runtime/src/tenant.ts +10 -0
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* <Seo> — per-page title/meta, Open Graph, Twitter card, canonical, JSON-LD.
|
|
4
4
|
* (brief §8). Tenant-aware: OG image + site name come from the resolved tenant.
|
|
5
5
|
*/
|
|
6
|
-
import { articleSeoMetaTags, resolveOgImage, type ArticleMeta } from "@/lib/content/seo/meta.js";
|
|
6
|
+
import { articleSeoMetaTags, resolveOgImage, siteVerificationMetaTags, type ArticleMeta } from "@/lib/content/seo/meta.js";
|
|
7
7
|
import { withXDefault, type Alternate } from "@/lib/content/seo/alternates.js";
|
|
8
8
|
import { safeJsonScriptContent } from "@/lib/content/shared/jsonScript";
|
|
9
9
|
import { documentTitle } from "@/lib/content/seo/documentTitle";
|
|
@@ -90,6 +90,7 @@ const articleMeta = articleSeoMetaTags({
|
|
|
90
90
|
twitterCreator,
|
|
91
91
|
});
|
|
92
92
|
|
|
93
|
+
const siteVerification = siteVerificationMetaTags(tenant.seo?.siteVerification);
|
|
93
94
|
const graphs = jsonLd ? (Array.isArray(jsonLd) ? jsonLd : [jsonLd]) : [];
|
|
94
95
|
const alternateLinks = withXDefault(alternates);
|
|
95
96
|
const paginationLinks = [
|
|
@@ -102,6 +103,7 @@ const paginationLinks = [
|
|
|
102
103
|
{description && <meta name="description" content={description} />}
|
|
103
104
|
<link rel="canonical" href={canonical} />
|
|
104
105
|
{noindex && <meta name="robots" content="noindex,nofollow" />}
|
|
106
|
+
{siteVerification.map((t) => <meta name={t.name} content={t.content} />)}
|
|
105
107
|
|
|
106
108
|
{
|
|
107
109
|
paginationLinks.map((l) => <link rel={l.rel} href={l.href} />)
|
|
@@ -34,6 +34,34 @@ export interface ArticleSeoInput {
|
|
|
34
34
|
twitterCreator?: string;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
/** The tenant's declared `seo.siteVerification` (tenant.ts `SeoDeclaration`). */
|
|
38
|
+
export interface SiteVerificationDeclaration {
|
|
39
|
+
google?: string | string[];
|
|
40
|
+
bing?: string | string[];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const SITE_VERIFICATION_META_NAMES = [
|
|
44
|
+
["google", "google-site-verification"],
|
|
45
|
+
["bing", "msvalidate.01"],
|
|
46
|
+
] as const;
|
|
47
|
+
|
|
48
|
+
/** A verification token is a bare token; anything else (markup, quotes) is dropped, never escaped into a page. */
|
|
49
|
+
const SITE_VERIFICATION_TOKEN = /^[A-Za-z0-9._-]{1,200}$/;
|
|
50
|
+
|
|
51
|
+
/** One `<meta name content>` per declared, well-formed token, Google first then Bing. */
|
|
52
|
+
export function siteVerificationMetaTags(declared: SiteVerificationDeclaration | undefined): MetaTag[] {
|
|
53
|
+
if (!declared || typeof declared !== "object") return [];
|
|
54
|
+
const tags: MetaTag[] = [];
|
|
55
|
+
for (const [key, name] of SITE_VERIFICATION_META_NAMES) {
|
|
56
|
+
const value = declared[key];
|
|
57
|
+
const tokens = Array.isArray(value) ? value : value === undefined ? [] : [value];
|
|
58
|
+
for (const token of new Set(tokens)) {
|
|
59
|
+
if (typeof token === "string" && SITE_VERIFICATION_TOKEN.test(token)) tags.push({ name, content: token });
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return tags;
|
|
63
|
+
}
|
|
64
|
+
|
|
37
65
|
/**
|
|
38
66
|
* The og:image/twitter:image URL, or `null` when neither the page nor the
|
|
39
67
|
* tenant's theme declares one. Never falls back to a platform placeholder --
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
type ConsentSnapshot,
|
|
26
26
|
} from "@tot/public-runtime";
|
|
27
27
|
import { reportTrackingChainHealth } from "../../measurement/tracking/interactionHealth.js";
|
|
28
|
+
import { siteVerificationMetaTags, type SiteVerificationDeclaration } from "../seo/meta.js";
|
|
28
29
|
import { ASYNC_CSS_SWAP_JS } from "./asyncCss.js";
|
|
29
30
|
import { ROOT_SERVED_HREF_NAMESPACES, withBase } from "../../publication/shared/basePath.js";
|
|
30
31
|
|
|
@@ -425,6 +426,11 @@ export function rawHtmlResponse(
|
|
|
425
426
|
* popup off serves none on this path either. Omitted keeps the document's own.
|
|
426
427
|
*/
|
|
427
428
|
arrivalPopup?: boolean;
|
|
429
|
+
/**
|
|
430
|
+
* The tenant's declared `seo.siteVerification`: its meta tags are added to the head, matching
|
|
431
|
+
* <Seo>. A tag the document already carries is not repeated.
|
|
432
|
+
*/
|
|
433
|
+
siteVerification?: SiteVerificationDeclaration;
|
|
428
434
|
},
|
|
429
435
|
): Response {
|
|
430
436
|
let composed =
|
|
@@ -470,6 +476,10 @@ export function rawHtmlResponse(
|
|
|
470
476
|
composed = nonceInlineTags(composed, opts.nonce);
|
|
471
477
|
const phases = renderIntegrationPhases(opts.plan, opts.nonce, opts.consentSnapshot);
|
|
472
478
|
composed = injectHeadStart(composed, phases.head);
|
|
479
|
+
const verification = siteVerificationMetaTags(opts.siteVerification)
|
|
480
|
+
.map((t) => `<meta name="${t.name}" content="${t.content}">`)
|
|
481
|
+
.join("");
|
|
482
|
+
if (verification) composed = injectHeadStart(composed, verification);
|
|
473
483
|
composed = injectBodyStart(composed, phases.bodyStart);
|
|
474
484
|
if (opts.complianceTop) composed = injectBodyStart(composed, opts.complianceTop);
|
|
475
485
|
composed = injectBodyEnd(composed, phases.bodyDeferred);
|
|
@@ -114,10 +114,11 @@ if (!blogPostProps) {
|
|
|
114
114
|
complianceTop: complianceChrome.top || undefined,
|
|
115
115
|
complianceBottom: complianceChrome.bottom || undefined,
|
|
116
116
|
arrivalPopup: arrivalPopupEnabled(tenant),
|
|
117
|
+
siteVerification: tenant.seo?.siteVerification,
|
|
117
118
|
});
|
|
118
119
|
}
|
|
119
120
|
|
|
120
|
-
page =
|
|
121
|
+
page =await content.getPage(slug);
|
|
121
122
|
if (!page) return new Response(null, { status: 404 });
|
|
122
123
|
}
|
|
123
124
|
|
|
@@ -467,7 +467,7 @@ export async function evaluatePreflight(
|
|
|
467
467
|
!destination &&
|
|
468
468
|
!!ruleset &&
|
|
469
469
|
isSandboxVerificationProvider(ruleset.verification.provider);
|
|
470
|
-
const base = preAddress ? withoutDestinationRequired(decision) : decision;
|
|
470
|
+
const base = preAddress ? withoutDestinationRequired(decision, lines) : decision;
|
|
471
471
|
const applied = rulesOff ? verificationOnly(base) : base;
|
|
472
472
|
if (
|
|
473
473
|
!liveVerification &&
|
|
@@ -487,12 +487,26 @@ export async function evaluatePreflight(
|
|
|
487
487
|
}
|
|
488
488
|
|
|
489
489
|
/** The decision without its `destination_required` block, status recomputed; every other block stays. */
|
|
490
|
-
function withoutDestinationRequired(decision: CartComplianceDecision): CartComplianceDecision {
|
|
491
|
-
const
|
|
492
|
-
if (
|
|
490
|
+
function withoutDestinationRequired(decision: CartComplianceDecision, lines: CartComplianceLine[]): CartComplianceDecision {
|
|
491
|
+
const kept = decision.blocks.filter((block) => block.code !== "destination_required");
|
|
492
|
+
if (kept.length === decision.blocks.length) return decision;
|
|
493
|
+
// A line whose declared allowed-states list is empty ships nowhere: that refusal does not
|
|
494
|
+
// depend on a destination, so deferring the state rules keeps it.
|
|
495
|
+
const nationwide = lines
|
|
496
|
+
.filter((line) => line.profile.allowedRegions != null && line.profile.allowedRegions.length === 0)
|
|
497
|
+
.map((line): CartComplianceDecision["blocks"][number] => ({
|
|
498
|
+
code: "region_prohibited",
|
|
499
|
+
sku: line.sku,
|
|
500
|
+
rule: "compliance.allowed_states",
|
|
501
|
+
allowedRegions: [],
|
|
502
|
+
failedClosed: true,
|
|
503
|
+
message: `${line.title ?? line.sku} can't be shipped anywhere: its allowed-states list names no valid state (safe default = BLOCK).`,
|
|
504
|
+
}));
|
|
505
|
+
const blocks = [...kept, ...nationwide];
|
|
493
506
|
return {
|
|
494
507
|
...decision,
|
|
495
508
|
blocks,
|
|
509
|
+
requirements: { ...decision.requirements, destination: "not_required" },
|
|
496
510
|
failedClosed: blocks.some((block) => block.failedClosed === true),
|
|
497
511
|
status: blocks.some((block) => block.code !== "verification_required") ? "blocked" : blocks.length ? "action_required" : "clear",
|
|
498
512
|
};
|
|
@@ -100,6 +100,7 @@ if (rawHtml && rawPolicy.allowed) {
|
|
|
100
100
|
complianceTop: complianceChrome.top || undefined,
|
|
101
101
|
complianceBottom: complianceChrome.bottom || undefined,
|
|
102
102
|
arrivalPopup: arrivalPopupEnabled(tenant),
|
|
103
|
+
siteVerification: tenant.seo?.siteVerification,
|
|
103
104
|
});
|
|
104
105
|
}
|
|
105
106
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokenoftrust/storefront-runner",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.10.0",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"description": "World-shareable storefront runner: multi-tenant renderer on Astro/Cloudflare. No control plane.",
|
|
6
6
|
"packageManager": "pnpm@11.9.0",
|
|
@@ -142,7 +142,7 @@ export function resolveStoreTimeZone(declared) {
|
|
|
142
142
|
|
|
143
143
|
|
|
144
144
|
/** Every `seo` key (mirrors packages/public-runtime/src/declared-tenant-config.mjs). */
|
|
145
|
-
export const SEO_KEYS = Object.freeze(["trailingSlash", "verbatimSeoTitles", "structuredData"]);
|
|
145
|
+
export const SEO_KEYS = Object.freeze(["trailingSlash", "verbatimSeoTitles", "structuredData", "siteVerification"]);
|
|
146
146
|
|
|
147
147
|
/** Every `seo.structuredData` key. */
|
|
148
148
|
export const STRUCTURED_DATA_KEYS = Object.freeze(["graphs", "names", "reviews", "onlyOn"]);
|
|
@@ -179,6 +179,31 @@ export const STRUCTURED_DATA_NAME_SOURCES = Object.freeze(["documentTitle", "tit
|
|
|
179
179
|
const isPlainObject = (value) =>
|
|
180
180
|
value !== null && typeof value === "object" && !Array.isArray(value);
|
|
181
181
|
|
|
182
|
+
/** Search-engine site-verification tokens: `seo.siteVerification` keys. */
|
|
183
|
+
export const SITE_VERIFICATION_KEYS = Object.freeze(["google", "bing"]);
|
|
184
|
+
/** A verification token is a bare token, never markup: letters, digits, `_`, `-`, `.`. */
|
|
185
|
+
export const SITE_VERIFICATION_TOKEN = /^[A-Za-z0-9._-]{1,200}$/;
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* @param {unknown} value
|
|
189
|
+
* @returns {string[]}
|
|
190
|
+
*/
|
|
191
|
+
function siteVerificationProblems(value) {
|
|
192
|
+
if (!isPlainObject(value)) return ["`seo.siteVerification` must be an object"];
|
|
193
|
+
const problems = [];
|
|
194
|
+
for (const [key, tokens] of Object.entries(/** @type {Record<string, unknown>} */ (value))) {
|
|
195
|
+
if (!SITE_VERIFICATION_KEYS.includes(key)) {
|
|
196
|
+
problems.push(`\`seo.siteVerification.${key}\` is not a search engine (${SITE_VERIFICATION_KEYS.join(", ")})`);
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
const list = Array.isArray(tokens) ? tokens : [tokens];
|
|
200
|
+
if (list.length === 0 || !list.every((t) => typeof t === "string" && SITE_VERIFICATION_TOKEN.test(t))) {
|
|
201
|
+
problems.push(`\`seo.siteVerification.${key}\` must be a verification token (or a list of them): letters, digits, "_", "-", "."; paste the content value, not the whole tag`);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return problems;
|
|
205
|
+
}
|
|
206
|
+
|
|
182
207
|
/**
|
|
183
208
|
* What is wrong with a declared `seo` value, one sentence per problem; `[]` when it is valid.
|
|
184
209
|
* A profile that names a node or page type the renderer does not build is refused whole: a
|
|
@@ -200,6 +225,7 @@ export function seoDeclarationProblems(seo) {
|
|
|
200
225
|
if (source.verbatimSeoTitles !== undefined && typeof source.verbatimSeoTitles !== "boolean") {
|
|
201
226
|
problems.push("`seo.verbatimSeoTitles` must be true or false");
|
|
202
227
|
}
|
|
228
|
+
if (source.siteVerification !== undefined) problems.push(...siteVerificationProblems(source.siteVerification));
|
|
203
229
|
const sd = source.structuredData;
|
|
204
230
|
if (sd === undefined) return problems;
|
|
205
231
|
if (!isPlainObject(sd)) return [...problems, "`seo.structuredData` must be an object"];
|
|
@@ -142,6 +142,8 @@ export interface CheckoutOrderListFilters {
|
|
|
142
142
|
status?: string;
|
|
143
143
|
/** Optional redeemed coupon code filter (case-insensitive). */
|
|
144
144
|
coupon?: string;
|
|
145
|
+
/** Free-text search over the whole book before paging (case-insensitive): order id, SKU, product name, coupon, status. */
|
|
146
|
+
q?: string;
|
|
145
147
|
/** ISO datetime lower bound. */
|
|
146
148
|
from?: string;
|
|
147
149
|
/** ISO datetime upper bound. */
|
|
@@ -83,7 +83,7 @@ export const FEATURE_KEYS = Object.freeze([
|
|
|
83
83
|
export const SITE_TYPES_LIST = Object.freeze(["commerce", "marketing"]);
|
|
84
84
|
|
|
85
85
|
/** Every `seo` key (SeoDeclaration, tenant.ts). */
|
|
86
|
-
export const SEO_KEYS = Object.freeze(["trailingSlash", "verbatimSeoTitles", "structuredData"]);
|
|
86
|
+
export const SEO_KEYS = Object.freeze(["trailingSlash", "verbatimSeoTitles", "structuredData", "siteVerification"]);
|
|
87
87
|
|
|
88
88
|
/** Every `seo.structuredData` key. */
|
|
89
89
|
export const STRUCTURED_DATA_KEYS = Object.freeze(["graphs", "names", "reviews", "onlyOn"]);
|
|
@@ -195,6 +195,31 @@ const SITE_TYPES = new Set(SITE_TYPES_LIST);
|
|
|
195
195
|
const isPlainObject = (value) =>
|
|
196
196
|
value !== null && typeof value === "object" && !Array.isArray(value);
|
|
197
197
|
|
|
198
|
+
/** Search-engine site-verification tokens: `seo.siteVerification` keys. */
|
|
199
|
+
export const SITE_VERIFICATION_KEYS = Object.freeze(["google", "bing"]);
|
|
200
|
+
/** A verification token is a bare token, never markup: letters, digits, `_`, `-`, `.`. */
|
|
201
|
+
export const SITE_VERIFICATION_TOKEN = /^[A-Za-z0-9._-]{1,200}$/;
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* @param {unknown} value
|
|
205
|
+
* @returns {string[]}
|
|
206
|
+
*/
|
|
207
|
+
function siteVerificationProblems(value) {
|
|
208
|
+
if (!isPlainObject(value)) return ["`seo.siteVerification` must be an object"];
|
|
209
|
+
const problems = [];
|
|
210
|
+
for (const [key, tokens] of Object.entries(/** @type {Record<string, unknown>} */ (value))) {
|
|
211
|
+
if (!SITE_VERIFICATION_KEYS.includes(key)) {
|
|
212
|
+
problems.push(`\`seo.siteVerification.${key}\` is not a search engine (${SITE_VERIFICATION_KEYS.join(", ")})`);
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
const list = Array.isArray(tokens) ? tokens : [tokens];
|
|
216
|
+
if (list.length === 0 || !list.every((t) => typeof t === "string" && SITE_VERIFICATION_TOKEN.test(t))) {
|
|
217
|
+
problems.push(`\`seo.siteVerification.${key}\` must be a verification token (or a list of them): letters, digits, "_", "-", "."; paste the content value, not the whole tag`);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return problems;
|
|
221
|
+
}
|
|
222
|
+
|
|
198
223
|
/**
|
|
199
224
|
* What is wrong with a declared `seo` value, one sentence per problem; `[]` when it is valid.
|
|
200
225
|
* A profile that names a node or page type the renderer does not build is refused whole: a
|
|
@@ -216,6 +241,7 @@ export function seoDeclarationProblems(seo) {
|
|
|
216
241
|
if (source.verbatimSeoTitles !== undefined && typeof source.verbatimSeoTitles !== "boolean") {
|
|
217
242
|
problems.push("`seo.verbatimSeoTitles` must be true or false");
|
|
218
243
|
}
|
|
244
|
+
if (source.siteVerification !== undefined) problems.push(...siteVerificationProblems(source.siteVerification));
|
|
219
245
|
const sd = source.structuredData;
|
|
220
246
|
if (sd === undefined) return problems;
|
|
221
247
|
if (!isPlainObject(sd)) return [...problems, "`seo.structuredData` must be an object"];
|
|
@@ -879,6 +879,16 @@ export interface SeoDeclaration {
|
|
|
879
879
|
* suffixed with the store name unless it already names the store.
|
|
880
880
|
*/
|
|
881
881
|
verbatimSeoTitles?: boolean;
|
|
882
|
+
/**
|
|
883
|
+
* Search-engine site-verification tokens (the `content` value of the engine's meta tag, never the
|
|
884
|
+
* whole tag). Rendered on every page as `<meta name="google-site-verification">` and
|
|
885
|
+
* `<meta name="msvalidate.01">`. A list verifies several properties. A root verification file
|
|
886
|
+
* (`public/google<token>.html`, `public/BingSiteAuth.xml`) is served at `/<filename>` as-is.
|
|
887
|
+
*/
|
|
888
|
+
siteVerification?: {
|
|
889
|
+
google?: string | string[];
|
|
890
|
+
bing?: string | string[];
|
|
891
|
+
};
|
|
882
892
|
/**
|
|
883
893
|
* The structured-data profile. When present it is the ONLY JSON-LD a declared page type
|
|
884
894
|
* emits: one `@graph` holding exactly the listed nodes, in order. A node whose data the
|