@aglyn/tenant-data-admin 1.0.0-beta.269 → 1.0.0-beta.271

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.
Files changed (77) hide show
  1. package/package.json +7 -7
  2. package/src/lib/render-cache.d.ts +10 -3
  3. package/src/lib/render-cache.js +10 -3
  4. package/src/lib/render-cache.js.map +1 -1
  5. package/src/lib/server/append-only-history-write.d.ts +38 -0
  6. package/src/lib/server/append-only-history-write.js +60 -0
  7. package/src/lib/server/append-only-history-write.js.map +1 -0
  8. package/src/lib/server/billing-addons.d.ts +58 -30
  9. package/src/lib/server/billing-addons.js +102 -77
  10. package/src/lib/server/billing-addons.js.map +1 -1
  11. package/src/lib/server/bundle-links.d.ts +166 -0
  12. package/src/lib/server/bundle-links.js +286 -0
  13. package/src/lib/server/bundle-links.js.map +1 -0
  14. package/src/lib/server/client-build.d.ts +74 -0
  15. package/src/lib/server/client-build.js +264 -0
  16. package/src/lib/server/client-build.js.map +1 -0
  17. package/src/lib/server/configured-url-fetch.d.ts +26 -0
  18. package/src/lib/server/configured-url-fetch.js +68 -0
  19. package/src/lib/server/configured-url-fetch.js.map +1 -1
  20. package/src/lib/server/custom-domain-redirects.d.ts +50 -0
  21. package/src/lib/server/custom-domain-redirects.js +61 -0
  22. package/src/lib/server/custom-domain-redirects.js.map +1 -0
  23. package/src/lib/server/host-custom-domain.d.ts +125 -0
  24. package/src/lib/server/host-custom-domain.js +395 -0
  25. package/src/lib/server/host-custom-domain.js.map +1 -0
  26. package/src/lib/server/host-memberships.d.ts +35 -2
  27. package/src/lib/server/host-memberships.js +63 -2
  28. package/src/lib/server/host-memberships.js.map +1 -1
  29. package/src/lib/server/host-released-names.d.ts +1 -2
  30. package/src/lib/server/host-released-names.js +4 -2
  31. package/src/lib/server/host-released-names.js.map +1 -1
  32. package/src/lib/server/media-photo-links.d.ts +196 -0
  33. package/src/lib/server/media-photo-links.js +290 -0
  34. package/src/lib/server/media-photo-links.js.map +1 -0
  35. package/src/lib/server/org-billing.d.ts +4 -2
  36. package/src/lib/server/org-billing.js +5 -0
  37. package/src/lib/server/org-billing.js.map +1 -1
  38. package/src/lib/server/organizations.d.ts +25 -1
  39. package/src/lib/server/organizations.js +62 -2
  40. package/src/lib/server/organizations.js.map +1 -1
  41. package/src/lib/server/personal-data-export.js +21 -1
  42. package/src/lib/server/personal-data-export.js.map +1 -1
  43. package/src/lib/server/push-delivery.js +32 -14
  44. package/src/lib/server/push-delivery.js.map +1 -1
  45. package/src/lib/server/site-care-emails.d.ts +52 -0
  46. package/src/lib/server/site-care-emails.js +97 -0
  47. package/src/lib/server/site-care-emails.js.map +1 -0
  48. package/src/lib/server/site-care-inbound.d.ts +80 -0
  49. package/src/lib/server/site-care-inbound.js +171 -0
  50. package/src/lib/server/site-care-inbound.js.map +1 -0
  51. package/src/lib/server/site-care-project-reconcile.d.ts +64 -0
  52. package/src/lib/server/site-care-project-reconcile.js +211 -0
  53. package/src/lib/server/site-care-project-reconcile.js.map +1 -0
  54. package/src/lib/server/site-care-project-stripe.d.ts +114 -0
  55. package/src/lib/server/site-care-project-stripe.js +305 -0
  56. package/src/lib/server/site-care-project-stripe.js.map +1 -0
  57. package/src/lib/server/site-care-projects.d.ts +169 -0
  58. package/src/lib/server/site-care-projects.js +882 -0
  59. package/src/lib/server/site-care-projects.js.map +1 -0
  60. package/src/lib/server/site-care-reconcile.d.ts +81 -0
  61. package/src/lib/server/site-care-reconcile.js +349 -0
  62. package/src/lib/server/site-care-reconcile.js.map +1 -0
  63. package/src/lib/server/site-care-requests.d.ts +243 -0
  64. package/src/lib/server/site-care-requests.js +1414 -0
  65. package/src/lib/server/site-care-requests.js.map +1 -0
  66. package/src/lib/server/site-care-stripe.d.ts +175 -0
  67. package/src/lib/server/site-care-stripe.js +375 -0
  68. package/src/lib/server/site-care-stripe.js.map +1 -0
  69. package/src/lib/server/tenant-dns-check.d.ts +58 -0
  70. package/src/lib/server/tenant-dns-check.js +197 -0
  71. package/src/lib/server/tenant-dns-check.js.map +1 -0
  72. package/src/lib/server/upgrade-proposal.d.ts +40 -1
  73. package/src/lib/server/upgrade-proposal.js +92 -50
  74. package/src/lib/server/upgrade-proposal.js.map +1 -1
  75. package/src/tenancy.d.ts +5 -0
  76. package/src/tenancy.js +10 -0
  77. package/src/tenancy.js.map +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../libs/tenant/data/admin/src/lib/server/custom-domain-redirects.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 { TENANT_APEX } from '@aglyn/aglyn/app-utils/tenant-apex'\nimport { attachProjectDomain } from './workspace-domains'\n\n/*\n * The two redirects a connected custom domain registers on the tenant\n * deployment (AGL-3961). Kept apart from `host-custom-domain.ts`, which owns\n * the claim, so the completer cron and its spec reach them without the claim's\n * Firestore and activity imports.\n */\n\n/**\n * Registers `{subdomain}.aglyn.app` on the tenant deployment as a per-domain\n * REDIRECT to the custom domain (AGL-1273). The app-level canonical redirect\n * in `loadPageData` is baked into an ISR entry keyed on pathname, so it\n * structurally cannot carry the query string — a campaign that pointed at the\n * platform subdomain lost its `utm_*` on the hop. The edge redirect preserves\n * path AND query at zero runtime cost, and the app-level redirect stays as the\n * fallback wherever the provider cannot express a redirect at all.\n *\n * A redirect is a REGISTRATION, not a special case: create the name carrying\n * the redirect, or point an existing entry at the new target. Both halves live\n * in the provider, so a name already on the deployment gets its redirect\n * applied rather than being read as \"already done\" — an entry left serving\n * instead of forwarding is a second live copy of the site on a name that was\n * supposed to hand visitors to the custom domain.\n *\n * Best-effort BY DESIGN: the custom domain is already attached by the time\n * this runs, and a redirect-registration failure must not unwind that. A\n * failure sets `subdomainRedirectPending` so the gap is visible and the\n * completer cron (`/api/admin/finish-domain-attachments`) can close it.\n */\nexport async function upsertSubdomainRedirect(options: {\n subdomain: string\n target: string\n}): Promise<boolean> {\n const { subdomain, target } = options\n const result = await attachProjectDomain(\n `${subdomain}.${TENANT_APEX}`,\n { redirectTo: target },\n 'tenant',\n )\n return result.outcome === 'attached' || result.outcome === 'already-exists'\n}\n\n/**\n * Registers the twin as a redirect to the primary. Best-effort for the same\n * reason the subdomain redirect is: the primary serves either way, and a twin\n * that did not land is recorded as `cnameTwinPending` for the completer.\n */\nexport async function upsertCustomDomainTwin(options: {\n twin: string\n target: string\n}): Promise<boolean> {\n const result = await attachProjectDomain(\n options.twin,\n { redirectTo: options.target },\n 'tenant',\n )\n return result.outcome === 'attached' || result.outcome === 'already-exists'\n}\n\n"],"names":["TENANT_APEX","attachProjectDomain","upsertSubdomainRedirect","options","subdomain","target","result","redirectTo","outcome","upsertCustomDomainTwin","twin"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,WAAW,QAAQ,qCAAoC;AAChE,SAASC,mBAAmB,QAAQ,yBAAqB;AAEzD;;;;;CAKC,GAED;;;;;;;;;;;;;;;;;;;;CAoBC,GACD,OAAO,eAAeC,wBAAwBC,OAG7C;IACC,MAAM,EAAEC,SAAS,EAAEC,MAAM,EAAE,GAAGF;IAC9B,MAAMG,SAAS,MAAML,oBACnB,GAAGG,UAAU,CAAC,EAAEJ,aAAa,EAC7B;QAAEO,YAAYF;IAAO,GACrB;IAEF,OAAOC,OAAOE,OAAO,KAAK,cAAcF,OAAOE,OAAO,KAAK;AAC7D;AAEA;;;;CAIC,GACD,OAAO,eAAeC,uBAAuBN,OAG5C;IACC,MAAMG,SAAS,MAAML,oBACnBE,QAAQO,IAAI,EACZ;QAAEH,YAAYJ,QAAQE,MAAM;IAAC,GAC7B;IAEF,OAAOC,OAAOE,OAAO,KAAK,cAAcF,OAAOE,OAAO,KAAK;AAC7D"}
