@aglyn/aglyn 1.24.0 → 1.25.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/package.json +11 -11
- package/src/lib/app-utils/activity-labels.js +4 -1
- package/src/lib/app-utils/activity-labels.js.map +1 -1
- package/src/lib/app-utils/business-details.d.ts +5 -0
- package/src/lib/app-utils/business-details.js +4 -0
- package/src/lib/app-utils/business-details.js.map +1 -1
- package/src/lib/app-utils/crm.d.ts +17 -30
- package/src/lib/app-utils/crm.js +139 -3
- package/src/lib/app-utils/crm.js.map +1 -1
- package/src/lib/app-utils/docs-help-sections.generated.js +4 -1
- package/src/lib/app-utils/docs-help-sections.generated.js.map +1 -1
- package/src/lib/app-utils/docs-help.generated.d.ts +1 -1
- package/src/lib/app-utils/docs-help.generated.js +7 -0
- package/src/lib/app-utils/docs-help.generated.js.map +1 -1
- package/src/lib/app-utils/docs-index.generated.js +28 -7
- package/src/lib/app-utils/docs-index.generated.js.map +1 -1
- package/src/lib/app-utils/host-tokens.d.ts +17 -0
- package/src/lib/app-utils/host-tokens.js +18 -0
- package/src/lib/app-utils/host-tokens.js.map +1 -1
- package/src/lib/app-utils/native-app-association.d.ts +5 -3
- package/src/lib/app-utils/native-app-association.js +5 -3
- package/src/lib/app-utils/native-app-association.js.map +1 -1
- package/src/lib/app-utils/native-nav.js +1 -1
- package/src/lib/app-utils/native-nav.js.map +1 -1
- package/src/lib/app-utils/plan-entitlements.d.ts +227 -36
- package/src/lib/app-utils/plan-entitlements.js +335 -43
- package/src/lib/app-utils/plan-entitlements.js.map +1 -1
- package/src/lib/app-utils/reusable-component-keys.d.ts +9 -0
- package/src/lib/app-utils/reusable-component-keys.js +9 -0
- package/src/lib/app-utils/reusable-component-keys.js.map +1 -1
- package/src/lib/app-utils/server.d.ts +1 -0
- package/src/lib/app-utils/server.js +1 -0
- package/src/lib/app-utils/server.js.map +1 -1
- package/src/lib/app-utils/sign-in-visibility.d.ts +78 -0
- package/src/lib/app-utils/sign-in-visibility.js +79 -0
- package/src/lib/app-utils/sign-in-visibility.js.map +1 -0
- package/src/lib/app-utils/site-live-url.d.ts +4 -1
- package/src/lib/app-utils/site-live-url.js +17 -3
- package/src/lib/app-utils/site-live-url.js.map +1 -1
- package/src/lib/app-utils/usage-level.d.ts +50 -0
- package/src/lib/app-utils/usage-level.js +94 -0
- package/src/lib/app-utils/usage-level.js.map +1 -0
- package/src/lib/foundation/definitions/org-billing.types.d.ts +24 -2
- package/src/lib/foundation/definitions/org-billing.types.js.map +1 -1
|
@@ -244,6 +244,23 @@ export declare function describeHostTokens(host: HostTokenSource | null | undefi
|
|
|
244
244
|
value?: string;
|
|
245
245
|
set: boolean;
|
|
246
246
|
}>;
|
|
247
|
+
/** One row of {@link describeHostTokens} as plain data: the definition without its resolvers. */
|
|
248
|
+
export interface HostTokenPreviewRow {
|
|
249
|
+
key: string;
|
|
250
|
+
type: HostTokenType;
|
|
251
|
+
label: string;
|
|
252
|
+
description: string;
|
|
253
|
+
whenEmpty: HostTokenEmptyBehaviour;
|
|
254
|
+
token: string;
|
|
255
|
+
value?: string;
|
|
256
|
+
set: boolean;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* {@link describeHostTokens} without the resolvers, so it can travel as data:
|
|
260
|
+
* the native apps' Business details card lists "What your pages can use"
|
|
261
|
+
* from it, and replays these answers in their tests (AGL-4136).
|
|
262
|
+
*/
|
|
263
|
+
export declare function hostTokenPreview(host: HostTokenSource | null | undefined): HostTokenPreviewRow[];
|
|
247
264
|
/**
|
|
248
265
|
* The `host.*` values as a merge-token map, for surfaces that already have a
|
|
249
266
|
* token substituter of their own.
|
|
@@ -416,6 +416,24 @@ function logo(host) {
|
|
|
416
416
|
});
|
|
417
417
|
});
|
|
418
418
|
}
|
|
419
|
+
/**
|
|
420
|
+
* {@link describeHostTokens} without the resolvers, so it can travel as data:
|
|
421
|
+
* the native apps' Business details card lists "What your pages can use"
|
|
422
|
+
* from it, and replays these answers in their tests (AGL-4136).
|
|
423
|
+
*/ export function hostTokenPreview(host) {
|
|
424
|
+
return describeHostTokens(host).map(({ key, type, label, description, whenEmpty, token, value, set })=>_extends({
|
|
425
|
+
key,
|
|
426
|
+
type,
|
|
427
|
+
label,
|
|
428
|
+
description,
|
|
429
|
+
whenEmpty,
|
|
430
|
+
token
|
|
431
|
+
}, value === undefined ? {} : {
|
|
432
|
+
value
|
|
433
|
+
}, {
|
|
434
|
+
set
|
|
435
|
+
}));
|
|
436
|
+
}
|
|
419
437
|
/**
|
|
420
438
|
* The `host.*` values as a merge-token map, for surfaces that already have a
|
|
421
439
|
* token substituter of their own.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/host-tokens.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { structuredAddressLine } from './business-profile'\nimport { siteProfileUrls, type HostSeoEntity } from './content-authors'\nimport { hostPublicOrigin } from './host-naming'\nimport { normalizeAreaServed } from './local-business'\n\n/**\n * Host variables — publisher templates that fill themselves in (AGL-1022).\n *\n * A publisher writing an email template cannot reference the installing site,\n * so every install begins with the same chore: swap the placeholder logo, fix\n * the business name, correct the links. Miss one and the site sends an email\n * carrying someone else's branding.\n *\n * `host.*` gives artifacts a way to NAME the host instead of hard-coding it.\n * The author writes `{{host.businessName}}`; the installing site fills it in,\n * and it stays filled in when that site rebrands.\n *\n * ## The namespace IS the security boundary\n *\n * This is publisher-authored content resolving against tenant data, so the\n * registry is CLOSED and each token reads through a hand-written function\n * rather than a path into the document. That is the whole design: a token\n * cannot address `stripeAccountId`, or `memberRoles`, or anything else, because\n * there is no path syntax to express it — `host.` is followed by a key that\n * either appears in {@link HOST_TOKENS} or resolves to nothing at all. Adding a\n * token is a deliberate edit here, reviewable as a diff.\n *\n * A path-based registry (\"allow `host.seo.title`\") would have been shorter and\n * is the version to refuse: allowlisting prefixes is how a namespace grows a\n * hole, and the first `host.orgId` would be a data leak with a plausible commit\n * message.\n *\n * ## Resolve LATE\n *\n * At render and at send, never at install. Freezing values into the artifact\n * would make a rebrand stop propagating silently — the site would keep sending\n * last year's business name from a template nobody remembers is a template.\n *\n * ## Every token defines what \"empty\" does\n *\n * A site with no logo must produce something deliberate. Never an empty image,\n * and never the literal `{{host.logo}}` reaching a visitor — a leaked token is\n * the most embarrassing possible failure for a feature whose entire purpose is\n * to stop templates looking unfinished.\n */\n\n/**\n * What a token yields, so a renderer knows how to place it and the authoring\n * surface can refuse it in the wrong slot.\n *\n * `text` is the only type safe to drop into arbitrary copy. The others carry a\n * shape a slot has to understand — an `image` in a paragraph is a URL sitting\n * in the middle of a sentence, which is exactly the \"fails in a sent email\"\n * outcome this typing exists to move to authoring time.\n */\nexport type HostTokenType = 'text' | 'url' | 'email' | 'image' | 'address'\n\n/** What a renderer should do when a token resolves to nothing. */\nexport type HostTokenEmptyBehaviour =\n /** Render nothing in its place; the surrounding copy still makes sense. */\n | 'blank'\n /**\n * The block holding it should be dropped entirely. An `<img src=\"\">` is a\n * broken-image icon in every mail client, which is worse than no logo.\n */\n | 'omit-block'\n\n/** The site fields a token may read. A closed, explicit surface. */\nexport interface HostTokenSource {\n displayName?: string\n logoUrl?: string\n logoDarkUrl?: string\n subdomain?: string\n cname?: string\n /**\n * The one-block copies of the email and address, and the social links\n * (AGL-1022). Setup → Business profile writes the email and address to `seo.entity`\n * and mirrors them here (AGL-4136), so these are what a token reads when\n * the entity has none: a site saved before that, or by the native apps.\n */\n business?: {\n supportEmail?: string\n address?: string\n socialLinks?: Array<{ label?: string; url?: string }>\n }\n /**\n * The business's facts as Setup → Business profile and SEO → Local business store\n * them (AGL-4136): the name, slogan, phone, email, structured address, the\n * profiles it claims and the areas it serves.\n */\n seo?: {\n entity?: Pick<\n HostSeoEntity,\n | 'name'\n | 'logo'\n | 'slogan'\n | 'email'\n | 'telephone'\n | 'address'\n | 'sameAs'\n | 'areaServed'\n >\n }\n}\n\nexport interface HostTokenDefinition {\n /** The key after `host.` */\n key: string\n type: HostTokenType\n label: string\n description: string\n /** Reads the value. Hand-written per token — never a path into the document. */\n resolve: (host: HostTokenSource) => string | undefined\n /**\n * A deliberate second choice when `resolve` finds nothing.\n *\n * Not a nicety: \"fall back to the business name\" is what turns a missing logo\n * from a hole in the page into a wordmark, which is what a careful designer\n * would have done by hand.\n */\n fallback?: (host: HostTokenSource) => string | undefined\n whenEmpty: HostTokenEmptyBehaviour\n}\n\nconst trimmed = (value: unknown): string | undefined => {\n const text = typeof value === 'string' ? value.trim() : ''\n return text || undefined\n}\n\n/**\n * The site's public URL.\n *\n * A custom domain wins when connected, because that is the address the site is\n * actually known by — a template linking to the aglyn.app subdomain of a site\n * with its own domain is technically correct and reads as a mistake.\n */\nfunction siteUrl(host: HostTokenSource): string | undefined {\n const custom = trimmed(host.cname)\n if (custom) return `https://${custom.replace(/^https?:\\/\\//, '')}`\n // `hostPublicOrigin`, not a fourth hand-rolled apex (AGL-2195). The cname\n // branch stays here because this one strips a scheme the token source may\n // carry; the subdomain branch has no such difference and had none — it was\n // the same two lines with `aglyn.app` written in, so an operator's own apex\n // was honoured everywhere except in the tokens a template renders.\n return hostPublicOrigin({ subdomain: trimmed(host.subdomain) })\n}\n\nfunction businessName(host: HostTokenSource): string | undefined {\n return trimmed(host.seo?.entity?.name) ?? trimmed(host.displayName)\n}\n\nfunction logo(host: HostTokenSource): string | undefined {\n return trimmed(host.logoUrl) ?? trimmed(host.seo?.entity?.logo)\n}\n\n/**\n * A phone number as a `tel:` link (AGL-4136): everything but its digits and\n * a leading `+` removed, so `+1 (512) 555-0100` dials `tel:+15125550100`.\n * Nothing when the number holds no digit, so a Call button never links to a\n * bare `tel:`.\n */\nexport function telephoneHref(phone: unknown): string | undefined {\n const text = trimmed(phone)\n if (!text) return undefined\n const digits = text.replace(/\\D+/g, '')\n if (!digits) return undefined\n return `tel:${text.startsWith('+') ? '+' : ''}${digits}`\n}\n\n/**\n * The social networks a page can link by name (AGL-4136), each with the\n * hostnames its profile addresses are served from. A hostname matches itself\n * and any subdomain of itself, so `www.` and `m.` addresses are the same\n * profile. X keeps `twitter.com`, because a link saved before the rename is\n * still the same account.\n */\nconst SOCIAL_NETWORK_HOSTS = {\n facebook: ['facebook.com', 'fb.com'],\n instagram: ['instagram.com'],\n x: ['x.com', 'twitter.com'],\n linkedin: ['linkedin.com'],\n youtube: ['youtube.com', 'youtu.be'],\n tiktok: ['tiktok.com'],\n} as const\n\nexport type HostSocialNetwork = keyof typeof SOCIAL_NETWORK_HOSTS\n\n/**\n * The site's profile on one network: the first of the profiles it claims\n * (`siteProfileUrls`, the entity's `sameAs` and then Setup → Business profile's\n * social links, https only) served from that network's hostname. Matched by\n * HOSTNAME rather than by the link's label, because the label is free text\n * and the address is what a visitor is sent to.\n */\nexport function siteSocialProfileUrl(\n host: HostTokenSource | null | undefined,\n network: HostSocialNetwork,\n): string | undefined {\n const hosts: readonly string[] = SOCIAL_NETWORK_HOSTS[network]\n for (const value of siteProfileUrls(host)) {\n let hostname: string\n try {\n hostname = new URL(value).hostname.toLowerCase()\n } catch {\n continue\n }\n if (hosts.some((name) => hostname === name || hostname.endsWith(`.${name}`))) {\n return value\n }\n }\n return undefined\n}\n\n/** The areas served, as SEO → Local business stores and the structured data publishes them. */\nfunction areasServed(host: HostTokenSource): string[] {\n return normalizeAreaServed(host.seo?.entity?.areaServed)\n}\n\n/** One social network's profile link as a token: a URL, dropped where the site has none. */\nfunction socialToken(\n network: HostSocialNetwork,\n key: string,\n name: string,\n): HostTokenDefinition {\n return {\n key,\n type: 'url',\n label: `${name} link`,\n description: `The address of the site’s ${name} profile, from Setup → Business profile.`,\n resolve: (host) => siteSocialProfileUrl(host, network),\n whenEmpty: 'omit-block',\n }\n}\n\n/**\n * The closed registry.\n *\n * Ordered as an author would look for them. Every entry is reachable from a\n * field a site can actually set — a token that can never resolve is worse than\n * an absent one, because it teaches people the feature does not work.\n */\nexport const HOST_TOKENS: Record<string, HostTokenDefinition> = {\n businessName: {\n key: 'businessName',\n type: 'text',\n label: 'Business name',\n description:\n 'The business name from Setup → Business profile, or the site’s name when none is set.',\n resolve: businessName,\n whenEmpty: 'blank',\n },\n slogan: {\n key: 'slogan',\n type: 'text',\n label: 'Slogan',\n description: 'A short line about the business, from Setup → Business profile.',\n resolve: (host) => trimmed(host.seo?.entity?.slogan),\n whenEmpty: 'blank',\n },\n logo: {\n key: 'logo',\n type: 'image',\n label: 'Logo',\n description: 'The site’s logo image.',\n resolve: logo,\n // No image: the block is dropped and the business name carries the brand\n // instead, which is what the block was for.\n whenEmpty: 'omit-block',\n },\n logoDark: {\n key: 'logoDark',\n type: 'image',\n label: 'Logo for dark backgrounds',\n description:\n 'The logo to show on a dark background. The site’s logo when it has no dark one.',\n // The pair a header toggles by color scheme (AGL-4119): a site with one\n // logo shows it in both schemes, and one with none shows neither.\n resolve: (host) => trimmed(host.logoDarkUrl) ?? logo(host),\n whenEmpty: 'omit-block',\n },\n url: {\n key: 'url',\n type: 'url',\n label: 'Site address',\n description: 'The site’s public URL — its custom domain when connected.',\n resolve: siteUrl,\n whenEmpty: 'blank',\n },\n phone: {\n key: 'phone',\n type: 'text',\n label: 'Phone',\n description: 'The business’s phone number, as entered on Setup → Business profile.',\n resolve: (host) => trimmed(host.seo?.entity?.telephone),\n whenEmpty: 'omit-block',\n },\n phoneLink: {\n key: 'phoneLink',\n type: 'url',\n label: 'Phone link',\n description:\n 'The phone number as a tel: link, for a Call button’s link. Dropped when the site has no phone.',\n resolve: (host) => telephoneHref(host.seo?.entity?.telephone),\n whenEmpty: 'omit-block',\n },\n /*\n The key keeps its old name, because pages and emails already say\n `{{host.supportEmail}}`. What it reads is the site's one email (AGL-4136):\n the one Setup → Business profile saves to the entity, else the one-block copy a\n site saved before that.\n */\n supportEmail: {\n key: 'supportEmail',\n type: 'email',\n label: 'Email',\n description: 'The email address visitors write to, from Setup → Business profile.',\n resolve: (host) => siteContactEmail(host) ?? undefined,\n whenEmpty: 'omit-block',\n },\n address: {\n key: 'address',\n type: 'address',\n label: 'Postal address',\n description:\n 'The business’s postal address from Setup → Business profile, as one block of text.',\n // The structured address, formatted the one way it is formatted\n // everywhere (AGL-4136), else the one-block copy as it was typed —\n // line breaks kept, because a document prints it a line per line.\n resolve: (host) =>\n trimmed(structuredAddressLine(host.seo?.entity?.address)) ??\n trimmed(host.business?.address),\n whenEmpty: 'omit-block',\n },\n mainArea: {\n key: 'mainArea',\n type: 'text',\n label: 'Main area',\n description:\n 'The first area served, by its place name: San Antonio, for “San Antonio, TX”. From SEO → Local business.',\n // The text before the first comma, so the token reads in a sentence —\n // \"across San Antonio and surrounding areas\" — and a page that already\n // says the place name can switch to it without a visible change.\n resolve: (host) => trimmed(areasServed(host)[0]?.split(',')[0]),\n whenEmpty: 'blank',\n },\n areasServed: {\n key: 'areasServed',\n type: 'text',\n label: 'Areas served',\n description:\n 'Every area served, in order, separated by commas. From SEO → Local business.',\n resolve: (host) => trimmed(areasServed(host).join(', ')),\n whenEmpty: 'blank',\n },\n socialLinks: {\n key: 'socialLinks',\n type: 'text',\n label: 'Social links',\n description: 'The site’s social profiles, as a list of labeled links.',\n // Rendered as text here so a token in copy degrades to something readable;\n // a link to one profile is that network's own token below (AGL-4136).\n resolve: (host) => {\n const links = host.business?.socialLinks ?? []\n const labels = links\n .map((link) => trimmed(link?.label) ?? trimmed(link?.url))\n .filter((label): label is string => Boolean(label))\n return labels.length ? labels.join(' · ') : undefined\n },\n whenEmpty: 'omit-block',\n },\n /*\n One link per common network (AGL-4136), so a page's social icons link\n the site's own profiles from Setup → Business profile instead of a hand-made\n variable per network.\n */\n facebookUrl: socialToken('facebook', 'facebookUrl', 'Facebook'),\n instagramUrl: socialToken('instagram', 'instagramUrl', 'Instagram'),\n xUrl: socialToken('x', 'xUrl', 'X'),\n linkedinUrl: socialToken('linkedin', 'linkedinUrl', 'LinkedIn'),\n youtubeUrl: socialToken('youtube', 'youtubeUrl', 'YouTube'),\n tiktokUrl: socialToken('tiktok', 'tiktokUrl', 'TikTok'),\n}\n\n/**\n * The registry's entry for `key`, or undefined when it declares none.\n *\n * An OWN entry only. `HOST_TOKENS` is an object literal, so a bare index also\n * finds the `Object.prototype` members — `constructor`, `toString`, `valueOf` —\n * and every one of those names matches {@link HOST_TOKEN_PATTERN}. Read that\n * way, `{{host.constructor}}` answers the `Object` function where a definition\n * belongs, and calling its `resolve` throws in the middle of a render. A name\n * the registry does not declare resolves to nothing, whatever the name is.\n */\nexport function hostTokenDefinition(\n key: string,\n): HostTokenDefinition | undefined {\n return Object.prototype.hasOwnProperty.call(HOST_TOKENS, key)\n ? HOST_TOKENS[key]\n : undefined\n}\n\n/**\n * `{{host.key}}` — whitespace-tolerant, and deliberately NOT dotted beyond one\n * segment. `host.a.b` does not match, so there is no path syntax to abuse.\n */\nexport const HOST_TOKEN_PATTERN = /\\{\\{\\s*host\\.([a-zA-Z][a-zA-Z0-9_]*)\\s*\\}\\}/g\n\n/**\n * Whether a value is exactly one image token, like `{{host.logo}}`: what a\n * picture's `src` may be when it is the installing site's own logo. It becomes\n * that site's stored value at render, so it names nothing of the publisher's.\n */\nexport function isHostImageToken(value: string): boolean {\n const keys = hostTokensIn(value)\n return (\n keys.length === 1 &&\n value.replace(HOST_TOKEN_PATTERN, '').trim() === '' &&\n hostTokenDefinition(keys[0])?.type === 'image'\n )\n}\n\n/** Every `host.*` token in a string, in order, including unknown ones. */\nexport function hostTokensIn(text: string): string[] {\n if (typeof text !== 'string' || !text.includes('{{')) return []\n const keys: string[] = []\n for (const match of text.matchAll(HOST_TOKEN_PATTERN)) keys.push(match[1])\n return keys\n}\n\n/** The resolved value of one token, or undefined when the site has none. */\nexport function resolveHostToken(\n key: string,\n host: HostTokenSource | null | undefined,\n): string | undefined {\n const definition = hostTokenDefinition(key)\n if (!definition || !host) return undefined\n return definition.resolve(host) ?? definition.fallback?.(host)\n}\n\n/**\n * Replaces every `host.*` token with the installing site's value.\n *\n * An unresolved token — unknown key, or a site that has not set the field —\n * renders EMPTY, never the literal. Leaking `{{host.logo}}` into a sent email\n * is the failure this feature exists to prevent, so it cannot be the fallback\n * for the feature's own gaps. The authoring-time check\n * ({@link validateHostTokens}) is where a typo is meant to be caught, while the\n * writer can still fix it.\n */\nexport function resolveHostTokens(\n text: string,\n host: HostTokenSource | null | undefined,\n): string {\n if (typeof text !== 'string' || !text.includes('{{')) return text\n return text.replace(HOST_TOKEN_PATTERN, (_token, key) =>\n resolveHostToken(String(key), host) ?? '',\n )\n}\n\nexport interface HostTokenIssue {\n key: string\n /**\n * `unknown` — no such token; it will render empty.\n * `wrong-slot` — the token's type cannot be placed here.\n */\n kind: 'unknown' | 'wrong-slot'\n message: string\n}\n\n/**\n * Authoring-time check: catch a token before it reaches a visitor.\n *\n * The two things worth failing on are a typo (which would silently render\n * nothing) and a type mismatch (an image URL dropped into a sentence). Both are\n * invisible at authoring time without this and obvious afterwards, which is the\n * wrong way round for something that ends up in a sent email.\n *\n * `allow` names the types this slot can take. Omit it for free text, where only\n * `text` and the string-ish types make sense.\n */\nexport function validateHostTokens(\n text: string,\n options?: { allow?: readonly HostTokenType[] },\n): HostTokenIssue[] {\n const allow = options?.allow ?? ['text', 'url', 'email', 'address']\n const issues: HostTokenIssue[] = []\n const seen = new Set<string>()\n for (const key of hostTokensIn(text)) {\n if (seen.has(key)) continue\n seen.add(key)\n const definition = hostTokenDefinition(key)\n if (!definition) {\n issues.push({\n key,\n kind: 'unknown',\n message:\n `There is no host variable called \"${key}\". It will render as ` +\n 'nothing. Available: ' +\n Object.keys(HOST_TOKENS).join(', ') +\n '.',\n })\n continue\n }\n if (!allow.includes(definition.type)) {\n issues.push({\n key,\n kind: 'wrong-slot',\n message:\n `\"${definition.label}\" is ${\n definition.type === 'image' ? 'an image' : `a ${definition.type}`\n }, so it cannot go here. Put it in a slot that takes ` +\n `${definition.type === 'image' ? 'an image' : `a ${definition.type}`}.`,\n })\n }\n }\n return issues\n}\n\n/**\n * Whether a block containing these tokens should be dropped for this site.\n *\n * The other half of \"every token needs a defined empty behaviour\": a logo block\n * on a site with no logo should not render an empty image, and the renderer\n * cannot know that from the resolved string alone — `''` is both \"no value\" and\n * \"a value that happens to be empty\". Asking here keeps the rule with the\n * token definition rather than spread across the surfaces that render it.\n */\nexport function shouldOmitBlock(\n text: string,\n host: HostTokenSource | null | undefined,\n): boolean {\n for (const key of hostTokensIn(text)) {\n const definition = hostTokenDefinition(key)\n if (!definition || definition.whenEmpty !== 'omit-block') continue\n if (!resolveHostToken(key, host)) return true\n }\n return false\n}\n\n/**\n * Every token with its resolved value for one site, for an authoring picker\n * that shows what each will actually produce here.\n *\n * A picker listing token names alone makes the author guess; showing the value\n * this site would render is what turns \"is it businessName or business_name\"\n * into a question nobody has to ask.\n */\nexport function describeHostTokens(\n host: HostTokenSource | null | undefined,\n): Array<HostTokenDefinition & { token: string; value?: string; set: boolean }> {\n return Object.values(HOST_TOKENS).map((definition) => {\n const value = resolveHostToken(definition.key, host)\n return {\n ...definition,\n token: `{{host.${definition.key}}}`,\n value,\n set: Boolean(value),\n }\n })\n}\n\n/**\n * The `host.*` values as a merge-token map, for surfaces that already have a\n * token substituter of their own.\n *\n * This is how EMAIL gets host variables without the email library depending on\n * this one: `substituteMergeTokens` already matches `{{a.b}}`, so a caller\n * spreads this into the merge map it was passing anyway. One registry, two\n * surfaces, no second substitution engine to drift.\n *\n * Every registered token appears, INCLUDING the ones this site has not set —\n * as `''`. Omitting them would leave `{{host.supportEmail}}` for the generic\n * catch-all to blank, which works today and works by accident: the moment a\n * surface without that catch-all uses this map, the literal token ships.\n */\nexport function hostTokenMerge(\n host: HostTokenSource | null | undefined,\n): Record<string, string> {\n const merge: Record<string, string> = {}\n for (const key of Object.keys(HOST_TOKENS)) {\n merge[`host.${key}`] = resolveHostToken(key, host) ?? ''\n }\n return merge\n}\n\n/**\n * The email address a visitor writes to the business at: the one Setup →\n * Business saves (`seo.entity.email`), else the one-block copy a site saved\n * before that (`business.supportEmail`). Null when the site has neither. One\n * answer for every place that names it: the `{{host.supportEmail}}` token\n * and so the email footer, the waiver consent, the quote and invoice PDFs,\n * the Reply-To of the quote email (AGL-4097), and the address a refused form\n * or sign-up offers instead (AGL-4136). Trimmed, not validated; a caller\n * putting it in a header checks it is an address.\n */\nexport function siteContactEmail(\n host:\n | {\n seo?: { entity?: { email?: unknown } | null } | null\n business?: { supportEmail?: unknown } | null\n }\n | null\n | undefined,\n): string | null {\n const text = (value: unknown) => (typeof value === 'string' ? value.trim().slice(0, 320) : '')\n return text(host?.seo?.entity?.email) || text(host?.business?.supportEmail) || null\n}\n\n/**\n * Resolves `host.*` tokens across every string prop of a normalized node map.\n *\n * Mirrors `resolveNodesBindings` deliberately — same shallow-copy discipline,\n * same string-props-only rule — so a screen and an email resolve the same token\n * to the same value. The issue's warning is the reason: two resolvers drift,\n * and then the same token means different things depending on where an author\n * typed it.\n *\n * Returns the input untouched when the site has nothing to substitute, so a\n * binding-free tree costs one `Object.entries`.\n */\nexport function resolveNodesHostTokens<T extends Record<string, any>>(\n nodes: T,\n host: HostTokenSource | null | undefined,\n): T {\n if (!nodes) return nodes\n let changed = false\n const next: Record<string, any> = {}\n for (const [id, node] of Object.entries(nodes)) {\n const props = node?.props\n if (!props) {\n next[id] = node\n continue\n }\n let nodeChanged = false\n const nextProps: Record<string, unknown> = {}\n for (const [key, value] of Object.entries(props)) {\n if (typeof value === 'string' && value.includes('{{')) {\n const resolved = resolveHostTokens(value, host)\n nextProps[key] = resolved\n if (resolved !== value) nodeChanged = true\n } else {\n nextProps[key] = value\n }\n }\n next[id] = nodeChanged ? { ...node, props: nextProps } : node\n changed = changed || nodeChanged\n }\n return (changed ? next : nodes) as T\n}\n"],"names":["structuredAddressLine","siteProfileUrls","hostPublicOrigin","normalizeAreaServed","trimmed","value","text","trim","undefined","siteUrl","host","custom","cname","replace","subdomain","businessName","seo","entity","name","displayName","logo","logoUrl","telephoneHref","phone","digits","startsWith","SOCIAL_NETWORK_HOSTS","facebook","instagram","x","linkedin","youtube","tiktok","siteSocialProfileUrl","network","hosts","hostname","URL","toLowerCase","some","endsWith","areasServed","areaServed","socialToken","key","type","label","description","resolve","whenEmpty","HOST_TOKENS","slogan","logoDark","logoDarkUrl","url","telephone","phoneLink","supportEmail","siteContactEmail","address","business","mainArea","split","join","socialLinks","links","labels","map","link","filter","Boolean","length","facebookUrl","instagramUrl","xUrl","linkedinUrl","youtubeUrl","tiktokUrl","hostTokenDefinition","Object","prototype","hasOwnProperty","call","HOST_TOKEN_PATTERN","isHostImageToken","keys","hostTokensIn","includes","match","matchAll","push","resolveHostToken","definition","fallback","resolveHostTokens","_token","String","validateHostTokens","options","allow","issues","seen","Set","has","add","kind","message","shouldOmitBlock","describeHostTokens","values","token","set","hostTokenMerge","merge","slice","email","resolveNodesHostTokens","nodes","changed","next","id","node","entries","props","nodeChanged","nextProps","resolved"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,qBAAqB,QAAQ,wBAAoB;AAC1D,SAASC,eAAe,QAA4B,uBAAmB;AACvE,SAASC,gBAAgB,QAAQ,mBAAe;AAChD,SAASC,mBAAmB,QAAQ,sBAAkB;AAyHtD,MAAMC,UAAU,CAACC;IACf,MAAMC,OAAO,OAAOD,UAAU,WAAWA,MAAME,IAAI,KAAK;IACxD,OAAOD,QAAQE;AACjB;AAEA;;;;;;CAMC,GACD,SAASC,QAAQC,IAAqB;IACpC,MAAMC,SAASP,QAAQM,KAAKE,KAAK;IACjC,IAAID,QAAQ,OAAO,CAAC,QAAQ,EAAEA,OAAOE,OAAO,CAAC,gBAAgB,KAAK;IAClE,0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,OAAO2C,OAAO,CAACC,OAAQ;YAChD,IAAI,OAAOtH,UAAU,YAAYA,MAAMkF,QAAQ,CAAC,OAAO;gBACrD,MAAMuC,WAAWhC,kBAAkBzF,OAAOK;gBAC1CmH,SAAS,CAACjF,IAAI,GAAGkF;gBACjB,IAAIA,aAAazH,OAAOuH,cAAc;YACxC,OAAO;gBACLC,SAAS,CAACjF,IAAI,GAAGvC;YACnB;QACF;QACAkH,IAAI,CAACC,GAAG,GAAGI,cAAc,aAAKH;YAAME,OAAOE;aAAcJ;QACzDH,UAAUA,WAAWM;IACvB;IACA,OAAQN,UAAUC,OAAOF;AAC3B"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/host-tokens.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { structuredAddressLine } from './business-profile'\nimport { siteProfileUrls, type HostSeoEntity } from './content-authors'\nimport { hostPublicOrigin } from './host-naming'\nimport { normalizeAreaServed } from './local-business'\n\n/**\n * Host variables — publisher templates that fill themselves in (AGL-1022).\n *\n * A publisher writing an email template cannot reference the installing site,\n * so every install begins with the same chore: swap the placeholder logo, fix\n * the business name, correct the links. Miss one and the site sends an email\n * carrying someone else's branding.\n *\n * `host.*` gives artifacts a way to NAME the host instead of hard-coding it.\n * The author writes `{{host.businessName}}`; the installing site fills it in,\n * and it stays filled in when that site rebrands.\n *\n * ## The namespace IS the security boundary\n *\n * This is publisher-authored content resolving against tenant data, so the\n * registry is CLOSED and each token reads through a hand-written function\n * rather than a path into the document. That is the whole design: a token\n * cannot address `stripeAccountId`, or `memberRoles`, or anything else, because\n * there is no path syntax to express it — `host.` is followed by a key that\n * either appears in {@link HOST_TOKENS} or resolves to nothing at all. Adding a\n * token is a deliberate edit here, reviewable as a diff.\n *\n * A path-based registry (\"allow `host.seo.title`\") would have been shorter and\n * is the version to refuse: allowlisting prefixes is how a namespace grows a\n * hole, and the first `host.orgId` would be a data leak with a plausible commit\n * message.\n *\n * ## Resolve LATE\n *\n * At render and at send, never at install. Freezing values into the artifact\n * would make a rebrand stop propagating silently — the site would keep sending\n * last year's business name from a template nobody remembers is a template.\n *\n * ## Every token defines what \"empty\" does\n *\n * A site with no logo must produce something deliberate. Never an empty image,\n * and never the literal `{{host.logo}}` reaching a visitor — a leaked token is\n * the most embarrassing possible failure for a feature whose entire purpose is\n * to stop templates looking unfinished.\n */\n\n/**\n * What a token yields, so a renderer knows how to place it and the authoring\n * surface can refuse it in the wrong slot.\n *\n * `text` is the only type safe to drop into arbitrary copy. The others carry a\n * shape a slot has to understand — an `image` in a paragraph is a URL sitting\n * in the middle of a sentence, which is exactly the \"fails in a sent email\"\n * outcome this typing exists to move to authoring time.\n */\nexport type HostTokenType = 'text' | 'url' | 'email' | 'image' | 'address'\n\n/** What a renderer should do when a token resolves to nothing. */\nexport type HostTokenEmptyBehaviour =\n /** Render nothing in its place; the surrounding copy still makes sense. */\n | 'blank'\n /**\n * The block holding it should be dropped entirely. An `<img src=\"\">` is a\n * broken-image icon in every mail client, which is worse than no logo.\n */\n | 'omit-block'\n\n/** The site fields a token may read. A closed, explicit surface. */\nexport interface HostTokenSource {\n displayName?: string\n logoUrl?: string\n logoDarkUrl?: string\n subdomain?: string\n cname?: string\n /**\n * The one-block copies of the email and address, and the social links\n * (AGL-1022). Setup → Business profile writes the email and address to `seo.entity`\n * and mirrors them here (AGL-4136), so these are what a token reads when\n * the entity has none: a site saved before that, or by the native apps.\n */\n business?: {\n supportEmail?: string\n address?: string\n socialLinks?: Array<{ label?: string; url?: string }>\n }\n /**\n * The business's facts as Setup → Business profile and SEO → Local business store\n * them (AGL-4136): the name, slogan, phone, email, structured address, the\n * profiles it claims and the areas it serves.\n */\n seo?: {\n entity?: Pick<\n HostSeoEntity,\n | 'name'\n | 'logo'\n | 'slogan'\n | 'email'\n | 'telephone'\n | 'address'\n | 'sameAs'\n | 'areaServed'\n >\n }\n}\n\nexport interface HostTokenDefinition {\n /** The key after `host.` */\n key: string\n type: HostTokenType\n label: string\n description: string\n /** Reads the value. Hand-written per token — never a path into the document. */\n resolve: (host: HostTokenSource) => string | undefined\n /**\n * A deliberate second choice when `resolve` finds nothing.\n *\n * Not a nicety: \"fall back to the business name\" is what turns a missing logo\n * from a hole in the page into a wordmark, which is what a careful designer\n * would have done by hand.\n */\n fallback?: (host: HostTokenSource) => string | undefined\n whenEmpty: HostTokenEmptyBehaviour\n}\n\nconst trimmed = (value: unknown): string | undefined => {\n const text = typeof value === 'string' ? value.trim() : ''\n return text || undefined\n}\n\n/**\n * The site's public URL.\n *\n * A custom domain wins when connected, because that is the address the site is\n * actually known by — a template linking to the aglyn.app subdomain of a site\n * with its own domain is technically correct and reads as a mistake.\n */\nfunction siteUrl(host: HostTokenSource): string | undefined {\n const custom = trimmed(host.cname)\n if (custom) return `https://${custom.replace(/^https?:\\/\\//, '')}`\n // `hostPublicOrigin`, not a fourth hand-rolled apex (AGL-2195). The cname\n // branch stays here because this one strips a scheme the token source may\n // carry; the subdomain branch has no such difference and had none — it was\n // the same two lines with `aglyn.app` written in, so an operator's own apex\n // was honoured everywhere except in the tokens a template renders.\n return hostPublicOrigin({ subdomain: trimmed(host.subdomain) })\n}\n\nfunction businessName(host: HostTokenSource): string | undefined {\n return trimmed(host.seo?.entity?.name) ?? trimmed(host.displayName)\n}\n\nfunction logo(host: HostTokenSource): string | undefined {\n return trimmed(host.logoUrl) ?? trimmed(host.seo?.entity?.logo)\n}\n\n/**\n * A phone number as a `tel:` link (AGL-4136): everything but its digits and\n * a leading `+` removed, so `+1 (512) 555-0100` dials `tel:+15125550100`.\n * Nothing when the number holds no digit, so a Call button never links to a\n * bare `tel:`.\n */\nexport function telephoneHref(phone: unknown): string | undefined {\n const text = trimmed(phone)\n if (!text) return undefined\n const digits = text.replace(/\\D+/g, '')\n if (!digits) return undefined\n return `tel:${text.startsWith('+') ? '+' : ''}${digits}`\n}\n\n/**\n * The social networks a page can link by name (AGL-4136), each with the\n * hostnames its profile addresses are served from. A hostname matches itself\n * and any subdomain of itself, so `www.` and `m.` addresses are the same\n * profile. X keeps `twitter.com`, because a link saved before the rename is\n * still the same account.\n */\nconst SOCIAL_NETWORK_HOSTS = {\n facebook: ['facebook.com', 'fb.com'],\n instagram: ['instagram.com'],\n x: ['x.com', 'twitter.com'],\n linkedin: ['linkedin.com'],\n youtube: ['youtube.com', 'youtu.be'],\n tiktok: ['tiktok.com'],\n} as const\n\nexport type HostSocialNetwork = keyof typeof SOCIAL_NETWORK_HOSTS\n\n/**\n * The site's profile on one network: the first of the profiles it claims\n * (`siteProfileUrls`, the entity's `sameAs` and then Setup → Business profile's\n * social links, https only) served from that network's hostname. Matched by\n * HOSTNAME rather than by the link's label, because the label is free text\n * and the address is what a visitor is sent to.\n */\nexport function siteSocialProfileUrl(\n host: HostTokenSource | null | undefined,\n network: HostSocialNetwork,\n): string | undefined {\n const hosts: readonly string[] = SOCIAL_NETWORK_HOSTS[network]\n for (const value of siteProfileUrls(host)) {\n let hostname: string\n try {\n hostname = new URL(value).hostname.toLowerCase()\n } catch {\n continue\n }\n if (hosts.some((name) => hostname === name || hostname.endsWith(`.${name}`))) {\n return value\n }\n }\n return undefined\n}\n\n/** The areas served, as SEO → Local business stores and the structured data publishes them. */\nfunction areasServed(host: HostTokenSource): string[] {\n return normalizeAreaServed(host.seo?.entity?.areaServed)\n}\n\n/** One social network's profile link as a token: a URL, dropped where the site has none. */\nfunction socialToken(\n network: HostSocialNetwork,\n key: string,\n name: string,\n): HostTokenDefinition {\n return {\n key,\n type: 'url',\n label: `${name} link`,\n description: `The address of the site’s ${name} profile, from Setup → Business profile.`,\n resolve: (host) => siteSocialProfileUrl(host, network),\n whenEmpty: 'omit-block',\n }\n}\n\n/**\n * The closed registry.\n *\n * Ordered as an author would look for them. Every entry is reachable from a\n * field a site can actually set — a token that can never resolve is worse than\n * an absent one, because it teaches people the feature does not work.\n */\nexport const HOST_TOKENS: Record<string, HostTokenDefinition> = {\n businessName: {\n key: 'businessName',\n type: 'text',\n label: 'Business name',\n description:\n 'The business name from Setup → Business profile, or the site’s name when none is set.',\n resolve: businessName,\n whenEmpty: 'blank',\n },\n slogan: {\n key: 'slogan',\n type: 'text',\n label: 'Slogan',\n description: 'A short line about the business, from Setup → Business profile.',\n resolve: (host) => trimmed(host.seo?.entity?.slogan),\n whenEmpty: 'blank',\n },\n logo: {\n key: 'logo',\n type: 'image',\n label: 'Logo',\n description: 'The site’s logo image.',\n resolve: logo,\n // No image: the block is dropped and the business name carries the brand\n // instead, which is what the block was for.\n whenEmpty: 'omit-block',\n },\n logoDark: {\n key: 'logoDark',\n type: 'image',\n label: 'Logo for dark backgrounds',\n description:\n 'The logo to show on a dark background. The site’s logo when it has no dark one.',\n // The pair a header toggles by color scheme (AGL-4119): a site with one\n // logo shows it in both schemes, and one with none shows neither.\n resolve: (host) => trimmed(host.logoDarkUrl) ?? logo(host),\n whenEmpty: 'omit-block',\n },\n url: {\n key: 'url',\n type: 'url',\n label: 'Site address',\n description: 'The site’s public URL — its custom domain when connected.',\n resolve: siteUrl,\n whenEmpty: 'blank',\n },\n phone: {\n key: 'phone',\n type: 'text',\n label: 'Phone',\n description: 'The business’s phone number, as entered on Setup → Business profile.',\n resolve: (host) => trimmed(host.seo?.entity?.telephone),\n whenEmpty: 'omit-block',\n },\n phoneLink: {\n key: 'phoneLink',\n type: 'url',\n label: 'Phone link',\n description:\n 'The phone number as a tel: link, for a Call button’s link. Dropped when the site has no phone.',\n resolve: (host) => telephoneHref(host.seo?.entity?.telephone),\n whenEmpty: 'omit-block',\n },\n /*\n The key keeps its old name, because pages and emails already say\n `{{host.supportEmail}}`. What it reads is the site's one email (AGL-4136):\n the one Setup → Business profile saves to the entity, else the one-block copy a\n site saved before that.\n */\n supportEmail: {\n key: 'supportEmail',\n type: 'email',\n label: 'Email',\n description: 'The email address visitors write to, from Setup → Business profile.',\n resolve: (host) => siteContactEmail(host) ?? undefined,\n whenEmpty: 'omit-block',\n },\n address: {\n key: 'address',\n type: 'address',\n label: 'Postal address',\n description:\n 'The business’s postal address from Setup → Business profile, as one block of text.',\n // The structured address, formatted the one way it is formatted\n // everywhere (AGL-4136), else the one-block copy as it was typed —\n // line breaks kept, because a document prints it a line per line.\n resolve: (host) =>\n trimmed(structuredAddressLine(host.seo?.entity?.address)) ??\n trimmed(host.business?.address),\n whenEmpty: 'omit-block',\n },\n mainArea: {\n key: 'mainArea',\n type: 'text',\n label: 'Main area',\n description:\n 'The first area served, by its place name: San Antonio, for “San Antonio, TX”. From SEO → Local business.',\n // The text before the first comma, so the token reads in a sentence —\n // \"across San Antonio and surrounding areas\" — and a page that already\n // says the place name can switch to it without a visible change.\n resolve: (host) => trimmed(areasServed(host)[0]?.split(',')[0]),\n whenEmpty: 'blank',\n },\n areasServed: {\n key: 'areasServed',\n type: 'text',\n label: 'Areas served',\n description:\n 'Every area served, in order, separated by commas. From SEO → Local business.',\n resolve: (host) => trimmed(areasServed(host).join(', ')),\n whenEmpty: 'blank',\n },\n socialLinks: {\n key: 'socialLinks',\n type: 'text',\n label: 'Social links',\n description: 'The site’s social profiles, as a list of labeled links.',\n // Rendered as text here so a token in copy degrades to something readable;\n // a link to one profile is that network's own token below (AGL-4136).\n resolve: (host) => {\n const links = host.business?.socialLinks ?? []\n const labels = links\n .map((link) => trimmed(link?.label) ?? trimmed(link?.url))\n .filter((label): label is string => Boolean(label))\n return labels.length ? labels.join(' · ') : undefined\n },\n whenEmpty: 'omit-block',\n },\n /*\n One link per common network (AGL-4136), so a page's social icons link\n the site's own profiles from Setup → Business profile instead of a hand-made\n variable per network.\n */\n facebookUrl: socialToken('facebook', 'facebookUrl', 'Facebook'),\n instagramUrl: socialToken('instagram', 'instagramUrl', 'Instagram'),\n xUrl: socialToken('x', 'xUrl', 'X'),\n linkedinUrl: socialToken('linkedin', 'linkedinUrl', 'LinkedIn'),\n youtubeUrl: socialToken('youtube', 'youtubeUrl', 'YouTube'),\n tiktokUrl: socialToken('tiktok', 'tiktokUrl', 'TikTok'),\n}\n\n/**\n * The registry's entry for `key`, or undefined when it declares none.\n *\n * An OWN entry only. `HOST_TOKENS` is an object literal, so a bare index also\n * finds the `Object.prototype` members — `constructor`, `toString`, `valueOf` —\n * and every one of those names matches {@link HOST_TOKEN_PATTERN}. Read that\n * way, `{{host.constructor}}` answers the `Object` function where a definition\n * belongs, and calling its `resolve` throws in the middle of a render. A name\n * the registry does not declare resolves to nothing, whatever the name is.\n */\nexport function hostTokenDefinition(\n key: string,\n): HostTokenDefinition | undefined {\n return Object.prototype.hasOwnProperty.call(HOST_TOKENS, key)\n ? HOST_TOKENS[key]\n : undefined\n}\n\n/**\n * `{{host.key}}` — whitespace-tolerant, and deliberately NOT dotted beyond one\n * segment. `host.a.b` does not match, so there is no path syntax to abuse.\n */\nexport const HOST_TOKEN_PATTERN = /\\{\\{\\s*host\\.([a-zA-Z][a-zA-Z0-9_]*)\\s*\\}\\}/g\n\n/**\n * Whether a value is exactly one image token, like `{{host.logo}}`: what a\n * picture's `src` may be when it is the installing site's own logo. It becomes\n * that site's stored value at render, so it names nothing of the publisher's.\n */\nexport function isHostImageToken(value: string): boolean {\n const keys = hostTokensIn(value)\n return (\n keys.length === 1 &&\n value.replace(HOST_TOKEN_PATTERN, '').trim() === '' &&\n hostTokenDefinition(keys[0])?.type === 'image'\n )\n}\n\n/** Every `host.*` token in a string, in order, including unknown ones. */\nexport function hostTokensIn(text: string): string[] {\n if (typeof text !== 'string' || !text.includes('{{')) return []\n const keys: string[] = []\n for (const match of text.matchAll(HOST_TOKEN_PATTERN)) keys.push(match[1])\n return keys\n}\n\n/** The resolved value of one token, or undefined when the site has none. */\nexport function resolveHostToken(\n key: string,\n host: HostTokenSource | null | undefined,\n): string | undefined {\n const definition = hostTokenDefinition(key)\n if (!definition || !host) return undefined\n return definition.resolve(host) ?? definition.fallback?.(host)\n}\n\n/**\n * Replaces every `host.*` token with the installing site's value.\n *\n * An unresolved token — unknown key, or a site that has not set the field —\n * renders EMPTY, never the literal. Leaking `{{host.logo}}` into a sent email\n * is the failure this feature exists to prevent, so it cannot be the fallback\n * for the feature's own gaps. The authoring-time check\n * ({@link validateHostTokens}) is where a typo is meant to be caught, while the\n * writer can still fix it.\n */\nexport function resolveHostTokens(\n text: string,\n host: HostTokenSource | null | undefined,\n): string {\n if (typeof text !== 'string' || !text.includes('{{')) return text\n return text.replace(HOST_TOKEN_PATTERN, (_token, key) =>\n resolveHostToken(String(key), host) ?? '',\n )\n}\n\nexport interface HostTokenIssue {\n key: string\n /**\n * `unknown` — no such token; it will render empty.\n * `wrong-slot` — the token's type cannot be placed here.\n */\n kind: 'unknown' | 'wrong-slot'\n message: string\n}\n\n/**\n * Authoring-time check: catch a token before it reaches a visitor.\n *\n * The two things worth failing on are a typo (which would silently render\n * nothing) and a type mismatch (an image URL dropped into a sentence). Both are\n * invisible at authoring time without this and obvious afterwards, which is the\n * wrong way round for something that ends up in a sent email.\n *\n * `allow` names the types this slot can take. Omit it for free text, where only\n * `text` and the string-ish types make sense.\n */\nexport function validateHostTokens(\n text: string,\n options?: { allow?: readonly HostTokenType[] },\n): HostTokenIssue[] {\n const allow = options?.allow ?? ['text', 'url', 'email', 'address']\n const issues: HostTokenIssue[] = []\n const seen = new Set<string>()\n for (const key of hostTokensIn(text)) {\n if (seen.has(key)) continue\n seen.add(key)\n const definition = hostTokenDefinition(key)\n if (!definition) {\n issues.push({\n key,\n kind: 'unknown',\n message:\n `There is no host variable called \"${key}\". It will render as ` +\n 'nothing. Available: ' +\n Object.keys(HOST_TOKENS).join(', ') +\n '.',\n })\n continue\n }\n if (!allow.includes(definition.type)) {\n issues.push({\n key,\n kind: 'wrong-slot',\n message:\n `\"${definition.label}\" is ${\n definition.type === 'image' ? 'an image' : `a ${definition.type}`\n }, so it cannot go here. Put it in a slot that takes ` +\n `${definition.type === 'image' ? 'an image' : `a ${definition.type}`}.`,\n })\n }\n }\n return issues\n}\n\n/**\n * Whether a block containing these tokens should be dropped for this site.\n *\n * The other half of \"every token needs a defined empty behaviour\": a logo block\n * on a site with no logo should not render an empty image, and the renderer\n * cannot know that from the resolved string alone — `''` is both \"no value\" and\n * \"a value that happens to be empty\". Asking here keeps the rule with the\n * token definition rather than spread across the surfaces that render it.\n */\nexport function shouldOmitBlock(\n text: string,\n host: HostTokenSource | null | undefined,\n): boolean {\n for (const key of hostTokensIn(text)) {\n const definition = hostTokenDefinition(key)\n if (!definition || definition.whenEmpty !== 'omit-block') continue\n if (!resolveHostToken(key, host)) return true\n }\n return false\n}\n\n/**\n * Every token with its resolved value for one site, for an authoring picker\n * that shows what each will actually produce here.\n *\n * A picker listing token names alone makes the author guess; showing the value\n * this site would render is what turns \"is it businessName or business_name\"\n * into a question nobody has to ask.\n */\nexport function describeHostTokens(\n host: HostTokenSource | null | undefined,\n): Array<HostTokenDefinition & { token: string; value?: string; set: boolean }> {\n return Object.values(HOST_TOKENS).map((definition) => {\n const value = resolveHostToken(definition.key, host)\n return {\n ...definition,\n token: `{{host.${definition.key}}}`,\n value,\n set: Boolean(value),\n }\n })\n}\n\n/** One row of {@link describeHostTokens} as plain data: the definition without its resolvers. */\nexport interface HostTokenPreviewRow {\n key: string\n type: HostTokenType\n label: string\n description: string\n whenEmpty: HostTokenEmptyBehaviour\n token: string\n value?: string\n set: boolean\n}\n\n/**\n * {@link describeHostTokens} without the resolvers, so it can travel as data:\n * the native apps' Business details card lists \"What your pages can use\"\n * from it, and replays these answers in their tests (AGL-4136).\n */\nexport function hostTokenPreview(\n host: HostTokenSource | null | undefined,\n): HostTokenPreviewRow[] {\n return describeHostTokens(host).map(\n ({ key, type, label, description, whenEmpty, token, value, set }) => ({\n key,\n type,\n label,\n description,\n whenEmpty,\n token,\n ...(value === undefined ? {} : { value }),\n set,\n }),\n )\n}\n\n/**\n * The `host.*` values as a merge-token map, for surfaces that already have a\n * token substituter of their own.\n *\n * This is how EMAIL gets host variables without the email library depending on\n * this one: `substituteMergeTokens` already matches `{{a.b}}`, so a caller\n * spreads this into the merge map it was passing anyway. One registry, two\n * surfaces, no second substitution engine to drift.\n *\n * Every registered token appears, INCLUDING the ones this site has not set —\n * as `''`. Omitting them would leave `{{host.supportEmail}}` for the generic\n * catch-all to blank, which works today and works by accident: the moment a\n * surface without that catch-all uses this map, the literal token ships.\n */\nexport function hostTokenMerge(\n host: HostTokenSource | null | undefined,\n): Record<string, string> {\n const merge: Record<string, string> = {}\n for (const key of Object.keys(HOST_TOKENS)) {\n merge[`host.${key}`] = resolveHostToken(key, host) ?? ''\n }\n return merge\n}\n\n/**\n * The email address a visitor writes to the business at: the one Setup →\n * Business saves (`seo.entity.email`), else the one-block copy a site saved\n * before that (`business.supportEmail`). Null when the site has neither. One\n * answer for every place that names it: the `{{host.supportEmail}}` token\n * and so the email footer, the waiver consent, the quote and invoice PDFs,\n * the Reply-To of the quote email (AGL-4097), and the address a refused form\n * or sign-up offers instead (AGL-4136). Trimmed, not validated; a caller\n * putting it in a header checks it is an address.\n */\nexport function siteContactEmail(\n host:\n | {\n seo?: { entity?: { email?: unknown } | null } | null\n business?: { supportEmail?: unknown } | null\n }\n | null\n | undefined,\n): string | null {\n const text = (value: unknown) => (typeof value === 'string' ? value.trim().slice(0, 320) : '')\n return text(host?.seo?.entity?.email) || text(host?.business?.supportEmail) || null\n}\n\n/**\n * Resolves `host.*` tokens across every string prop of a normalized node map.\n *\n * Mirrors `resolveNodesBindings` deliberately — same shallow-copy discipline,\n * same string-props-only rule — so a screen and an email resolve the same token\n * to the same value. The issue's warning is the reason: two resolvers drift,\n * and then the same token means different things depending on where an author\n * typed it.\n *\n * Returns the input untouched when the site has nothing to substitute, so a\n * binding-free tree costs one `Object.entries`.\n */\nexport function resolveNodesHostTokens<T extends Record<string, any>>(\n nodes: T,\n host: HostTokenSource | null | undefined,\n): T {\n if (!nodes) return nodes\n let changed = false\n const next: Record<string, any> = {}\n for (const [id, node] of Object.entries(nodes)) {\n const props = node?.props\n if (!props) {\n next[id] = node\n continue\n }\n let nodeChanged = false\n const nextProps: Record<string, unknown> = {}\n for (const [key, value] of Object.entries(props)) {\n if (typeof value === 'string' && value.includes('{{')) {\n const resolved = resolveHostTokens(value, host)\n nextProps[key] = resolved\n if (resolved !== value) nodeChanged = true\n } else {\n nextProps[key] = value\n }\n }\n next[id] = nodeChanged ? { ...node, props: nextProps } : node\n changed = changed || nodeChanged\n }\n return (changed ? next : nodes) as T\n}\n"],"names":["structuredAddressLine","siteProfileUrls","hostPublicOrigin","normalizeAreaServed","trimmed","value","text","trim","undefined","siteUrl","host","custom","cname","replace","subdomain","businessName","seo","entity","name","displayName","logo","logoUrl","telephoneHref","phone","digits","startsWith","SOCIAL_NETWORK_HOSTS","facebook","instagram","x","linkedin","youtube","tiktok","siteSocialProfileUrl","network","hosts","hostname","URL","toLowerCase","some","endsWith","areasServed","areaServed","socialToken","key","type","label","description","resolve","whenEmpty","HOST_TOKENS","slogan","logoDark","logoDarkUrl","url","telephone","phoneLink","supportEmail","siteContactEmail","address","business","mainArea","split","join","socialLinks","links","labels","map","link","filter","Boolean","length","facebookUrl","instagramUrl","xUrl","linkedinUrl","youtubeUrl","tiktokUrl","hostTokenDefinition","Object","prototype","hasOwnProperty","call","HOST_TOKEN_PATTERN","isHostImageToken","keys","hostTokensIn","includes","match","matchAll","push","resolveHostToken","definition","fallback","resolveHostTokens","_token","String","validateHostTokens","options","allow","issues","seen","Set","has","add","kind","message","shouldOmitBlock","describeHostTokens","values","token","set","hostTokenPreview","hostTokenMerge","merge","slice","email","resolveNodesHostTokens","nodes","changed","next","id","node","entries","props","nodeChanged","nextProps","resolved"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,G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|
/**
|
|
50
50
|
* The pre-sign-in sections whose exact page the apps finish natively: sign-up
|
|
51
51
|
* (with its `?plan=`), an emailed verification link, an emailed password
|
|
52
|
-
* reset and account recovery (`AuthFlow.swift
|
|
53
|
-
*
|
|
54
|
-
*
|
|
52
|
+
* reset and account recovery (`AuthFlow.swift`, `AuthFlow.kt`). Only the page
|
|
53
|
+
* itself opens the app; anything under it stays in the browser, where the
|
|
54
|
+
* console handles it. Android's App Link filter claims the same console paths
|
|
55
|
+
* as {@link consoleAppLinksComponents}, refusing each exclusion in its manifest
|
|
56
|
+
* (`native-app-association.spec.ts` holds the two together, AGL-4059).
|
|
55
57
|
*/
|
|
56
58
|
export declare const NATIVE_AUTH_LINK_SEGMENTS: readonly string[];
|
|
57
59
|
/** One `applinks` component: a URL path pattern, optionally excluded. */
|
|
@@ -77,9 +77,11 @@
|
|
|
77
77
|
/**
|
|
78
78
|
* The pre-sign-in sections whose exact page the apps finish natively: sign-up
|
|
79
79
|
* (with its `?plan=`), an emailed verification link, an emailed password
|
|
80
|
-
* reset and account recovery (`AuthFlow.swift
|
|
81
|
-
*
|
|
82
|
-
*
|
|
80
|
+
* reset and account recovery (`AuthFlow.swift`, `AuthFlow.kt`). Only the page
|
|
81
|
+
* itself opens the app; anything under it stays in the browser, where the
|
|
82
|
+
* console handles it. Android's App Link filter claims the same console paths
|
|
83
|
+
* as {@link consoleAppLinksComponents}, refusing each exclusion in its manifest
|
|
84
|
+
* (`native-app-association.spec.ts` holds the two together, AGL-4059).
|
|
83
85
|
*/ export const NATIVE_AUTH_LINK_SEGMENTS = [
|
|
84
86
|
'account-recovery',
|
|
85
87
|
'reset-password',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/native-app-association.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/*==========================================\n * THE DOCUMENTS THAT TIE THE NATIVE APPS TO A DOMAIN (AGL-3817).\n *\n * Apple's `apple-app-site-association` and Google's `assetlinks.json` are how\n * a domain says which apps may use its passkeys (`webcredentials`,\n * `get_login_creds`) and open its links (`applinks`, `handle_all_urls`). Both\n * are fetched by the platform's verifier, not by a person, so each has to be\n * exactly `application/json`, a 200, no redirect and no cookie.\n *\n * Everything that names an app comes from the environment, never from here:\n *\n * - `NATIVE_APPLE_APP_IDS`: comma-separated `<team id>.<bundle id>` values,\n * in the order the system should prefer them;\n * - `NATIVE_ANDROID_APPS`: `;`-separated `<package>=<sha256>,<sha256>`\n * entries, each fingerprint the colon-separated hex Play Console prints.\n *\n * Unset (or nothing valid in it), the document answers 404: a deployment\n * with no apps of its own vouches for none.\n *\n * A leaf with no imports, because both middlewares read the paths below.\n *=========================================*/\n\n/** Where Apple's verifier reads the association file: no `.json` suffix. */\nexport const APPLE_APP_SITE_ASSOCIATION_PATH = '/.well-known/apple-app-site-association'\n\n/** Where Google's verifier reads the statement list. */\nexport const ASSET_LINKS_PATH = '/.well-known/assetlinks.json'\n\n/**\n * The route handlers each middleware rewrites the two public paths to. They\n * live under `/api` because both apps keep their route handlers there, and\n * neither middleware runs again on `/api`.\n */\nexport const NATIVE_APP_ASSOCIATION_ROUTES: Readonly<Record<string, string>> = {\n [APPLE_APP_SITE_ASSOCIATION_PATH]: '/api/native-app-association/apple-app-site-association',\n [ASSET_LINKS_PATH]: '/api/native-app-association/assetlinks',\n}\n\n/** The route handler a public association path is served by, or null. */\nexport function nativeAppAssociationRoute(pathname: string): string | null {\n return Object.prototype.hasOwnProperty.call(NATIVE_APP_ASSOCIATION_ROUTES, pathname)\n ? NATIVE_APP_ASSOCIATION_ROUTES[pathname]\n : null\n}\n\n/**\n * The console's top-level sections the native apps have no screen for, so a\n * link to one stays in the browser: the sign-in page and SSO (the system\n * auth session opens them for the app, and a universal link there would loop\n * back into the app), the native hand-off and other `/auth` pages, the\n * sign-out page, the site admin bar's connect page, a plugin's public\n * device pages, a site's photo link (`/p/<linkId>`, opened on a phone\n * by someone with no account) and the connector consent page\n * (`/oauth/authorize`, AGL-4225), which an app such as Claude opens in the\n * browser and expects to finish there. The sections the apps finish natively are\n * {@link NATIVE_AUTH_LINK_SEGMENTS}.\n *\n * The rest of the console's top-level sections (`admin`, `billing`,\n * `manage`, `support`) and every workspace path are what the native\n * deep-link grammar resolves (`DeepLinks.swift`, `DeepLinks.kt`): a\n * registered screen, the Besigner in the app's own web view, or the nearest\n * native screen. `apps/console/specs/native-app-association.spec.ts` holds\n * this list to the console's route set and the native link specs.\n */\nexport const NATIVE_WEB_ONLY_TOP_LEVEL_SEGMENTS: readonly string[] = [\n 'auth',\n 'edit-access',\n 'kiosk',\n 'oauth',\n 'p',\n 'signin',\n 'signout',\n 'sso',\n]\n\n/**\n * The pre-sign-in sections whose exact page the apps finish natively: sign-up\n * (with its `?plan=`), an emailed verification link, an emailed password\n * reset and account recovery (`AuthFlow.swift`; Android's console intent\n * filter lists the same four paths). Only the page itself opens the app;\n * anything under it stays in the browser, where the console handles it.\n */\nexport const NATIVE_AUTH_LINK_SEGMENTS: readonly string[] = [\n 'account-recovery',\n 'reset-password',\n 'signup',\n 'verify-email',\n]\n\n/** One `applinks` component: a URL path pattern, optionally excluded. */\nexport interface AppLinksComponent {\n '/': string\n exclude?: true\n comment?: string\n}\n\n/**\n * The console paths the apps open, as `applinks` components. Apple reads\n * them in order and the first match wins, so every exclusion comes ahead of\n * the closing catch-all.\n */\nexport function consoleAppLinksComponents(): AppLinksComponent[] {\n const excluded: AppLinksComponent[] = [\n { '/': '/_*', exclude: true, comment: 'framework and internal paths' },\n { '/': '/api', exclude: true },\n { '/': '/api/*', exclude: true, comment: 'route handlers' },\n { '/': '/.well-known/*', exclude: true },\n ]\n for (const segment of NATIVE_WEB_ONLY_TOP_LEVEL_SEGMENTS) {\n excluded.push({ '/': `/${segment}`, exclude: true }, { '/': `/${segment}/*`, exclude: true })\n }\n for (const segment of NATIVE_AUTH_LINK_SEGMENTS) {\n excluded.push({ '/': `/${segment}/*`, exclude: true })\n }\n return [\n ...excluded,\n { '/': '/*', comment: 'workspace, site, account, billing, support and staff pages' },\n ]\n}\n\n/** `TEAMID1234.com.example.app`: a 10-character team id, then a bundle id. */\nconst APPLE_APP_ID = /^[A-Z0-9]{10}\\.[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)+$/\n\n/** A Java package name: dot-separated identifiers, at least two. */\nconst ANDROID_PACKAGE = /^[A-Za-z][A-Za-z0-9_]*(\\.[A-Za-z][A-Za-z0-9_]*)+$/\n\n/** A SHA-256 certificate fingerprint as 32 colon-separated hex pairs. */\nconst SHA256_FINGERPRINT = /^([0-9A-F]{2}:){31}[0-9A-F]{2}$/\n\n/** The Apple app ids in `NATIVE_APPLE_APP_IDS`, in order; invalid ones dropped. */\nexport function parseAppleAppIds(raw: string | undefined): string[] {\n const ids = (raw ?? '')\n .split(',')\n .map((value) => value.trim())\n .filter((value) => APPLE_APP_ID.test(value))\n return [...new Set(ids)]\n}\n\n/** One Android app and the signing certificates it may be verified by. */\nexport interface AndroidAppAssociation {\n packageName: string\n sha256Fingerprints: string[]\n}\n\n/**\n * The Android apps in `NATIVE_ANDROID_APPS`. An entry without a valid package\n * or without one valid fingerprint is dropped whole: a statement with no\n * certificate verifies nothing.\n */\nexport function parseAndroidApps(raw: string | undefined): AndroidAppAssociation[] {\n const apps: AndroidAppAssociation[] = []\n for (const entry of (raw ?? '').split(';')) {\n const at = entry.indexOf('=')\n if (at < 0) continue\n const packageName = entry.slice(0, at).trim()\n if (!ANDROID_PACKAGE.test(packageName)) continue\n if (apps.some((app) => app.packageName === packageName)) continue\n const fingerprints = entry\n .slice(at + 1)\n .split(',')\n .map((value) => value.trim().toUpperCase())\n .filter((value) => SHA256_FINGERPRINT.test(value))\n if (fingerprints.length === 0) continue\n apps.push({ packageName, sha256Fingerprints: [...new Set(fingerprints)] })\n }\n return apps\n}\n\n/** The `apple-app-site-association` document Apple's CDN reads. */\nexport interface AppleAppSiteAssociation {\n applinks?: {\n apps: []\n details: Array<{ appIDs: string[]; components: AppLinksComponent[] }>\n }\n webcredentials: { apps: string[] }\n}\n\n/**\n * The association file for these app ids. `applinks` is only for a host\n * whose paths the native deep-link grammar resolves: the console. A host\n * that serves the passkey relying party alone gets `webcredentials` only.\n *\n * One `details` entry per app, in the configured order, because when two\n * installed apps claim the same path the system takes the first.\n */\nexport function appleAppSiteAssociation(\n appIds: string[],\n options: { applinks: boolean },\n): AppleAppSiteAssociation {\n const document: AppleAppSiteAssociation = { webcredentials: { apps: [...appIds] } }\n if (options.applinks) {\n const components = consoleAppLinksComponents()\n document.applinks = {\n apps: [],\n details: appIds.map((appId) => ({ appIDs: [appId], components })),\n }\n }\n return document\n}\n\n/** One Digital Asset Links statement. */\nexport interface AssetLinkStatement {\n relation: string[]\n target: { namespace: 'android_app'; package_name: string; sha256_cert_fingerprints: string[] }\n}\n\n/** Passkeys and app links, for every configured app. */\nexport const ASSET_LINK_RELATIONS = [\n 'delegate_permission/common.handle_all_urls',\n 'delegate_permission/common.get_login_creds',\n] as const\n\n/** The `assetlinks.json` statement list Google's verifier reads. */\nexport function assetLinks(apps: AndroidAppAssociation[]): AssetLinkStatement[] {\n return apps.map((app) => ({\n relation: [...ASSET_LINK_RELATIONS],\n target: {\n namespace: 'android_app',\n package_name: app.packageName,\n sha256_cert_fingerprints: [...app.sha256Fingerprints],\n },\n }))\n}\n\n/** The request's hostname: lowercase, no port. */\nexport function requestHostname(host: string | null | undefined): string {\n return (host ?? '').trim().toLowerCase().replace(/:\\d+$/, '')\n}\n\n/** A URL's hostname, or null when it is not one. */\nexport function hostnameOfUrl(url: string | null | undefined): string | null {\n if (!url) return null\n try {\n return new URL(url).hostname.toLowerCase() || null\n } catch {\n return null\n }\n}\n\n/** What a route handler needs to answer one of the two documents. */\nexport interface NativeAppAssociationRequest {\n /** The request's `Host` header. */\n host: string | null\n /**\n * The hostnames this deployment vouches for. Every other host an app\n * serves (a customer's custom domain, a workspace subdomain, a white-label\n * console) answers 404, because the apps are this deployment's and not\n * theirs.\n */\n servedHosts: ReadonlyArray<string | null | undefined>\n /** Whether this host's paths are console links the apps resolve. */\n applinks: boolean\n /** The environment; `process.env` in the routes, a fixture in specs. */\n env: Readonly<Record<string, string | undefined>>\n}\n\n/** Short on purpose: Apple's CDN caches on top, and a fix must land within minutes. */\nconst CACHE_CONTROL = 'public, max-age=300, s-maxage=300'\n\n/**\n * Whether this host may answer. A Vercel preview deployment is reachable only\n * at the platform's own generated hostnames, so it answers on any host, which\n * is what lets a preview be checked before it is promoted.\n */\nfunction servesHost(request: NativeAppAssociationRequest): boolean {\n if (request.env['VERCEL_ENV'] === 'preview') return true\n const hostname = requestHostname(request.host)\n if (!hostname) return false\n return request.servedHosts.some((served) => requestHostname(served) === hostname)\n}\n\nfunction notFound(): Response {\n return new Response('Not Found', {\n status: 404,\n headers: { 'content-type': 'text/plain; charset=utf-8', 'cache-control': CACHE_CONTROL },\n })\n}\n\nfunction json(body: unknown): Response {\n return new Response(JSON.stringify(body), {\n status: 200,\n headers: { 'content-type': 'application/json', 'cache-control': CACHE_CONTROL },\n })\n}\n\n/** `GET /.well-known/apple-app-site-association`. */\nexport function appleAppSiteAssociationResponse(request: NativeAppAssociationRequest): Response {\n const appIds = parseAppleAppIds(request.env['NATIVE_APPLE_APP_IDS'])\n if (appIds.length === 0 || !servesHost(request)) return notFound()\n return json(appleAppSiteAssociation(appIds, { applinks: request.applinks }))\n}\n\n/** `GET /.well-known/assetlinks.json`. */\nexport function assetLinksResponse(request: NativeAppAssociationRequest): Response {\n const apps = parseAndroidApps(request.env['NATIVE_ANDROID_APPS'])\n if (apps.length === 0 || !servesHost(request)) return notFound()\n return json(assetLinks(apps))\n}\n"],"names":["APPLE_APP_SITE_ASSOCIATION_PATH","ASSET_LINKS_PATH","NATIVE_APP_ASSOCIATION_ROUTES","nativeAppAssociationRoute","pathname","Object","prototype","hasOwnProperty","call","NATIVE_WEB_ONLY_TOP_LEVEL_SEGMENTS","NATIVE_AUTH_LINK_SEGMENTS","consoleAppLinksComponents","excluded","exclude","comment","segment","push","APPLE_APP_ID","ANDROID_PACKAGE","SHA256_FINGERPRINT","parseAppleAppIds","raw","ids","split","map","value","trim","filter","test","Set","parseAndroidApps","apps","entry","at","indexOf","packageName","slice","some","app","fingerprints","toUpperCase","length","sha256Fingerprints","appleAppSiteAssociation","appIds","options","document","webcredentials","applinks","components","details","appId","appIDs","ASSET_LINK_RELATIONS","assetLinks","relation","target","namespace","package_name","sha256_cert_fingerprints","requestHostname","host","toLowerCase","replace","hostnameOfUrl","url","URL","hostname","CACHE_CONTROL","servesHost","request","env","servedHosts","served","notFound","Response","status","headers","json","body","JSON","stringify","appleAppSiteAssociationResponse","assetLinksResponse"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;2CAoB2C,GAE3C,0EAA0E,GAC1E,OAAO,MAAMA,kCAAkC,0CAAyC;AAExF,sDAAsD,GACtD,OAAO,MAAMC,mBAAmB,+BAA8B;AAE9D;;;;CAIC,GACD,OAAO,MAAMC,gCAAkE;IAC7E,CAACF,gCAAgC,EAAE;IACnC,CAACC,iBAAiB,EAAE;AACtB,EAAC;AAED,uEAAuE,GACvE,OAAO,SAASE,0BAA0BC,QAAgB;IACxD,OAAOC,OAAOC,SAAS,CAACC,cAAc,CAACC,IAAI,CAACN,+BAA+BE,YACvEF,6BAA6B,CAACE,SAAS,GACvC;AACN;AAEA;;;;;;;;;;;;;;;;;;CAkBC,GACD,OAAO,MAAMK,qCAAwD;IACnE;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAA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AMvC,OAAOD,iBAAiBwC,QAAQC,GAAG,CAAC,sBAAsB;IAChE,IAAIxC,KAAKU,MAAM,KAAK,KAAK,CAAC4B,WAAWC,UAAU,OAAOI;IACtD,OAAOI,KAAKxB,WAAWvB;AACzB"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/native-app-association.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/*==========================================\n * THE DOCUMENTS THAT TIE THE NATIVE APPS TO A DOMAIN (AGL-3817).\n *\n * Apple's `apple-app-site-association` and Google's `assetlinks.json` are how\n * a domain says which apps may use its passkeys (`webcredentials`,\n * `get_login_creds`) and open its links (`applinks`, `handle_all_urls`). Both\n * are fetched by the platform's verifier, not by a person, so each has to be\n * exactly `application/json`, a 200, no redirect and no cookie.\n *\n * Everything that names an app comes from the environment, never from here:\n *\n * - `NATIVE_APPLE_APP_IDS`: comma-separated `<team id>.<bundle id>` values,\n * in the order the system should prefer them;\n * - `NATIVE_ANDROID_APPS`: `;`-separated `<package>=<sha256>,<sha256>`\n * entries, each fingerprint the colon-separated hex Play Console prints.\n *\n * Unset (or nothing valid in it), the document answers 404: a deployment\n * with no apps of its own vouches for none.\n *\n * A leaf with no imports, because both middlewares read the paths below.\n *=========================================*/\n\n/** Where Apple's verifier reads the association file: no `.json` suffix. */\nexport const APPLE_APP_SITE_ASSOCIATION_PATH = '/.well-known/apple-app-site-association'\n\n/** Where Google's verifier reads the statement list. */\nexport const ASSET_LINKS_PATH = '/.well-known/assetlinks.json'\n\n/**\n * The route handlers each middleware rewrites the two public paths to. They\n * live under `/api` because both apps keep their route handlers there, and\n * neither middleware runs again on `/api`.\n */\nexport const NATIVE_APP_ASSOCIATION_ROUTES: Readonly<Record<string, string>> = {\n [APPLE_APP_SITE_ASSOCIATION_PATH]: '/api/native-app-association/apple-app-site-association',\n [ASSET_LINKS_PATH]: '/api/native-app-association/assetlinks',\n}\n\n/** The route handler a public association path is served by, or null. */\nexport function nativeAppAssociationRoute(pathname: string): string | null {\n return Object.prototype.hasOwnProperty.call(NATIVE_APP_ASSOCIATION_ROUTES, pathname)\n ? NATIVE_APP_ASSOCIATION_ROUTES[pathname]\n : null\n}\n\n/**\n * The console's top-level sections the native apps have no screen for, so a\n * link to one stays in the browser: the sign-in page and SSO (the system\n * auth session opens them for the app, and a universal link there would loop\n * back into the app), the native hand-off and other `/auth` pages, the\n * sign-out page, the site admin bar's connect page, a plugin's public\n * device pages, a site's photo link (`/p/<linkId>`, opened on a phone\n * by someone with no account) and the connector consent page\n * (`/oauth/authorize`, AGL-4225), which an app such as Claude opens in the\n * browser and expects to finish there. The sections the apps finish natively are\n * {@link NATIVE_AUTH_LINK_SEGMENTS}.\n *\n * The rest of the console's top-level sections (`admin`, `billing`,\n * `manage`, `support`) and every workspace path are what the native\n * deep-link grammar resolves (`DeepLinks.swift`, `DeepLinks.kt`): a\n * registered screen, the Besigner in the app's own web view, or the nearest\n * native screen. `apps/console/specs/native-app-association.spec.ts` holds\n * this list to the console's route set and the native link specs.\n */\nexport const NATIVE_WEB_ONLY_TOP_LEVEL_SEGMENTS: readonly string[] = [\n 'auth',\n 'edit-access',\n 'kiosk',\n 'oauth',\n 'p',\n 'signin',\n 'signout',\n 'sso',\n]\n\n/**\n * The pre-sign-in sections whose exact page the apps finish natively: sign-up\n * (with its `?plan=`), an emailed verification link, an emailed password\n * reset and account recovery (`AuthFlow.swift`, `AuthFlow.kt`). Only the page\n * itself opens the app; anything under it stays in the browser, where the\n * console handles it. Android's App Link filter claims the same console paths\n * as {@link consoleAppLinksComponents}, refusing each exclusion in its manifest\n * (`native-app-association.spec.ts` holds the two together, AGL-4059).\n */\nexport const NATIVE_AUTH_LINK_SEGMENTS: readonly string[] = [\n 'account-recovery',\n 'reset-password',\n 'signup',\n 'verify-email',\n]\n\n/** One `applinks` component: a URL path pattern, optionally excluded. */\nexport interface AppLinksComponent {\n '/': string\n exclude?: true\n comment?: string\n}\n\n/**\n * The console paths the apps open, as `applinks` components. Apple reads\n * them in order and the first match wins, so every exclusion comes ahead of\n * the closing catch-all.\n */\nexport function consoleAppLinksComponents(): AppLinksComponent[] {\n const excluded: AppLinksComponent[] = [\n { '/': '/_*', exclude: true, comment: 'framework and internal paths' },\n { '/': '/api', exclude: true },\n { '/': '/api/*', exclude: true, comment: 'route handlers' },\n { '/': '/.well-known/*', exclude: true },\n ]\n for (const segment of NATIVE_WEB_ONLY_TOP_LEVEL_SEGMENTS) {\n excluded.push({ '/': `/${segment}`, exclude: true }, { '/': `/${segment}/*`, exclude: true })\n }\n for (const segment of NATIVE_AUTH_LINK_SEGMENTS) {\n excluded.push({ '/': `/${segment}/*`, exclude: true })\n }\n return [\n ...excluded,\n { '/': '/*', comment: 'workspace, site, account, billing, support and staff pages' },\n ]\n}\n\n/** `TEAMID1234.com.example.app`: a 10-character team id, then a bundle id. */\nconst APPLE_APP_ID = /^[A-Z0-9]{10}\\.[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)+$/\n\n/** A Java package name: dot-separated identifiers, at least two. */\nconst ANDROID_PACKAGE = /^[A-Za-z][A-Za-z0-9_]*(\\.[A-Za-z][A-Za-z0-9_]*)+$/\n\n/** A SHA-256 certificate fingerprint as 32 colon-separated hex pairs. */\nconst SHA256_FINGERPRINT = /^([0-9A-F]{2}:){31}[0-9A-F]{2}$/\n\n/** The Apple app ids in `NATIVE_APPLE_APP_IDS`, in order; invalid ones dropped. */\nexport function parseAppleAppIds(raw: string | undefined): string[] {\n const ids = (raw ?? '')\n .split(',')\n .map((value) => value.trim())\n .filter((value) => APPLE_APP_ID.test(value))\n return [...new Set(ids)]\n}\n\n/** One Android app and the signing certificates it may be verified by. */\nexport interface AndroidAppAssociation {\n packageName: string\n sha256Fingerprints: string[]\n}\n\n/**\n * The Android apps in `NATIVE_ANDROID_APPS`. An entry without a valid package\n * or without one valid fingerprint is dropped whole: a statement with no\n * certificate verifies nothing.\n */\nexport function parseAndroidApps(raw: string | undefined): AndroidAppAssociation[] {\n const apps: AndroidAppAssociation[] = []\n for (const entry of (raw ?? '').split(';')) {\n const at = entry.indexOf('=')\n if (at < 0) continue\n const packageName = entry.slice(0, at).trim()\n if (!ANDROID_PACKAGE.test(packageName)) continue\n if (apps.some((app) => app.packageName === packageName)) continue\n const fingerprints = entry\n .slice(at + 1)\n .split(',')\n .map((value) => value.trim().toUpperCase())\n .filter((value) => SHA256_FINGERPRINT.test(value))\n if (fingerprints.length === 0) continue\n apps.push({ packageName, sha256Fingerprints: [...new Set(fingerprints)] })\n }\n return apps\n}\n\n/** The `apple-app-site-association` document Apple's CDN reads. */\nexport interface AppleAppSiteAssociation {\n applinks?: {\n apps: []\n details: Array<{ appIDs: string[]; components: AppLinksComponent[] }>\n }\n webcredentials: { apps: string[] }\n}\n\n/**\n * The association file for these app ids. `applinks` is only for a host\n * whose paths the native deep-link grammar resolves: the console. A host\n * that serves the passkey relying party alone gets `webcredentials` only.\n *\n * One `details` entry per app, in the configured order, because when two\n * installed apps claim the same path the system takes the first.\n */\nexport function appleAppSiteAssociation(\n appIds: string[],\n options: { applinks: boolean },\n): AppleAppSiteAssociation {\n const document: AppleAppSiteAssociation = { webcredentials: { apps: [...appIds] } }\n if (options.applinks) {\n const components = consoleAppLinksComponents()\n document.applinks = {\n apps: [],\n details: appIds.map((appId) => ({ appIDs: [appId], components })),\n }\n }\n return document\n}\n\n/** One Digital Asset Links statement. */\nexport interface AssetLinkStatement {\n relation: string[]\n target: { namespace: 'android_app'; package_name: string; sha256_cert_fingerprints: string[] }\n}\n\n/** Passkeys and app links, for every configured app. */\nexport const ASSET_LINK_RELATIONS = [\n 'delegate_permission/common.handle_all_urls',\n 'delegate_permission/common.get_login_creds',\n] as const\n\n/** The `assetlinks.json` statement list Google's verifier reads. */\nexport function assetLinks(apps: AndroidAppAssociation[]): AssetLinkStatement[] {\n return apps.map((app) => ({\n relation: [...ASSET_LINK_RELATIONS],\n target: {\n namespace: 'android_app',\n package_name: app.packageName,\n sha256_cert_fingerprints: [...app.sha256Fingerprints],\n },\n }))\n}\n\n/** The request's hostname: lowercase, no port. */\nexport function requestHostname(host: string | null | undefined): string {\n return (host ?? '').trim().toLowerCase().replace(/:\\d+$/, '')\n}\n\n/** A URL's hostname, or null when it is not one. */\nexport function hostnameOfUrl(url: string | null | undefined): string | null {\n if (!url) return null\n try {\n return new URL(url).hostname.toLowerCase() || null\n } catch {\n return null\n }\n}\n\n/** What a route handler needs to answer one of the two documents. */\nexport interface NativeAppAssociationRequest {\n /** The request's `Host` header. */\n host: string | null\n /**\n * The hostnames this deployment vouches for. Every other host an app\n * serves (a customer's custom domain, a workspace subdomain, a white-label\n * console) answers 404, because the apps are this deployment's and not\n * theirs.\n */\n servedHosts: ReadonlyArray<string | null | undefined>\n /** Whether this host's paths are console links the apps resolve. */\n applinks: boolean\n /** The environment; `process.env` in the routes, a fixture in specs. */\n env: Readonly<Record<string, string | undefined>>\n}\n\n/** Short on purpose: Apple's CDN caches on top, and a fix must land within minutes. */\nconst CACHE_CONTROL = 'public, max-age=300, s-maxage=300'\n\n/**\n * Whether this host may answer. A Vercel preview deployment is reachable only\n * at the platform's own generated hostnames, so it answers on any host, which\n * is what lets a preview be checked before it is promoted.\n */\nfunction servesHost(request: NativeAppAssociationRequest): boolean {\n if (request.env['VERCEL_ENV'] === 'preview') return true\n const hostname = requestHostname(request.host)\n if (!hostname) return false\n return request.servedHosts.some((served) => requestHostname(served) === hostname)\n}\n\nfunction notFound(): Response {\n return new Response('Not Found', {\n status: 404,\n headers: { 'content-type': 'text/plain; charset=utf-8', 'cache-control': CACHE_CONTROL },\n })\n}\n\nfunction json(body: unknown): Response {\n return new Response(JSON.stringify(body), {\n status: 200,\n headers: { 'content-type': 'application/json', 'cache-control': CACHE_CONTROL },\n })\n}\n\n/** `GET /.well-known/apple-app-site-association`. */\nexport function appleAppSiteAssociationResponse(request: NativeAppAssociationRequest): Response {\n const appIds = parseAppleAppIds(request.env['NATIVE_APPLE_APP_IDS'])\n if (appIds.length === 0 || !servesHost(request)) return notFound()\n return json(appleAppSiteAssociation(appIds, { applinks: request.applinks }))\n}\n\n/** `GET /.well-known/assetlinks.json`. */\nexport function assetLinksResponse(request: NativeAppAssociationRequest): Response {\n const apps = parseAndroidApps(request.env['NATIVE_ANDROID_APPS'])\n if (apps.length === 0 || !servesHost(request)) return notFound()\n return json(assetLinks(apps))\n}\n"],"names":["APPLE_APP_SITE_ASSOCIATION_PATH","ASSET_LINKS_PATH","NATIVE_APP_ASSOCIATION_ROUTES","nativeAppAssociationRoute","pathname","Object","prototype","hasOwnProperty","call","NATIVE_WEB_ONLY_TOP_LEVEL_SEGMENTS","NATIVE_AUTH_LINK_SEGMENTS","consoleAppLinksComponents","excluded","exclude","comment","segment","push","APPLE_APP_ID","ANDROID_PACKAGE","SHA256_FINGERPRINT","parseAppleAppIds","raw","ids","split","map","value","trim","filter","test","Set","parseAndroidApps","apps","entry","at","indexOf","packageName","slice","some","app","fingerprints","toUpperCase","length","sha256Fingerprints","appleAppSiteAssociation","appIds","options","document","webcredentials","applinks","components","details","appId","appIDs","ASSET_LINK_RELATIONS","assetLinks","relation","target","namespace","package_name","sha256_cert_fingerprints","requestHostname","host","toLowerCase","replace","hostnameOfUrl","url","URL","hostname","CACHE_CONTROL","servesHost","request","env","servedHosts","served","notFound","Response","status","headers","json","body","JSON","stringify","appleAppSiteAssociationResponse","assetLinksResponse"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;2CAoB2C,GAE3C,0EAA0E,GAC1E,OAAO,MAAMA,kCAA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,IAAIJ,SAASK,KAAKC,SAAS,CAACF,OAAO;QACxCH,QAAQ;QACRC,SAAS;YAAE,gBAAgB;YAAoB,iBAAiBT;QAAc;IAChF;AACF;AAEA,mDAAmD,GACnD,OAAO,SAASc,gCAAgCZ,OAAoC;IAClF,MAAM1B,SAASxB,iBAAiBkD,QAAQC,GAAG,CAAC,uBAAuB;IACnE,IAAI3B,OAAOH,MAAM,KAAK,KAAK,CAAC4B,WAAWC,UAAU,OAAOI;IACxD,OAAOI,KAAKnC,wBAAwBC,QAAQ;QAAEI,UAAUsB,QAAQtB,QAAQ;IAAC;AAC3E;AAEA,wCAAwC,GACxC,OAAO,SAASmC,mBAAmBb,OAAoC;IACrE,MAAMvC,OAAOD,iBAAiBwC,QAAQC,GAAG,CAAC,sBAAsB;IAChE,IAAIxC,KAAKU,MAAM,KAAK,KAAK,CAAC4B,WAAWC,UAAU,OAAOI;IACtD,OAAOI,KAAKxB,WAAWvB;AACzB"}
|
|
@@ -478,7 +478,7 @@ const SITE_SETTINGS = {
|
|
|
478
478
|
label: 'Setup',
|
|
479
479
|
foldable: false,
|
|
480
480
|
rows: ordered([
|
|
481
|
-
setupRow('details', 'Basic details', ICONS.details, 'Logo,
|
|
481
|
+
setupRow('details', 'Basic details', ICONS.details, 'Logo, layout and languages'),
|
|
482
482
|
setupRow('business', 'Business profile', ICONS.business, 'What the business is, for everything that writes about it'),
|
|
483
483
|
setupRow('seo', 'SEO', ICONS.seo, 'Search title, social image, business profile and verification', [
|
|
484
484
|
'search'
|