@@ -0,0 +1,125 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import type { HostActivityActor } from '@aglyn/aglyn/app-utils/activity-presenter';
18
+ import { type ProjectDomainState, type ProjectDomainStatus } from './domain-provider';
19
+ /**
20
+ * CONNECTING A NAME TO A SITE, as one server function (AGL-3961).
21
+ *
22
+ * This is the sequence `/api/domains/attach` ran inline: claim the name in a
23
+ * transaction, attach it to the tenant deployment, probe what the platform
24
+ * actually did, record the shortfall, point the platform subdomain at it, log
25
+ * it, and tell plugins. It lives here so a caller with no ID token — a plugin
26
+ * that bought the name, a sweeper finishing an order — connects a domain
27
+ * through exactly the same claim the customer's own button uses. A second copy
28
+ * of the claim is how two sites end up holding one name (AGL-743).
29
+ *
30
+ * Authorization is the CALLER's: the route checks the admin role, lockdown and
31
+ * the plan before it gets here, and a plugin checks its own. This function
32
+ * assumes the caller may connect `domain` to `hostId` and that `domain` has
33
+ * already been through `validatePlatformDomain`.
34
+ *
35
+ * ## The twin
36
+ *
37
+ * `twin` is the `www.`/apex partner of the domain, served as a REDIRECT to it
38
+ * (AGL-1311 memo §5.2). It is opt-in, because only a caller that writes the
39
+ * twin's DNS can promise it resolves: a bought domain, or a provider applying
40
+ * a Domain Connect template. The manual card connects one name, as before.
41
+ *
42
+ * The twin is claimed in the SAME transaction as the primary and is checked
43
+ * against every other site's primary AND twin, both ways round. Without that,
44
+ * org B could connect org A's `www.` sibling, the attach would answer
45
+ * `already-exists`, and B would be shown a healthy domain that redirects to
46
+ * A's site.
47
+ */
48
+ /** Firestore field holding the redirect twin of `cname`. */
49
+ export declare const HOST_CNAME_TWIN_FIELD = "cnameTwin";
50
+ export interface ConnectHostDomainInput {
51
+ hostId: string;
52
+ /** Lowercased and validated by `validatePlatformDomain`. */
53
+ domain: string;
54
+ actor: HostActivityActor;
55
+ /**
56
+ * The `www.`/apex partner to serve as a redirect to `domain`. Must be
57
+ * `www.<domain>` or the name `domain` is `www.` of.
58
+ */
59
+ twin?: string | null;
60
+ }
61
+ export type ConnectHostDomainResult = {
62
+ ok: 'connected';
63
+ state: ProjectDomainState;
64
+ verification: ProjectDomainStatus['verification'];
65
+ conflicts: ProjectDomainStatus['conflicts'];
66
+ /** The twin this connect claimed, or null. */
67
+ twin: string | null;
68
+ } | {
69
+ ok: 'refused';
70
+ /** The HTTP status a route should answer with. */
71
+ status: 404 | 409 | 501 | 502;
72
+ /** Customer-facing copy, unchanged from the route that owned it. */
73
+ error: string;
74
+ code: 'unknown-site' | 'taken' | 'not-configured' | 'attach-failed' | 'held-elsewhere';
75
+ state?: ProjectDomainState;
76
+ };
77
+ /**
78
+ * The redirect twin a domain may carry: `www.x` ↔ `x`. Null for anything else,
79
+ * because a twin is a name reserved on the site's behalf and a guess in either
80
+ * direction locks another site out of a name it never chose.
81
+ */
82
+ export declare function customDomainTwinOf(domain: string, twin: string): boolean;
83
+ /** Claims, attaches and finishes `domain` for `hostId`. Never throws. */
84
+ export declare function connectHostCustomDomain(input: ConnectHostDomainInput): Promise<ConnectHostDomainResult>;
85
+ /**
86
+ * Releases a site's twin from the tenant deployment. The primary has its own
87
+ * release in `/api/domains/detach`; the twin rides along so it can never
88
+ * outlive the name it forwards to.
89
+ */
90
+ export declare function releaseCustomDomainTwin(twin: string | null | undefined): Promise<boolean>;
91
+ export type DisconnectHostDomainResult = {
92
+ ok: 'released';
93
+ /** The name released, for the caller's cache work. */
94
+ domain: string;
95
+ /** The site's platform subdomain, which serves again. */
96
+ subdomain: string;
97
+ }
98
+ /** Nothing to release: the caller's desired end state already holds. */
99
+ | {
100
+ ok: 'already-clear';
101
+ } | {
102
+ ok: 'refused';
103
+ status: 404 | 502;
104
+ code: 'unknown-site' | 'detach-failed';
105
+ error: string;
106
+ };
107
+ /**
108
+ * Releases a site's custom domain (AGL-742): removes it from the tenant
109
+ * deployment, puts the platform subdomain back to serving, releases the twin,
110
+ * clears the claim, logs it and tells plugins — the sequence
111
+ * `/api/domains/detach` ran inline, here so a plugin can release a name it
112
+ * bought once that name stops being the site's (it expired, or moved away).
113
+ *
114
+ * Deliberately does NOT touch DNS: a connected domain's records live in the
115
+ * customer's own zone.
116
+ *
117
+ * Cache work is the caller's, after this returns: the console's
118
+ * `revalidateHostAliases` drops the tenant's `cname--` alias entry, and a
119
+ * caller without it degrades to the cache's TTL.
120
+ */
121
+ export declare function disconnectHostCustomDomain(input: {
122
+ hostId: string;
123
+ actor: HostActivityActor;
124
+ reason?: 'detached' | 'site-deleted';
125
+ }): Promise<DisconnectHostDomainResult>;
@@ -0,0 +1,395 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ import { TENANT_APEX } from "@aglyn/aglyn/app-utils/tenant-apex";
17
+ import { runPluginEventHandlers } from "@aglyn/aglyn/plugin-manager/plugin-events";
18
+ import { domainProvider, domainStateServes } from "./domain-provider.js";
19
+ import firebaseAdmin from "./firebase-admin.js";
20
+ import { flagLookalikeCustomDomain } from "./hosted-page-review.js";
21
+ import { syncHostProjectionForMembers } from "./host-memberships.js";
22
+ import { upsertCustomDomainTwin, upsertSubdomainRedirect } from "./custom-domain-redirects.js";
23
+ import { logHostActivity } from "./organizations.js";
24
+ import { attachProjectDomain, detachProjectDomain, projectDomainStatus } from "./workspace-domains.js";
25
+ /**
26
+ * CONNECTING A NAME TO A SITE, as one server function (AGL-3961).
27
+ *
28
+ * This is the sequence `/api/domains/attach` ran inline: claim the name in a
29
+ * transaction, attach it to the tenant deployment, probe what the platform
30
+ * actually did, record the shortfall, point the platform subdomain at it, log
31
+ * it, and tell plugins. It lives here so a caller with no ID token — a plugin
32
+ * that bought the name, a sweeper finishing an order — connects a domain
33
+ * through exactly the same claim the customer's own button uses. A second copy
34
+ * of the claim is how two sites end up holding one name (AGL-743).
35
+ *
36
+ * Authorization is the CALLER's: the route checks the admin role, lockdown and
37
+ * the plan before it gets here, and a plugin checks its own. This function
38
+ * assumes the caller may connect `domain` to `hostId` and that `domain` has
39
+ * already been through `validatePlatformDomain`.
40
+ *
41
+ * ## The twin
42
+ *
43
+ * `twin` is the `www.`/apex partner of the domain, served as a REDIRECT to it
44
+ * (AGL-1311 memo §5.2). It is opt-in, because only a caller that writes the
45
+ * twin's DNS can promise it resolves: a bought domain, or a provider applying
46
+ * a Domain Connect template. The manual card connects one name, as before.
47
+ *
48
+ * The twin is claimed in the SAME transaction as the primary and is checked
49
+ * against every other site's primary AND twin, both ways round. Without that,
50
+ * org B could connect org A's `www.` sibling, the attach would answer
51
+ * `already-exists`, and B would be shown a healthy domain that redirects to
52
+ * A's site.
53
+ */ /** Firestore field holding the redirect twin of `cname`. */ export const HOST_CNAME_TWIN_FIELD = 'cnameTwin';
54
+ const NOT_CONFIGURED = 'Domain attachment is not configured on this deployment ' + '(no domain provider — set AGLYN_DOMAIN_PROVIDER).';
55
+ /**
56
+ * The redirect twin a domain may carry: `www.x` ↔ `x`. Null for anything else,
57
+ * because a twin is a name reserved on the site's behalf and a guess in either
58
+ * direction locks another site out of a name it never chose.
59
+ */ export function customDomainTwinOf(domain, twin) {
60
+ const primary = domain.trim().toLowerCase();
61
+ const other = twin.trim().toLowerCase();
62
+ if (!primary || !other || primary === other) return false;
63
+ return other === `www.${primary}` || primary === `www.${other}`;
64
+ }
65
+ /** Every other site that holds `name` as its primary or its twin. */ async function holdersOf(tx, firestore, name) {
66
+ const [asPrimary, asTwin] = await Promise.all([
67
+ tx.get(firestore.collection('hosts').where('cname', '==', name).limit(2)),
68
+ tx.get(firestore.collection('hosts').where(HOST_CNAME_TWIN_FIELD, '==', name).limit(2))
69
+ ]);
70
+ return [
71
+ ...asPrimary.docs,
72
+ ...asTwin.docs
73
+ ].map((snapshot)=>snapshot.id);
74
+ }
75
+ /** Claims, attaches and finishes `domain` for `hostId`. Never throws. */ export async function connectHostCustomDomain(input) {
76
+ var _hostSnapshot_get, _hostSnapshot_get1;
77
+ const { hostId, domain, actor } = input;
78
+ const twin = input.twin && customDomainTwinOf(domain, input.twin) ? input.twin.trim().toLowerCase() : null;
79
+ const firestore = firebaseAdmin.app().firestore();
80
+ const hostRef = firestore.collection('hosts').doc(hostId);
81
+ const hostSnapshot = await hostRef.get();
82
+ if (!hostSnapshot.exists) {
83
+ return {
84
+ ok: 'refused',
85
+ status: 404,
86
+ code: 'unknown-site',
87
+ error: 'Unknown site'
88
+ };
89
+ }
90
+ const orgId = String((_hostSnapshot_get = hostSnapshot.get('orgId')) != null ? _hostSnapshot_get : '');
91
+ // Claiming the domain and persisting `host.cname` happen in ONE
92
+ // transaction (AGL-743). The write used to be a client-side `updateDoc`
93
+ // that ran BEFORE this check, so losing the 409 still left the losing host
94
+ // holding the domain — and `get-host.ts` then resolved the duplicate by
95
+ // Firestore document order, i.e. one org could be served on another org's
96
+ // domain. A cross-document invariant cannot be enforced from the client, so
97
+ // this is the only writer of `cname`.
98
+ const claimed = await firestore.runTransaction(async (tx)=>{
99
+ const names = twin ? [
100
+ domain,
101
+ twin
102
+ ] : [
103
+ domain
104
+ ];
105
+ for (const name of names){
106
+ const holders = await holdersOf(tx, firestore, name);
107
+ if (holders.some((id)=>id !== hostId)) return false;
108
+ }
109
+ tx.set(hostRef, {
110
+ cname: domain,
111
+ [HOST_CNAME_TWIN_FIELD]: twin != null ? twin : firebaseAdmin.firestore.FieldValue.delete()
112
+ }, {
113
+ merge: true
114
+ });
115
+ return true;
116
+ });
117
+ if (!claimed) {
118
+ return {
119
+ ok: 'refused',
120
+ status: 409,
121
+ code: 'taken',
122
+ error: 'That domain is already connected to another site'
123
+ };
124
+ }
125
+ // Every member's row of this site carries the domain for the Sites list's
126
+ // search and its Custom domain filter (AGL-3321, `membershipRow`), so the
127
+ // rows follow the write. Best-effort, as the rename's re-sync is: a row
128
+ // left behind is re-derived by the next re-sync of this site.
129
+ if (orgId) {
130
+ await syncHostProjectionForMembers(orgId, hostId).catch(()=>undefined);
131
+ }
132
+ // A domain that wears a brand (`paypal-secure.com`) goes to staff in the
133
+ // abuse queue — flagged, not refused (AGL-3356). Never throws.
134
+ await flagLookalikeCustomDomain({
135
+ hostId,
136
+ orgId: orgId || null,
137
+ domain
138
+ });
139
+ const markPending = ()=>hostRef.set({
140
+ cnameAttachmentPending: true
141
+ }, {
142
+ merge: true
143
+ }).catch(()=>undefined);
144
+ // Ask the provider whether this deployment can register a name at all,
145
+ // rather than testing one vendor's credentials. A self-host behind its own
146
+ // proxy answers yes; a deployment that leaves names to somebody else
147
+ // answers no, and the wizard says so instead of reporting an outage.
148
+ if (!domainProvider().configured('tenant')) {
149
+ // Backfill path (AGL-166): remember the attachment never happened so the
150
+ // wizard can show it honestly and offer a retry.
151
+ await markPending();
152
+ return {
153
+ ok: 'refused',
154
+ status: 501,
155
+ code: 'not-configured',
156
+ error: NOT_CONFIGURED
157
+ };
158
+ }
159
+ // The `already-exists` tolerance lives in the provider, not here: a name
160
+ // already registered is success for a create path and a retry alike.
161
+ const attach = await attachProjectDomain(domain, {}, 'tenant');
162
+ if (attach.outcome === 'skipped') {
163
+ // Configured, and still nothing registered — a provider that does not
164
+ // manage this particular name. Same honest answer as no provider at all.
165
+ await markPending();
166
+ return {
167
+ ok: 'refused',
168
+ status: 501,
169
+ code: 'not-configured',
170
+ error: NOT_CONFIGURED
171
+ };
172
+ }
173
+ if (attach.outcome === 'failed') {
174
+ var _attach_detail;
175
+ await markPending();
176
+ return {
177
+ ok: 'refused',
178
+ status: 502,
179
+ code: 'attach-failed',
180
+ error: (_attach_detail = attach.detail) != null ? _attach_detail : 'Attach failed at the platform'
181
+ };
182
+ }
183
+ // What the registration said is not what the customer gets (AGL-1913).
184
+ //
185
+ // - `already-exists` was tolerated above as idempotency, but it is also the
186
+ // answer when the name is registered to a DIFFERENT deployment.
187
+ // `projectDomainStatus` asks whether the name is on OUR deployment rather
188
+ // than inferring it from the tolerated outcome.
189
+ // - A provider accepts a name whose apex belongs to another account and
190
+ // then withholds routing and the certificate until a TXT challenge is
191
+ // answered.
192
+ //
193
+ // `certificate-pending` is NOT serving (AGL-1996): treating it as live
194
+ // registered the edge redirect before a certificate existed, so the site
195
+ // lost BOTH addresses. `admin/finish-domain-attachments` re-probes and
196
+ // completes it without a human (AGL-2010).
197
+ const status = await projectDomainStatus(domain, {
198
+ scope: 'tenant'
199
+ });
200
+ const serves = domainStateServes(status.state);
201
+ if (status.state === 'not-attached') {
202
+ await markPending();
203
+ return {
204
+ ok: 'refused',
205
+ status: 409,
206
+ code: 'held-elsewhere',
207
+ error: 'That domain is already registered to another account on our ' + 'hosting platform, so it could not be attached. Contact support ' + 'with the domain name.',
208
+ state: status.state
209
+ };
210
+ }
211
+ await hostRef.set({
212
+ cnameAttachmentPending: serves ? firebaseAdmin.firestore.FieldValue.delete() : // `liveCustomDomain` reads to decide whether it is safe to send
213
+ // visitors here, and a domain awaiting an ownership challenge or
214
+ // pointed elsewhere is exactly what that guard exists for.
215
+ true
216
+ }, {
217
+ merge: true
218
+ }).catch(()=>undefined);
219
+ // Query-preserving edge redirect from the platform subdomain (AGL-1273),
220
+ // only once the domain actually serves — the edge-level twin of
221
+ // `liveCustomDomain`'s refusal on `cnameAttachmentPending`.
222
+ const subdomain = String((_hostSnapshot_get1 = hostSnapshot.get('subdomain')) != null ? _hostSnapshot_get1 : '').trim().toLowerCase();
223
+ if (subdomain && serves) {
224
+ const redirected = await upsertSubdomainRedirect({
225
+ subdomain,
226
+ target: domain
227
+ }).catch(()=>false);
228
+ await hostRef.set(redirected ? {
229
+ subdomainRedirectPending: firebaseAdmin.firestore.FieldValue.delete()
230
+ } : {
231
+ subdomainRedirectPending: true
232
+ }, {
233
+ merge: true
234
+ }).catch(()=>undefined);
235
+ }
236
+ // The twin forwards to the primary, so it is registered whether or not the
237
+ // primary serves yet: a redirect to a name still issuing its certificate is
238
+ // the same wait the visitor would have on the primary itself.
239
+ if (twin) {
240
+ const twinned = await upsertCustomDomainTwin({
241
+ twin,
242
+ target: domain
243
+ }).catch(()=>false);
244
+ await hostRef.set(twinned ? {
245
+ cnameTwinPending: firebaseAdmin.firestore.FieldValue.delete()
246
+ } : {
247
+ cnameTwinPending: true
248
+ }, {
249
+ merge: true
250
+ }).catch(()=>undefined);
251
+ }
252
+ // The site's public address changed hands (AGL-118). One entry, at the
253
+ // single terminal success.
254
+ await logHostActivity(hostId, actor, 'Attached a custom domain', {
255
+ type: 'host',
256
+ id: hostId,
257
+ name: domain
258
+ });
259
+ // Plugins that register the domain somewhere of their own — commerce's
260
+ // Stripe payment method domains, so Apple Pay shows on it (AGL-3629).
261
+ // After the claim and the attach, so the name is this site's; isolated, so
262
+ // a plugin that fails cannot fail the connect.
263
+ await runPluginEventHandlers('host.domain.attached', {
264
+ orgId: orgId || null,
265
+ hostId,
266
+ domain
267
+ });
268
+ return {
269
+ ok: 'connected',
270
+ state: status.state,
271
+ verification: status.verification,
272
+ conflicts: status.conflicts,
273
+ twin
274
+ };
275
+ }
276
+ /**
277
+ * Releases a site's twin from the tenant deployment. The primary has its own
278
+ * release in `/api/domains/detach`; the twin rides along so it can never
279
+ * outlive the name it forwards to.
280
+ */ export async function releaseCustomDomainTwin(twin) {
281
+ const name = String(twin != null ? twin : '').trim().toLowerCase();
282
+ if (!name) return true;
283
+ const released = await detachProjectDomain(name, 'tenant');
284
+ return released.outcome !== 'failed';
285
+ }
286
+ /**
287
+ * Releases a site's custom domain (AGL-742): removes it from the tenant
288
+ * deployment, puts the platform subdomain back to serving, releases the twin,
289
+ * clears the claim, logs it and tells plugins — the sequence
290
+ * `/api/domains/detach` ran inline, here so a plugin can release a name it
291
+ * bought once that name stops being the site's (it expired, or moved away).
292
+ *
293
+ * Deliberately does NOT touch DNS: a connected domain's records live in the
294
+ * customer's own zone.
295
+ *
296
+ * Cache work is the caller's, after this returns: the console's
297
+ * `revalidateHostAliases` drops the tenant's `cname--` alias entry, and a
298
+ * caller without it degrades to the cache's TTL.
299
+ */ export async function disconnectHostCustomDomain(input) {
300
+ var _hostSnapshot_get, _hostSnapshot_get1, _hostSnapshot_get2, _input_reason;
301
+ const { hostId, actor } = input;
302
+ const firestore = firebaseAdmin.app().firestore();
303
+ const hostRef = firestore.collection('hosts').doc(hostId);
304
+ const hostSnapshot = await hostRef.get();
305
+ if (!hostSnapshot.exists) {
306
+ return {
307
+ ok: 'refused',
308
+ status: 404,
309
+ code: 'unknown-site',
310
+ error: 'Unknown site'
311
+ };
312
+ }
313
+ const domain = String((_hostSnapshot_get = hostSnapshot.get('cname')) != null ? _hostSnapshot_get : '').trim().toLowerCase();
314
+ if (!domain) return {
315
+ ok: 'already-clear'
316
+ };
317
+ // `not-found` is success — the desired end state already holds — mirroring
318
+ // how attach tolerates a name already registered.
319
+ const released = await detachProjectDomain(domain, 'tenant');
320
+ if (released.outcome === 'failed') {
321
+ var _released_detail;
322
+ // Recorded so a retry (and a staff view) can see a release that never
323
+ // landed; `cname` is KEPT, because the name is still attached.
324
+ await hostRef.set({
325
+ cnameDetachmentPending: true
326
+ }, {
327
+ merge: true
328
+ }).catch(()=>undefined);
329
+ return {
330
+ ok: 'refused',
331
+ status: 502,
332
+ code: 'detach-failed',
333
+ error: (_released_detail = released.detail) != null ? _released_detail : 'Detach failed at the platform'
334
+ };
335
+ }
336
+ // The platform subdomain was registered as a REDIRECT to the domain
337
+ // (AGL-1273), and the redirect is a property of its registration, so it is
338
+ // dropped with the registration and put back plain — which is what makes
339
+ // it serve again. A `not-found` means a wildcard serves it and it carried
340
+ // no redirect of its own; registering one there would create an entry
341
+ // this never removed.
342
+ const subdomain = String((_hostSnapshot_get1 = hostSnapshot.get('subdomain')) != null ? _hostSnapshot_get1 : '').trim().toLowerCase();
343
+ if (subdomain) {
344
+ const platformName = `${subdomain}.${TENANT_APEX}`;
345
+ const removed = await detachProjectDomain(platformName, 'tenant');
346
+ if (removed.outcome === 'detached') {
347
+ await attachProjectDomain(platformName, {}, 'tenant');
348
+ }
349
+ }
350
+ // The twin forwards to the name just released, so it goes with it.
351
+ // Best-effort: a twin left on the deployment redirects to a name that no
352
+ // longer serves, which is a dead end but not another site — and the claim
353
+ // below is cleared either way, so no site can be shown the name as its own.
354
+ await releaseCustomDomainTwin(hostSnapshot.get(HOST_CNAME_TWIN_FIELD)).catch(()=>false);
355
+ await hostRef.set({
356
+ cname: firebaseAdmin.firestore.FieldValue.delete(),
357
+ [HOST_CNAME_TWIN_FIELD]: firebaseAdmin.firestore.FieldValue.delete(),
358
+ cnameTwinPending: firebaseAdmin.firestore.FieldValue.delete(),
359
+ cnameAttachmentPending: firebaseAdmin.firestore.FieldValue.delete(),
360
+ cnameDetachmentPending: firebaseAdmin.firestore.FieldValue.delete(),
361
+ subdomainRedirectPending: firebaseAdmin.firestore.FieldValue.delete()
362
+ }, {
363
+ merge: true
364
+ });
365
+ // The Sites list's rows of this site drop the domain from their search and
366
+ // read "no custom domain" again (AGL-3321). Best-effort.
367
+ const orgId = String((_hostSnapshot_get2 = hostSnapshot.get('orgId')) != null ? _hostSnapshot_get2 : '');
368
+ if (orgId) {
369
+ await syncHostProjectionForMembers(orgId, hostId).catch(()=>undefined);
370
+ }
371
+ // THE EVENT IS `cname` LEAVING THE DOCUMENT (AGL-118), which is the write
372
+ // directly above — the mirror image of where connect logs. The refusals
373
+ // above write no entry: a failed release still holds the name, and a row
374
+ // there would say the customer released a domain we are still holding.
375
+ await logHostActivity(hostId, actor, 'Released the custom domain', {
376
+ type: 'host',
377
+ id: hostId,
378
+ name: domain
379
+ });
380
+ // The name no longer serves this site: plugins undo what they registered
381
+ // for it (AGL-3629), each checking no other site still serves it.
382
+ await runPluginEventHandlers('host.domain.released', {
383
+ orgId: orgId || null,
384
+ hostId,
385
+ domain,
386
+ reason: (_input_reason = input.reason) != null ? _input_reason : 'detached'
387
+ });
388
+ return {
389
+ ok: 'released',
390
+ domain,
391
+ subdomain
392
+ };
393
+ }
394
+
395
+ //# sourceMappingURL=host-custom-domain.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../libs/tenant/data/admin/src/lib/server/host-custom-domain.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 type { HostActivityActor } from '@aglyn/aglyn/app-utils/activity-presenter'\nimport { TENANT_APEX } from '@aglyn/aglyn/app-utils/tenant-apex'\nimport { runPluginEventHandlers } from '@aglyn/aglyn/plugin-manager/plugin-events'\nimport {\n domainProvider,\n domainStateServes,\n type ProjectDomainState,\n type ProjectDomainStatus,\n} from './domain-provider'\nimport firebaseAdmin from './firebase-admin'\nimport { flagLookalikeCustomDomain } from './hosted-page-review'\nimport { syncHostProjectionForMembers } from './host-memberships'\nimport {\n upsertCustomDomainTwin,\n upsertSubdomainRedirect,\n} from './custom-domain-redirects'\nimport { logHostActivity } from './organizations'\nimport {\n attachProjectDomain,\n detachProjectDomain,\n projectDomainStatus,\n} from './workspace-domains'\n\n/**\n * CONNECTING A NAME TO A SITE, as one server function (AGL-3961).\n *\n * This is the sequence `/api/domains/attach` ran inline: claim the name in a\n * transaction, attach it to the tenant deployment, probe what the platform\n * actually did, record the shortfall, point the platform subdomain at it, log\n * it, and tell plugins. It lives here so a caller with no ID token — a plugin\n * that bought the name, a sweeper finishing an order — connects a domain\n * through exactly the same claim the customer's own button uses. A second copy\n * of the claim is how two sites end up holding one name (AGL-743).\n *\n * Authorization is the CALLER's: the route checks the admin role, lockdown and\n * the plan before it gets here, and a plugin checks its own. This function\n * assumes the caller may connect `domain` to `hostId` and that `domain` has\n * already been through `validatePlatformDomain`.\n *\n * ## The twin\n *\n * `twin` is the `www.`/apex partner of the domain, served as a REDIRECT to it\n * (AGL-1311 memo §5.2). It is opt-in, because only a caller that writes the\n * twin's DNS can promise it resolves: a bought domain, or a provider applying\n * a Domain Connect template. The manual card connects one name, as before.\n *\n * The twin is claimed in the SAME transaction as the primary and is checked\n * against every other site's primary AND twin, both ways round. Without that,\n * org B could connect org A's `www.` sibling, the attach would answer\n * `already-exists`, and B would be shown a healthy domain that redirects to\n * A's site.\n */\n\n/** Firestore field holding the redirect twin of `cname`. */\nexport const HOST_CNAME_TWIN_FIELD = 'cnameTwin'\n\nexport interface ConnectHostDomainInput {\n hostId: string\n /** Lowercased and validated by `validatePlatformDomain`. */\n domain: string\n actor: HostActivityActor\n /**\n * The `www.`/apex partner to serve as a redirect to `domain`. Must be\n * `www.<domain>` or the name `domain` is `www.` of.\n */\n twin?: string | null\n}\n\nexport type ConnectHostDomainResult =\n | {\n ok: 'connected'\n state: ProjectDomainState\n verification: ProjectDomainStatus['verification']\n conflicts: ProjectDomainStatus['conflicts']\n /** The twin this connect claimed, or null. */\n twin: string | null\n }\n | {\n ok: 'refused'\n /** The HTTP status a route should answer with. */\n status: 404 | 409 | 501 | 502\n /** Customer-facing copy, unchanged from the route that owned it. */\n error: string\n code:\n | 'unknown-site'\n | 'taken'\n | 'not-configured'\n | 'attach-failed'\n | 'held-elsewhere'\n state?: ProjectDomainState\n }\n\nconst NOT_CONFIGURED =\n 'Domain attachment is not configured on this deployment ' +\n '(no domain provider — set AGLYN_DOMAIN_PROVIDER).'\n\n/**\n * The redirect twin a domain may carry: `www.x` ↔ `x`. Null for anything else,\n * because a twin is a name reserved on the site's behalf and a guess in either\n * direction locks another site out of a name it never chose.\n */\nexport function customDomainTwinOf(domain: string, twin: string): boolean {\n const primary = domain.trim().toLowerCase()\n const other = twin.trim().toLowerCase()\n if (!primary || !other || primary === other) return false\n return other === `www.${primary}` || primary === `www.${other}`\n}\n\n/** Every other site that holds `name` as its primary or its twin. */\nasync function holdersOf(\n tx: FirebaseFirestore.Transaction,\n firestore: FirebaseFirestore.Firestore,\n name: string,\n): Promise<string[]> {\n const [asPrimary, asTwin] = await Promise.all([\n tx.get(firestore.collection('hosts').where('cname', '==', name).limit(2)),\n tx.get(\n firestore\n .collection('hosts')\n .where(HOST_CNAME_TWIN_FIELD, '==', name)\n .limit(2),\n ),\n ])\n return [...asPrimary.docs, ...asTwin.docs].map((snapshot) => snapshot.id)\n}\n\n/** Claims, attaches and finishes `domain` for `hostId`. Never throws. */\nexport async function connectHostCustomDomain(\n input: ConnectHostDomainInput,\n): Promise<ConnectHostDomainResult> {\n const { hostId, domain, actor } = input\n const twin =\n input.twin && customDomainTwinOf(domain, input.twin)\n ? input.twin.trim().toLowerCase()\n : null\n const firestore = firebaseAdmin.app().firestore()\n const hostRef = firestore.collection('hosts').doc(hostId)\n const hostSnapshot = await hostRef.get()\n if (!hostSnapshot.exists) {\n return {\n ok: 'refused',\n status: 404,\n code: 'unknown-site',\n error: 'Unknown site',\n }\n }\n const orgId = String(hostSnapshot.get('orgId') ?? '')\n\n // Claiming the domain and persisting `host.cname` happen in ONE\n // transaction (AGL-743). The write used to be a client-side `updateDoc`\n // that ran BEFORE this check, so losing the 409 still left the losing host\n // holding the domain — and `get-host.ts` then resolved the duplicate by\n // Firestore document order, i.e. one org could be served on another org's\n // domain. A cross-document invariant cannot be enforced from the client, so\n // this is the only writer of `cname`.\n const claimed = await firestore.runTransaction(async (tx) => {\n const names = twin ? [domain, twin] : [domain]\n for (const name of names) {\n const holders = await holdersOf(tx, firestore, name)\n if (holders.some((id) => id !== hostId)) return false\n }\n tx.set(\n hostRef,\n {\n cname: domain,\n [HOST_CNAME_TWIN_FIELD]: twin ?? firebaseAdmin.firestore.FieldValue.delete(),\n },\n { merge: true },\n )\n return true\n })\n if (!claimed) {\n return {\n ok: 'refused',\n status: 409,\n code: 'taken',\n error: 'That domain is already connected to another site',\n }\n }\n // Every member's row of this site carries the domain for the Sites list's\n // search and its Custom domain filter (AGL-3321, `membershipRow`), so the\n // rows follow the write. Best-effort, as the rename's re-sync is: a row\n // left behind is re-derived by the next re-sync of this site.\n if (orgId) {\n await syncHostProjectionForMembers(orgId, hostId).catch(() => undefined)\n }\n // A domain that wears a brand (`paypal-secure.com`) goes to staff in the\n // abuse queue — flagged, not refused (AGL-3356). Never throws.\n await flagLookalikeCustomDomain({ hostId, orgId: orgId || null, domain })\n\n const markPending = () =>\n hostRef\n .set({ cnameAttachmentPending: true }, { merge: true })\n .catch(() => undefined)\n\n // Ask the provider whether this deployment can register a name at all,\n // rather than testing one vendor's credentials. A self-host behind its own\n // proxy answers yes; a deployment that leaves names to somebody else\n // answers no, and the wizard says so instead of reporting an outage.\n if (!domainProvider().configured('tenant')) {\n // Backfill path (AGL-166): remember the attachment never happened so the\n // wizard can show it honestly and offer a retry.\n await markPending()\n return { ok: 'refused', status: 501, code: 'not-configured', error: NOT_CONFIGURED }\n }\n\n // The `already-exists` tolerance lives in the provider, not here: a name\n // already registered is success for a create path and a retry alike.\n const attach = await attachProjectDomain(domain, {}, 'tenant')\n if (attach.outcome === 'skipped') {\n // Configured, and still nothing registered — a provider that does not\n // manage this particular name. Same honest answer as no provider at all.\n await markPending()\n return { ok: 'refused', status: 501, code: 'not-configured', error: NOT_CONFIGURED }\n }\n if (attach.outcome === 'failed') {\n await markPending()\n return {\n ok: 'refused',\n status: 502,\n code: 'attach-failed',\n error: attach.detail ?? 'Attach failed at the platform',\n }\n }\n\n // What the registration said is not what the customer gets (AGL-1913).\n //\n // - `already-exists` was tolerated above as idempotency, but it is also the\n // answer when the name is registered to a DIFFERENT deployment.\n // `projectDomainStatus` asks whether the name is on OUR deployment rather\n // than inferring it from the tolerated outcome.\n // - A provider accepts a name whose apex belongs to another account and\n // then withholds routing and the certificate until a TXT challenge is\n // answered.\n //\n // `certificate-pending` is NOT serving (AGL-1996): treating it as live\n // registered the edge redirect before a certificate existed, so the site\n // lost BOTH addresses. `admin/finish-domain-attachments` re-probes and\n // completes it without a human (AGL-2010).\n const status = await projectDomainStatus(domain, { scope: 'tenant' })\n const serves = domainStateServes(status.state)\n if (status.state === 'not-attached') {\n await markPending()\n return {\n ok: 'refused',\n status: 409,\n code: 'held-elsewhere',\n error:\n 'That domain is already registered to another account on our ' +\n 'hosting platform, so it could not be attached. Contact support ' +\n 'with the domain name.',\n state: status.state,\n }\n }\n await hostRef\n .set(\n {\n cnameAttachmentPending: serves\n ? firebaseAdmin.firestore.FieldValue.delete()\n : // Not a lie about the attach: it landed. But the field is what\n // `liveCustomDomain` reads to decide whether it is safe to send\n // visitors here, and a domain awaiting an ownership challenge or\n // pointed elsewhere is exactly what that guard exists for.\n true,\n },\n { merge: true },\n )\n .catch(() => undefined)\n\n // Query-preserving edge redirect from the platform subdomain (AGL-1273),\n // only once the domain actually serves — the edge-level twin of\n // `liveCustomDomain`'s refusal on `cnameAttachmentPending`.\n const subdomain = String(hostSnapshot.get('subdomain') ?? '')\n .trim()\n .toLowerCase()\n if (subdomain && serves) {\n const redirected = await upsertSubdomainRedirect({\n subdomain,\n target: domain,\n }).catch(() => false)\n await hostRef\n .set(\n redirected\n ? { subdomainRedirectPending: firebaseAdmin.firestore.FieldValue.delete() }\n : { subdomainRedirectPending: true },\n { merge: true },\n )\n .catch(() => undefined)\n }\n\n // The twin forwards to the primary, so it is registered whether or not the\n // primary serves yet: a redirect to a name still issuing its certificate is\n // the same wait the visitor would have on the primary itself.\n if (twin) {\n const twinned = await upsertCustomDomainTwin({ twin, target: domain }).catch(\n () => false,\n )\n await hostRef\n .set(\n twinned\n ? { cnameTwinPending: firebaseAdmin.firestore.FieldValue.delete() }\n : { cnameTwinPending: true },\n { merge: true },\n )\n .catch(() => undefined)\n }\n\n // The site's public address changed hands (AGL-118). One entry, at the\n // single terminal success.\n await logHostActivity(hostId, actor, 'Attached a custom domain', {\n type: 'host',\n id: hostId,\n name: domain,\n })\n // Plugins that register the domain somewhere of their own — commerce's\n // Stripe payment method domains, so Apple Pay shows on it (AGL-3629).\n // After the claim and the attach, so the name is this site's; isolated, so\n // a plugin that fails cannot fail the connect.\n await runPluginEventHandlers('host.domain.attached', {\n orgId: orgId || null,\n hostId,\n domain,\n })\n return {\n ok: 'connected',\n state: status.state,\n verification: status.verification,\n conflicts: status.conflicts,\n twin,\n }\n}\n\n/**\n * Releases a site's twin from the tenant deployment. The primary has its own\n * release in `/api/domains/detach`; the twin rides along so it can never\n * outlive the name it forwards to.\n */\nexport async function releaseCustomDomainTwin(\n twin: string | null | undefined,\n): Promise<boolean> {\n const name = String(twin ?? '').trim().toLowerCase()\n if (!name) return true\n const released = await detachProjectDomain(name, 'tenant')\n return released.outcome !== 'failed'\n}\n\nexport type DisconnectHostDomainResult =\n | {\n ok: 'released'\n /** The name released, for the caller's cache work. */\n domain: string\n /** The site's platform subdomain, which serves again. */\n subdomain: string\n }\n /** Nothing to release: the caller's desired end state already holds. */\n | { ok: 'already-clear' }\n | {\n ok: 'refused'\n status: 404 | 502\n code: 'unknown-site' | 'detach-failed'\n error: string\n }\n\n/**\n * Releases a site's custom domain (AGL-742): removes it from the tenant\n * deployment, puts the platform subdomain back to serving, releases the twin,\n * clears the claim, logs it and tells plugins — the sequence\n * `/api/domains/detach` ran inline, here so a plugin can release a name it\n * bought once that name stops being the site's (it expired, or moved away).\n *\n * Deliberately does NOT touch DNS: a connected domain's records live in the\n * customer's own zone.\n *\n * Cache work is the caller's, after this returns: the console's\n * `revalidateHostAliases` drops the tenant's `cname--` alias entry, and a\n * caller without it degrades to the cache's TTL.\n */\nexport async function disconnectHostCustomDomain(input: {\n hostId: string\n actor: HostActivityActor\n reason?: 'detached' | 'site-deleted'\n}): Promise<DisconnectHostDomainResult> {\n const { hostId, actor } = input\n const firestore = firebaseAdmin.app().firestore()\n const hostRef = firestore.collection('hosts').doc(hostId)\n const hostSnapshot = await hostRef.get()\n if (!hostSnapshot.exists) {\n return { ok: 'refused', status: 404, code: 'unknown-site', error: 'Unknown site' }\n }\n const domain = String(hostSnapshot.get('cname') ?? '')\n .trim()\n .toLowerCase()\n if (!domain) return { ok: 'already-clear' }\n\n // `not-found` is success — the desired end state already holds — mirroring\n // how attach tolerates a name already registered.\n const released = await detachProjectDomain(domain, 'tenant')\n if (released.outcome === 'failed') {\n // Recorded so a retry (and a staff view) can see a release that never\n // landed; `cname` is KEPT, because the name is still attached.\n await hostRef\n .set({ cnameDetachmentPending: true }, { merge: true })\n .catch(() => undefined)\n return {\n ok: 'refused',\n status: 502,\n code: 'detach-failed',\n error: released.detail ?? 'Detach failed at the platform',\n }\n }\n\n // The platform subdomain was registered as a REDIRECT to the domain\n // (AGL-1273), and the redirect is a property of its registration, so it is\n // dropped with the registration and put back plain — which is what makes\n // it serve again. A `not-found` means a wildcard serves it and it carried\n // no redirect of its own; registering one there would create an entry\n // this never removed.\n const subdomain = String(hostSnapshot.get('subdomain') ?? '')\n .trim()\n .toLowerCase()\n if (subdomain) {\n const platformName = `${subdomain}.${TENANT_APEX}`\n const removed = await detachProjectDomain(platformName, 'tenant')\n if (removed.outcome === 'detached') {\n await attachProjectDomain(platformName, {}, 'tenant')\n }\n }\n\n // The twin forwards to the name just released, so it goes with it.\n // Best-effort: a twin left on the deployment redirects to a name that no\n // longer serves, which is a dead end but not another site — and the claim\n // below is cleared either way, so no site can be shown the name as its own.\n await releaseCustomDomainTwin(hostSnapshot.get(HOST_CNAME_TWIN_FIELD)).catch(\n () => false,\n )\n await hostRef.set(\n {\n cname: firebaseAdmin.firestore.FieldValue.delete(),\n [HOST_CNAME_TWIN_FIELD]: firebaseAdmin.firestore.FieldValue.delete(),\n cnameTwinPending: firebaseAdmin.firestore.FieldValue.delete(),\n cnameAttachmentPending: firebaseAdmin.firestore.FieldValue.delete(),\n cnameDetachmentPending: firebaseAdmin.firestore.FieldValue.delete(),\n subdomainRedirectPending: firebaseAdmin.firestore.FieldValue.delete(),\n },\n { merge: true },\n )\n // The Sites list's rows of this site drop the domain from their search and\n // read \"no custom domain\" again (AGL-3321). Best-effort.\n const orgId = String(hostSnapshot.get('orgId') ?? '')\n if (orgId) {\n await syncHostProjectionForMembers(orgId, hostId).catch(() => undefined)\n }\n // THE EVENT IS `cname` LEAVING THE DOCUMENT (AGL-118), which is the write\n // directly above — the mirror image of where connect logs. The refusals\n // above write no entry: a failed release still holds the name, and a row\n // there would say the customer released a domain we are still holding.\n await logHostActivity(hostId, actor, 'Released the custom domain', {\n type: 'host',\n id: hostId,\n name: domain,\n })\n // The name no longer serves this site: plugins undo what they registered\n // for it (AGL-3629), each checking no other site still serves it.\n await runPluginEventHandlers('host.domain.released', {\n orgId: orgId || null,\n hostId,\n domain,\n reason: input.reason ?? 'detached',\n })\n return { ok: 'released', domain, subdomain }\n}\n"],"names":["TENANT_APEX","runPluginEventHandlers","domainProvider","domainStateServes","firebaseAdmin","flagLookalikeCustomDomain","syncHostProjectionForMembers","upsertCustomDomainTwin","upsertSubdomainRedirect","logHostActivity","attachProjectDomain","detachProjectDomain","projectDomainStatus","HOST_CNAME_TWIN_FIELD","NOT_CONFIGURED","customDomainTwinOf","domain","twin","primary","trim","toLowerCase","other","holdersOf","tx","firestore","name","asPrimary","asTwin","Promise","all","get","collection","where","limit","docs","map","snapshot","id","connectHostCustomDomain","input","hostSnapshot","hostId","actor","app","hostRef","doc","exists","ok","status","code","error","orgId","String","claimed","runTransaction","names","holders","some","set","cname","FieldValue","delete","merge","catch","undefined","markPending","cnameAttachmentPending","configured","attach","outcome","detail","scope","serves","state","subdomain","redirected","target","subdomainRedirectPending","twinned","cnameTwinPending","type","verification","conflicts","releaseCustomDomainTwin","released","disconnectHostCustomDomain","cnameDetachmentPending","platformName","removed","reason"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAGD,SAASA,WAAW,QAAQ,qCAAoC;AAChE,SAASC,sBAAsB,QAAQ,4CAA2C;AAClF,SACEC,cAAc,EACdC,iBAAiB,QAGZ,uBAAmB;AAC1B,OAAOC,mBAAmB,sBAAkB;AAC5C,SAASC,yBAAyB,QAAQ,0BAAsB;AAChE,SAASC,4BAA4B,QAAQ,wBAAoB;AACjE,SACEC,sBAAsB,EACtBC,uBAAuB,QAClB,+BAA2B;AAClC,SAASC,eAAe,QAAQ,qBAAiB;AACjD,SACEC,mBAAmB,EACnBC,mBAAmB,EACnBC,mBAAmB,QACd,yBAAqB;AAE5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BC,GAED,0DAA0D,GAC1D,OAAO,MAAMC,wBAAwB,YAAW;AAsChD,MAAMC,iBACJ,4DACA;AAEF;;;;CAIC,GACD,OAAO,SAASC,mBAAmBC,MAAc,EAAEC,IAAY;IAC7D,MAAMC,UAAUF,OAAOG,IAAI,GAAGC,WAAW;IACzC,MAAMC,QAAQJ,KAAKE,IAAI,GAAGC,WAAW;IACrC,IAAI,CAACF,WAAW,CAACG,SAASH,YAAYG,OAAO,OAAO;IACpD,OAAOA,UAAU,CAAC,IAAI,EAAEH,SAAS,IAAIA,YAAY,CAAC,IAAI,EAAEG,OAAO;AACjE;AAEA,mEAAmE,GACnE,eAAeC,UACbC,EAAiC,EACjCC,SAAsC,EACtCC,IAAY;IAEZ,MAAM,CAACC,WAAWC,OAAO,GAAG,MA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AC5E,MAAMJ,wBAAwB3C,aAAaV,GAAG,CAACjB,wBAAwBkD,KAAK,CAC1E,IAAM;IAER,MAAMnB,QAAQc,GAAG,CACf;QACEC,OAAOvD,cAAcoB,SAAS,CAACoC,UAAU,CAACC,MAAM;QAChD,CAAChD,sBAAsB,EAAET,cAAcoB,SAAS,CAACoC,UAAU,CAACC,MAAM;QAClEkB,kBAAkB3E,cAAcoB,SAAS,CAACoC,UAAU,CAACC,MAAM;QAC3DK,wBAAwB9D,cAAcoB,SAAS,CAACoC,UAAU,CAACC,MAAM;QACjEyB,wBAAwBlF,cAAcoB,SAAS,CAACoC,UAAU,CAACC,MAAM;QACjEgB,0BAA0BzE,cAAcoB,SAAS,CAACoC,UAAU,CAACC,MAAM;IACrE,GACA;QAAEC,OAAO;IAAK;IAEhB,2EAA2E;IAC3E,yDAAyD;IACzD,MAAMX,QAAQC,QAAOZ,qBAAAA,aAAaV,GAAG,CAAC,oBAAjBU,qBAA6B;IAClD,IAAIW,OAAO;QACT,MAAM7C,6BAA6B6C,OAAOV,QAAQsB,KAAK,CAAC,IAAMC;IAChE;IACA,0EAA0E;IAC1E,wEAAwE;IACxE,yEAAyE;IACzE,uEAAuE;IACvE,MAAMvD,gBAAgBgC,QAAQC,OAAO,8BAA8B;QACjEsC,MAAM;QACN3C,IAAII;QACJhB,MAAMT;IACR;IACA,yEAAyE;IACzE,kEAAkE;IAClE,MAAMf,uBAAuB,wBAAwB;QACnDkD,OAAOA,SAAS;QAChBV;QACAzB;QACAyE,MAAM,GAAElD,gBAAAA,MAAMkD,MAAM,YAAZlD,gBAAgB;IAC1B;IACA,OAAO;QAAEQ,IAAI;QAAY/B;QAAQ0D;IAAU;AAC7C"}
@@ -81,6 +81,7 @@ export declare const membershipRow: (orgId: string, meta: HostMeta | undefined,
81
81
  nameLower: string;
82
82
  searchTokens: string[];
83
83
  hasCustomDomain: boolean;
84
+ cname: string | FieldValue;
84
85
  createdAt: unknown;
85
86
  favicon: string | FieldValue;
86
87
  role: string;
@@ -88,6 +89,38 @@ export declare const membershipRow: (orgId: string, meta: HostMeta | undefined,
88
89
  subdomain?: string;
89
90
  orgId: string;
90
91
  };
92
+ /**
93
+ * The host-document paths a membership row is derived from. A writer that
94
+ * changes any of them owes `syncHostProjectionForMembers` (AGL-3972): the
95
+ * rows are written by the Admin SDK at these writers and nowhere else, so a
96
+ * change that skips the re-fan leaves every member's list on the old value
97
+ * until something unrelated rewrites the row.
98
+ */
99
+ export declare const PROJECTED_HOST_PATHS: readonly string[];
100
+ /** Whether a write that changed these paths owes the membership re-fan. */
101
+ export declare const changesProjectedHostFields: (paths: readonly string[]) => boolean;
102
+ /** The longest site name the console's Display name field accepts. */
103
+ export declare const HOST_DISPLAY_NAME_MAX = 200;
104
+ /**
105
+ * The host-document update for a mirrored field a person changed in the
106
+ * console (AGL-3972), read from a `/api/hosts/sync-memberships` body.
107
+ *
108
+ * The console used to write `displayName` and `seo.favicon` from the browser
109
+ * and then ping the server to re-fan the rows, chained on the write's
110
+ * server acknowledgement. Under the multi-tab cache that acknowledgement can
111
+ * take a minute (AGL-3806), and a page left in that minute, or a ping that
112
+ * failed, left the rows on the old name for good. The server now writes the
113
+ * field and re-fans in the same request, so the two cannot come apart.
114
+ *
115
+ * Answers `null` when the body names neither field (a plain re-fan), and an
116
+ * error for a value the console would never send. A favicon of `''` is the
117
+ * Remove button's clear, kept as `''` because that is what the card writes.
118
+ */
119
+ export declare function projectedHostFieldsUpdate(body: Record<string, unknown> | null | undefined): {
120
+ update: Record<string, unknown> | null;
121
+ } | {
122
+ error: string;
123
+ };
91
124
  /**
92
125
  * Re-sync ONE member's projection rows across all the org's hosts: set a row
93
126
  * for every host the member can reach, delete the row for every host they
@@ -97,8 +130,8 @@ export declare const membershipRow: (orgId: string, meta: HostMeta | undefined,
97
130
  export declare function syncMemberHostProjections(orgId: string, uid: string): Promise<void>;
98
131
  /**
99
132
  * Re-sync ONE host's projection rows across all org members: set a row for
100
- * every member who can reach it, delete for those who cannot. Call after a
101
- * host is created, renamed, or its displayName changes.
133
+ * every member who can reach it, delete for those who cannot. Call after
134
+ * any write that changes one of `PROJECTED_HOST_PATHS`.
102
135
  */
103
136
  export declare function syncHostProjectionForMembers(orgId: string, hostId: string): Promise<void>;
104
137
  /** Delete every projection row for a member across the org's hosts (member removed). */