@aglyn/tenant-data-admin 1.15.0 → 1.15.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aglyn/tenant-data-admin",
3
- "version": "1.15.0",
3
+ "version": "1.15.1",
4
4
  "license": "Apache-2.0",
5
5
  "homepage": "https://aglyn.com",
6
6
  "repository": {
@@ -25,12 +25,12 @@
25
25
  "./package.json": "./package.json"
26
26
  },
27
27
  "dependencies": {
28
- "@aglyn/aglyn": "1.15.0",
29
- "@aglyn/shared-util-email": "1.15.0",
30
- "@aglyn/shared-util-fbserver": "1.15.0",
31
- "@aglyn/shared-util-first-touch": "1.15.0",
32
- "@aglyn/shared-util-http": "1.15.0",
33
- "@aglyn/shared-util-tools": "1.15.0",
28
+ "@aglyn/aglyn": "1.15.1",
29
+ "@aglyn/shared-util-email": "1.15.1",
30
+ "@aglyn/shared-util-fbserver": "1.15.1",
31
+ "@aglyn/shared-util-first-touch": "1.15.1",
32
+ "@aglyn/shared-util-http": "1.15.1",
33
+ "@aglyn/shared-util-tools": "1.15.1",
34
34
  "@msgpack/msgpack": "^3.1.3",
35
35
  "@swc/helpers": "0.5.23",
36
36
  "sharp": "^0.35.5",
@@ -14,6 +14,7 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */ import { firebaseAdmin } from "./firebase-admin.js";
17
+ import { accountChargeModel } from "./payment-provider.js";
17
18
  import { sendGa4StripeConnected } from "./ga4-measurement-protocol.js";
18
19
  import { updateExisting } from "./update-existing.js";
19
20
  /**
@@ -36,6 +37,14 @@ import { updateExisting } from "./update-existing.js";
36
37
  const accountId = typeof (account == null ? void 0 : account.id) === 'string' ? account.id.trim() : '';
37
38
  if (!accountId) return 0;
38
39
  const patch = {};
40
+ // The charge shape (direct or destination) is read off the account's
41
+ // `controller`, the same rule the connect route applies, so an
42
+ // `account.updated` keeps it true without anyone re-opening setup. Only a
43
+ // storefront binding records it: plugin marketplace sales are always
44
+ // destination charges.
45
+ if (collection === 'profiles' && (account == null ? void 0 : account.controller)) {
46
+ patch['stripeChargeModel'] = accountChargeModel(account);
47
+ }
39
48
  if (typeof (account == null ? void 0 : account.charges_enabled) === 'boolean') {
40
49
  patch['stripeChargesEnabled'] = account.charges_enabled;
41
50
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../libs/tenant/data/admin/src/lib/server/payment-provider-stripe-connect-status.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 { firebaseAdmin } from './firebase-admin'\nimport { sendGa4StripeConnected } from './ga4-measurement-protocol'\nimport { updateExisting } from './update-existing'\n\n/**\n * Connect readiness, refreshed from Stripe rather than from a cached flag\n * (AGL-1997).\n *\n * `stripeChargesEnabled` is the field every money route gates on — commerce\n * checkout, cart checkout, draft orders, reservations, POS — and until this it\n * was refreshed ONLY when the merchant happened to reopen the Connect route.\n * So an account Stripe later restricts (a verification deadline passing, a\n * capability revoked, documents going stale) kept a cached `true`, the store\n * kept selling, and the failure surfaced to the SHOPPER at payment time. The\n * merchant, who could have fixed it, was the last to know.\n *\n * `account.updated` is the event that carries this. Stripe sends it on every\n * change to a connected account, which is why the fix is a subscription and\n * not a poll.\n *\n * WHY IT WRITES ONLY WHAT STRIPE ACTUALLY SAID. Both flags are written only\n * when the payload states them as booleans. Coercing an absent field with\n * `Boolean(...)` would manufacture a `false` and lock out a merchant who is\n * fine — the over-restrictive direction, but still a wrong answer invented\n * from no evidence — and defaulting the other way would re-create the very\n * fail-open this closes. An event that states neither flag writes nothing at\n * all; it is not an Account payload.\n *\n * WHY `updateExisting` AND NOT A MERGE-SET. The refs come from a query, so the\n * documents existed a moment ago — but a merge-set would resurrect one erased\n * in between as a stub holding two payout booleans and nothing else, the\n * AGL-1763 phantom shape. `update()` rejects instead, and a rejection here\n * costs nothing: the next `account.updated` re-delivers the same state.\n *\n * IDEMPOTENT AND ORDER-INDEPENDENT by construction — it mirrors current state,\n * never a delta — so a Stripe redelivery and an out-of-order pair both\n * converge.\n *\n * Part of the Stripe Connect payment provider: a plugin reaches it through\n * the contract's `applyAccountEvent`, never by importing it.\n */\nexport interface ConnectAccountStatusEvent {\n /** `event.data.object` for `account.updated` — the Stripe Account. */\n id?: unknown\n charges_enabled?: unknown\n payouts_enabled?: unknown\n}\n\n/**\n * Mirrors a connected account's charge/payout readiness onto whichever\n * documents in `collection` name it in `stripeAccountId`.\n *\n * @param eventLivemode `event.livemode` from the enclosing `account.updated`\n * event (AGL-2471) — NOT `event.data.object.livemode`, which Stripe's\n * Account object does not have. Anything other than a boolean writes\n * nothing, leaving the field absent, which every money gate reads as\n * unverified and refuses.\n * @param collection Firestore collection holding the payout binding —\n * `profiles` for storefront merchants, `publisherProfiles` for marketplace\n * publishers. Each plugin syncs its own; a non-matching account updates\n * nothing.\n * @returns the number of documents updated. 0 is the ordinary answer for an\n * account this collection does not bind, and the caller should not treat it\n * as a failure.\n */\nexport async function syncConnectAccountStatus(\n collection: string,\n account: ConnectAccountStatusEvent | null | undefined,\n eventLivemode?: unknown,\n): Promise<number> {\n const accountId = typeof account?.id === 'string' ? account.id.trim() : ''\n if (!accountId) return 0\n const patch: Record<string, boolean> = {}\n if (typeof account?.charges_enabled === 'boolean') {\n patch['stripeChargesEnabled'] = account.charges_enabled\n }\n if (typeof account?.payouts_enabled === 'boolean') {\n patch['stripePayoutsEnabled'] = account.payouts_enabled\n }\n // WHICH STRIPE WORLD (AGL-2471). The Account object has no `livemode`, but\n // the EVENT carrying it does, and it is Stripe's own statement about the\n // account being described — the strongest evidence available, and it\n // arrives on every change. This is what heals a linkage whose mode was\n // never recorded, without anyone touching the database by hand.\n //\n // Same doctrine as the two flags above: only a literal boolean is written.\n if (typeof eventLivemode === 'boolean') {\n patch['stripeAccountLivemode'] = eventLivemode\n }\n // Nothing stated, nothing written — see the doc comment.\n if (!Object.keys(patch).length) return 0\n\n const matches = await firebaseAdmin\n .app()\n .firestore()\n .collection(collection)\n .where('stripeAccountId', '==', accountId)\n .get()\n let updated = 0\n for (const doc of matches.docs) {\n // THE ACTIVATION TRANSITION, read BEFORE the write (AGL-1580).\n //\n // `stripe_connected` is one of the launch key events, and its two\n // client-side emitters are gated on the merchant's profile still reading\n // \"not connected\" when they click. This webhook is what makes that false:\n // it lands while the merchant is still on Stripe's hosted onboarding, so\n // the flag has already flipped by the time they get back and the browser\n // event can never fire. See `sendGa4StripeConnected` for why the two\n // guards cannot both open for the same account.\n //\n // `!== true` and not `=== false`: a profile that has never been asked has\n // the field ABSENT, and that is the commonest first-connect shape of all.\n const becameConnected =\n patch['stripeChargesEnabled'] === true &&\n doc.get('stripeChargesEnabled') !== true\n // `updateExisting` rethrows anything that is not \"the document is gone\",\n // so a permission or transport failure still reaches the webhook and gets\n // the redelivery it needs.\n if (await updateExisting(doc.ref, patch)) {\n updated += 1\n // Reported only after the write LANDED. A document erased between the\n // query and the update is not an activation, and reporting one would\n // put a merchant in the metric who no longer exists.\n //\n // Awaited, not floated: this runs inside the Stripe webhook's claim on\n // the event, and a floated promise in a serverless handler is frozen at\n // response and never runs — the AGL-2346 shape. The sender swallows\n // everything and cannot un-claim the event by throwing.\n if (becameConnected) await sendGa4StripeConnected({ accountId })\n }\n }\n return updated\n}\n"],"names":["firebaseAdmin","sendGa4StripeConnected","updateExisting","syncConnectAccountStatus","collection","account","eventLivemode","accountId","id","trim","patch","charges_enabled","payouts_enabled","Object","keys","length","matches","app","firestore","where","get","updated","doc","docs","becameConnected","ref"],"mappings":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uB,KAAK,QAClCY,IAAIF,GAAG,CAAC,4BAA4B;QACtC,yEAAyE;QACzE,0EAA0E;QAC1E,2BAA2B;QAC3B,IAAI,MAAMlB,eAAeoB,IAAIG,GAAG,EAAEf,QAAQ;YACxCW,WAAW;YACX,sEAAsE;YACtE,qEAAqE;YACrE,qDAAqD;YACrD,EAAE;YACF,uEAAuE;YACvE,wEAAwE;YACxE,oEAAoE;YACpE,wDAAwD;YACxD,IAAIG,iBAAiB,MAAMvB,uBAAuB;gBAAEM;YAAU;QAChE;IACF;IACA,OAAOc;AACT"}
1
+ {"version":3,"sources":["../../../../../../../../libs/tenant/data/admin/src/lib/server/payment-provider-stripe-connect-status.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 { firebaseAdmin } from './firebase-admin'\nimport { accountChargeModel } from './payment-provider'\nimport { sendGa4StripeConnected } from './ga4-measurement-protocol'\nimport { updateExisting } from './update-existing'\n\n/**\n * Connect readiness, refreshed from Stripe rather than from a cached flag\n * (AGL-1997).\n *\n * `stripeChargesEnabled` is the field every money route gates on — commerce\n * checkout, cart checkout, draft orders, reservations, POS — and until this it\n * was refreshed ONLY when the merchant happened to reopen the Connect route.\n * So an account Stripe later restricts (a verification deadline passing, a\n * capability revoked, documents going stale) kept a cached `true`, the store\n * kept selling, and the failure surfaced to the SHOPPER at payment time. The\n * merchant, who could have fixed it, was the last to know.\n *\n * `account.updated` is the event that carries this. Stripe sends it on every\n * change to a connected account, which is why the fix is a subscription and\n * not a poll.\n *\n * WHY IT WRITES ONLY WHAT STRIPE ACTUALLY SAID. Both flags are written only\n * when the payload states them as booleans. Coercing an absent field with\n * `Boolean(...)` would manufacture a `false` and lock out a merchant who is\n * fine — the over-restrictive direction, but still a wrong answer invented\n * from no evidence — and defaulting the other way would re-create the very\n * fail-open this closes. An event that states neither flag writes nothing at\n * all; it is not an Account payload.\n *\n * WHY `updateExisting` AND NOT A MERGE-SET. The refs come from a query, so the\n * documents existed a moment ago — but a merge-set would resurrect one erased\n * in between as a stub holding two payout booleans and nothing else, the\n * AGL-1763 phantom shape. `update()` rejects instead, and a rejection here\n * costs nothing: the next `account.updated` re-delivers the same state.\n *\n * IDEMPOTENT AND ORDER-INDEPENDENT by construction — it mirrors current state,\n * never a delta — so a Stripe redelivery and an out-of-order pair both\n * converge.\n *\n * Part of the Stripe Connect payment provider: a plugin reaches it through\n * the contract's `applyAccountEvent`, never by importing it.\n */\nexport interface ConnectAccountStatusEvent {\n /** `event.data.object` for `account.updated` — the Stripe Account. */\n id?: unknown\n charges_enabled?: unknown\n payouts_enabled?: unknown\n}\n\n/**\n * Mirrors a connected account's charge/payout readiness onto whichever\n * documents in `collection` name it in `stripeAccountId`.\n *\n * @param eventLivemode `event.livemode` from the enclosing `account.updated`\n * event (AGL-2471) — NOT `event.data.object.livemode`, which Stripe's\n * Account object does not have. Anything other than a boolean writes\n * nothing, leaving the field absent, which every money gate reads as\n * unverified and refuses.\n * @param collection Firestore collection holding the payout binding —\n * `profiles` for storefront merchants, `publisherProfiles` for marketplace\n * publishers. Each plugin syncs its own; a non-matching account updates\n * nothing.\n * @returns the number of documents updated. 0 is the ordinary answer for an\n * account this collection does not bind, and the caller should not treat it\n * as a failure.\n */\nexport async function syncConnectAccountStatus(\n collection: string,\n account: ConnectAccountStatusEvent | null | undefined,\n eventLivemode?: unknown,\n): Promise<number> {\n const accountId = typeof account?.id === 'string' ? account.id.trim() : ''\n if (!accountId) return 0\n const patch: Record<string, boolean | string> = {}\n // The charge shape (direct or destination) is read off the account's\n // `controller`, the same rule the connect route applies, so an\n // `account.updated` keeps it true without anyone re-opening setup. Only a\n // storefront binding records it: plugin marketplace sales are always\n // destination charges.\n if (collection === 'profiles' && (account as any)?.controller) {\n patch['stripeChargeModel'] = accountChargeModel(account)\n }\n if (typeof account?.charges_enabled === 'boolean') {\n patch['stripeChargesEnabled'] = account.charges_enabled\n }\n if (typeof account?.payouts_enabled === 'boolean') {\n patch['stripePayoutsEnabled'] = account.payouts_enabled\n }\n // WHICH STRIPE WORLD (AGL-2471). The Account object has no `livemode`, but\n // the EVENT carrying it does, and it is Stripe's own statement about the\n // account being described — the strongest evidence available, and it\n // arrives on every change. This is what heals a linkage whose mode was\n // never recorded, without anyone touching the database by hand.\n //\n // Same doctrine as the two flags above: only a literal boolean is written.\n if (typeof eventLivemode === 'boolean') {\n patch['stripeAccountLivemode'] = eventLivemode\n }\n // Nothing stated, nothing written — see the doc comment.\n if (!Object.keys(patch).length) return 0\n\n const matches = await firebaseAdmin\n .app()\n .firestore()\n .collection(collection)\n .where('stripeAccountId', '==', accountId)\n .get()\n let updated = 0\n for (const doc of matches.docs) {\n // THE ACTIVATION TRANSITION, read BEFORE the write (AGL-1580).\n //\n // `stripe_connected` is one of the launch key events, and its two\n // client-side emitters are gated on the merchant's profile still reading\n // \"not connected\" when they click. This webhook is what makes that false:\n // it lands while the merchant is still on Stripe's hosted onboarding, so\n // the flag has already flipped by the time they get back and the browser\n // event can never fire. See `sendGa4StripeConnected` for why the two\n // guards cannot both open for the same account.\n //\n // `!== true` and not `=== false`: a profile that has never been asked has\n // the field ABSENT, and that is the commonest first-connect shape of all.\n const becameConnected =\n patch['stripeChargesEnabled'] === true &&\n doc.get('stripeChargesEnabled') !== true\n // `updateExisting` rethrows anything that is not \"the document is gone\",\n // so a permission or transport failure still reaches the webhook and gets\n // the redelivery it needs.\n if (await updateExisting(doc.ref, patch)) {\n updated += 1\n // Reported only after the write LANDED. A document erased between the\n // query and the update is not an activation, and reporting one would\n // put a merchant in the metric who no longer exists.\n //\n // Awaited, not floated: this runs inside the Stripe webhook's claim on\n // the event, and a floated promise in a serverless handler is frozen at\n // response and never runs — the AGL-2346 shape. The sender swallows\n // everything and cannot un-claim the event by throwing.\n if (becameConnected) await sendGa4StripeConnected({ accountId })\n }\n }\n return updated\n}\n"],"names":["firebaseAdmin","accountChargeModel","sendGa4StripeConnected","updateExisting","syncConnectAccountStatus","collection","account","eventLivemode","accountId","id","trim","patch","controller","charges_enabled","payouts_enabled","Object","keys","length","matches","app","firestore","where","get","updated","doc","docs","becameConnected","ref"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,aAAa,QAAQ,sBAAkB;AAChD,SAASC,kBAAkB,QAAQ,wBAAoB;AACvD,SAASC,sBAAsB,QAAQ,gCAA4B;AACnE,SAASC,cAAc,QAAQ,uBAAmB;AA8ClD;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,eAAeC,yBACpBC,UAAkB,EAClBC,OAAqD,EACrDC,aAAuB;IAEvB,MAAMC,YAAY,QAAOF,2BAAAA,QAASG,EAAE,MAAK,WAAWH,QAAQG,EAAE,CAACC,IAAI,KAAK;IACxE,IAAI,CAACF,WAAW,OAAO;IACvB,MAAMG,QAA0C,CAAC;IACjD,qEAAqE;IACrE,+DAA+D;IAC/D,0EAA0E;IAC1E,qEAAqE;IACrE,uBAAuB;IACvB,IAAIN,eAAe,eAAeC,2BAAD,AAACA,QAAiBM,UAAU,GAAE;QAC7DD,KAAK,CAAC,oBAAoB,GAAGV,mBAAmBK;IAClD;IACA,IAAI,QAAOA,2BAAAA,QAASO,eAAe,MAAK,WAAW;QACjDF,KAAK,CAAC,uBAAuB,GAAGL,QAAQO,eAAe;IACzD;IACA,IAAI,QAAOP,2BAAAA,QAASQ,eAAe,MAAK,WAAW;QACjDH,KAAK,CAAC,uBAAuB,GAAGL,QAAQQ,eAAe;IACzD;IACA,2EAA2E;IAC3E,yEAAyE;IACzE,qEAAqE;IACrE,uEAAuE;IACvE,gEAAgE;IAChE,EAAE;IACF,2EAA2E;IAC3E,IAAI,OAAOP,kBAAkB,WAAW;QACtCI,KAAK,CAAC,wBAAwB,GAAGJ;IACnC;IACA,yDAAyD;IACzD,IAAI,CAACQ,OAAOC,IAAI,CAACL,OAAOM,MAAM,EAAE,OAAO;IAEvC,MAAMC,UAAU,MAAMlB,cACnBmB,GAAG,GACHC,SAAS,GACTf,UAAU,CAACA,YACXgB,KAAK,CAAC,mBAAmB,MAAMb,WAC/Bc,GAAG;IACN,IAAIC,UAAU;IACd,KAAK,MAAMC,OAAON,QAAQO,IAAI,CAAE;QAC9B,+DAA+D;QAC/D,EAAE;QACF,kEAAkE;QAClE,yEAAyE;QACzE,0EAA0E;QAC1E,yEAAyE;QACzE,yEAAyE;QACzE,qEAAqE;QACrE,gDAAgD;QAChD,EAAE;QACF,0EAA0E;QAC1E,0EAA0E;QAC1E,MAAMC,kBACJf,KAAK,CAAC,uBAAuB,KAAK,QAClCa,IAAIF,GAAG,CAAC,4BAA4B;QACtC,yEAAyE;QACzE,0EAA0E;QAC1E,2BAA2B;QAC3B,IAAI,MAAMnB,eAAeqB,IAAIG,GAAG,EAAEhB,QAAQ;YACxCY,WAAW;YACX,sEAAsE;YACtE,qEAAqE;YACrE,qDAAqD;YACrD,EAAE;YACF,uEAAuE;YACvE,wEAAwE;YACxE,oEAAoE;YACpE,wDAAwD;YACxD,IAAIG,iBAAiB,MAAMxB,uBAAuB;gBAAEM;YAAU;QAChE;IACF;IACA,OAAOe;AACT"}
@@ -171,3 +171,26 @@ export declare function merchantAccountReadiness(input: MerchantAccountReadiness
171
171
  export declare function merchantAccountIsReady(input: MerchantAccountReadinessInput, context?: {
172
172
  subject?: string;
173
173
  }): boolean;
174
+ export type SaleChargeModel = 'direct' | 'destination';
175
+ /**
176
+ * The `/v1/accounts` parameters for a new seller account: a full Stripe
177
+ * account that Stripe bills and Stripe underwrites (the Standard shape, by
178
+ * controller properties). The dashboard type cannot be changed later, which
179
+ * is why it is set here and nowhere else.
180
+ */
181
+ export declare const DIRECT_CHARGE_ACCOUNT_PARAMS: Readonly<Record<string, string>>;
182
+ /** The charge shape a Stripe Account object supports. */
183
+ export declare function accountChargeModel(account: unknown): SaleChargeModel;
184
+ /** The charge shape recorded on a seller's profile (`stripeChargeModel`). */
185
+ export declare function saleChargeModel(recorded: unknown): SaleChargeModel;
186
+ /**
187
+ * The header that creates (or reads) a Stripe object ON the seller's account
188
+ * for a direct charge, and nothing for a destination charge.
189
+ */
190
+ export declare function connectedAccountHeader(model: SaleChargeModel, accountId: unknown): Record<string, string>;
191
+ /**
192
+ * The split for a DIRECT charge: Aglyn's take as the application fee, and no
193
+ * `transfer_data`, because the money is already the seller's. Stripe rejects
194
+ * a zero application fee, so a 0% plan sends no key at all.
195
+ */
196
+ export declare function directChargeParams(feeCents: number, prefix?: 'payment_intent_data' | ''): Record<string, string>;
@@ -66,5 +66,45 @@
66
66
  }
67
67
  return readiness === 'ready';
68
68
  }
69
+ /**
70
+ * The `/v1/accounts` parameters for a new seller account: a full Stripe
71
+ * account that Stripe bills and Stripe underwrites (the Standard shape, by
72
+ * controller properties). The dashboard type cannot be changed later, which
73
+ * is why it is set here and nowhere else.
74
+ */ export const DIRECT_CHARGE_ACCOUNT_PARAMS = {
75
+ 'controller[fees][payer]': 'account',
76
+ 'controller[losses][payments]': 'stripe',
77
+ 'controller[requirement_collection]': 'stripe',
78
+ 'controller[stripe_dashboard][type]': 'full'
79
+ };
80
+ /** The charge shape a Stripe Account object supports. */ export function accountChargeModel(account) {
81
+ var _controller_fees, _controller_stripe_dashboard;
82
+ const controller = account == null ? void 0 : account.controller;
83
+ return (controller == null ? void 0 : (_controller_fees = controller.fees) == null ? void 0 : _controller_fees.payer) === 'account' && (controller == null ? void 0 : (_controller_stripe_dashboard = controller.stripe_dashboard) == null ? void 0 : _controller_stripe_dashboard.type) === 'full' ? 'direct' : 'destination';
84
+ }
85
+ /** The charge shape recorded on a seller's profile (`stripeChargeModel`). */ export function saleChargeModel(recorded) {
86
+ return recorded === 'direct' ? 'direct' : 'destination';
87
+ }
88
+ /**
89
+ * The header that creates (or reads) a Stripe object ON the seller's account
90
+ * for a direct charge, and nothing for a destination charge.
91
+ */ export function connectedAccountHeader(model, accountId) {
92
+ const id = typeof accountId === 'string' ? accountId.trim() : '';
93
+ return model === 'direct' && id ? {
94
+ 'Stripe-Account': id
95
+ } : {};
96
+ }
97
+ /**
98
+ * The split for a DIRECT charge: Aglyn's take as the application fee, and no
99
+ * `transfer_data`, because the money is already the seller's. Stripe rejects
100
+ * a zero application fee, so a 0% plan sends no key at all.
101
+ */ export function directChargeParams(feeCents, prefix = 'payment_intent_data') {
102
+ const fee = Number.isFinite(feeCents) ? Math.max(0, Math.round(feeCents)) : 0;
103
+ if (fee <= 0) return {};
104
+ const key = prefix ? `${prefix}[application_fee_amount]` : 'application_fee_amount';
105
+ return {
106
+ [key]: String(fee)
107
+ };
108
+ }
69
109
 
70
110
  //# sourceMappingURL=payment-provider.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../libs/tenant/data/admin/src/lib/server/payment-provider.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 { STRIPE_CONNECT_PAYMENT_PROVIDER } from './payment-provider-stripe-connect'\n\n/**\n * The merchant's payment account — the one seam the payment vendor lives\n * behind when a TENANT takes money.\n *\n * ## Which money this is, and which it is not\n *\n * Two different accounts move money on this platform and only one of them is\n * here. The platform BILLS its customers — plans, add-ons, metered usage — on\n * its own account; that rail is infrastructure (`org-billing.ts`, the billing\n * webhook route, `api-idempotency.ts`, `stripe-deployment-mode.ts`) and names\n * its vendor where it runs. A tenant SELLS — a storefront order, a booked\n * appointment, a marketplace listing — into a connected merchant account of\n * its own, and every plugin that takes money reaches that account through\n * this contract: whether the account may be charged, which world (live or\n * test) the platform charges in, and what the provider says when the account\n * changes or a payout fails.\n *\n * Commerce's `PaymentProviderId` names the provider a CHECKOUT is created\n * with. This is the other half: the account the checkout pays into.\n *\n * ## One adapter, compiled in, and no registry — by failure direction\n *\n * Stripe Connect is the only adapter\n * (`payment-provider-stripe-connect.ts`), and {@link paymentProvider} returns\n * it without consulting any registry, the way the domain driver's built-ins\n * and the mail rail's are compiled into their libraries. A provider a plugin\n * registered could be ABSENT where a door reads it — a declaration that threw\n * part-way, a route bundle that evaluated the registry apart from boot's —\n * and every answer an absent provider could give at a money door is wrong: a\n * refusal takes every sale on every site down, and a default lets a checkout\n * proceed against an account nobody checked. Compiled in, it cannot be\n * absent, so neither can happen.\n *\n * It lives in this library rather than in a plugin because three plugins take\n * money into the same account — a storefront, a calendar and the marketplace\n * — and one plugin may not import another. A plugin that owned the adapter\n * would make the other two's sales depend on its install and on its\n * registration having run; the adapter itself sells nothing and holds no\n * product, only the platform's own connected-account integration.\n *\n * A second adapter is one module beside the first and a selector here. There\n * is no selector today because there is nothing to select: every plugin's\n * checkout is created against the same vendor.\n *\n * ## The contract every adapter owes\n *\n * 1. **An account the provider did not describe is never ready.** Every\n * {@link MerchantAccountReadiness} other than `'ready'` refuses the charge,\n * and only a literal boolean is a recorded answer.\n * 2. **Only what the provider stated is written.** An account event that\n * states nothing writes nothing, and a written record never invents a\n * `false` or a `true` from an absent field.\n * 3. **Failures propagate.** {@link PaymentProvider.applyAccountEvent} runs\n * inside the platform's billing webhook, and a throw is what earns the\n * redelivery; every write it makes is idempotent so that redelivery\n * converges.\n */\n\n/** Which world a platform credential or a merchant account charges in. */\nexport type PaymentMode = 'live' | 'test'\n\n/**\n * Why a stored merchant account may not be charged against. Every value\n * other than `'ready'` is a refusal.\n */\nexport type MerchantAccountReadiness =\n /** Charge away. */\n | 'ready'\n /** No merchant account is stored at all — the onboarding call to action. */\n | 'not-connected'\n /** The provider will not let this account take charges. */\n | 'charges-disabled'\n /**\n * The account's mode was never recorded (AGL-2471) AND this deployment is\n * LIVE. The onboarding route and the provider's account event both record\n * it, so a genuine merchant self-heals on the next of either.\n */\n | 'mode-unverified'\n /** The account belongs to the OTHER world. The AGL-2471 defect. */\n | 'mode-mismatch'\n\nexport interface MerchantAccountReadinessInput {\n /** The stored account id, whatever shape the document has. */\n accountId?: unknown\n /** Whether the provider said the account may take charges. */\n chargesEnabled?: unknown\n /** Whether the provider said the account is live — absent before AGL-2471. */\n accountLivemode?: unknown\n /** Defaults to {@link PaymentProvider.platformMode}. */\n platformMode?: PaymentMode | undefined\n}\n\n/** One event the platform's billing webhook received, as the provider sent it. */\nexport interface PaymentProviderEvent {\n /** The provider's own name for the event. */\n type: string\n /** The object the event describes. */\n object: unknown\n /** The whole event as delivered. */\n event: unknown\n}\n\nexport interface PaymentProvider {\n /** Stable id, for log lines. Never a display name. */\n readonly id: string\n /**\n * The mode this deployment's platform credential states about itself, read\n * without a network call; `undefined` when there is no credential or it\n * states nothing.\n */\n platformMode(): PaymentMode | undefined\n /**\n * The platform's mode, asked of the provider first and the credential\n * second — what an onboarding route records against a merchant account it\n * has just retrieved.\n */\n resolvePlatformMode(): Promise<PaymentMode | undefined>\n /**\n * Applies an event about a connected merchant account — its readiness\n * changed, a payout to it failed, a later payout landed — to the documents\n * in `collection` that store it. A plugin passes the collection holding ITS\n * merchant profiles; a non-matching account updates nothing.\n *\n * @returns `true` when the event was about a merchant account and has been\n * applied, so the caller's own sections have nothing to do with it;\n * `false` for every other event.\n */\n applyAccountEvent(\n collection: string,\n delivered: PaymentProviderEvent,\n ): Promise<boolean>\n}\n\n/** The provider every merchant account on this deployment is held at. */\nexport function paymentProvider(): PaymentProvider {\n return STRIPE_CONNECT_PAYMENT_PROVIDER\n}\n\n/**\n * Decides whether a stored merchant account may be charged against.\n *\n * Order matters: the two refusals that existed before AGL-2471 are asked\n * first, so an unconnected or restricted merchant still gets the answer they\n * always got, and only an account that WOULD have passed reaches the mode\n * question.\n *\n * WHY THE MODE RULE IS ASYMMETRIC, AND NOT \"REFUSE ANYTHING UNPROVEN\". An\n * unrecorded mode refuses only on a LIVE deployment. That is where real money\n * moves, and a live deployment can always re-establish the field: the\n * merchant reconnects, or the provider sends one account event. Everywhere\n * else — a test deployment, a developer machine, a self-hosted install still\n * in sandbox, the whole test suite — an unverified account keeps the\n * behavior it had before, because no real money can move there and the\n * provider enforces the mode boundary itself. A PROVEN mismatch is refused in\n * both directions, because it costs nothing to detect and is never right.\n */\nexport function merchantAccountReadiness(\n input: MerchantAccountReadinessInput,\n): MerchantAccountReadiness {\n const accountId =\n typeof input.accountId === 'string' ? input.accountId.trim() : ''\n if (!accountId) return 'not-connected'\n if (input.chargesEnabled !== true) return 'charges-disabled'\n const platformMode =\n 'platformMode' in input\n ? input.platformMode\n : paymentProvider().platformMode()\n // Three-valued on purpose, exactly as AGL-1997 reads `payoutsEnabled`: only\n // a literal boolean is a recorded answer. A string `'true'` or a `1` is a\n // field somebody else wrote, and inventing `true` from it would re-open the\n // hole this closes.\n if (typeof input.accountLivemode === 'boolean') {\n // A PROVEN mismatch is refused in either direction. It costs nothing to\n // detect and it is always wrong.\n if (!platformMode) return 'ready'\n return input.accountLivemode === (platformMode === 'live')\n ? 'ready'\n : 'mode-mismatch'\n }\n return platformMode === 'live' ? 'mode-unverified' : 'ready'\n}\n\n/**\n * The form every money door calls: `true` only when the account may be\n * charged, with the two mode refusals reported to the server log.\n *\n * The log line is the part the shopper's generic 409 cannot carry. Before\n * this, a mode mismatch surfaced as a 502 from the provider with nothing\n * anywhere naming the cause; the sale is still refused the same way, but now\n * somebody can find out why.\n */\nexport function merchantAccountIsReady(\n input: MerchantAccountReadinessInput,\n context?: { subject?: string },\n): boolean {\n const readiness = merchantAccountReadiness(input)\n if (readiness === 'mode-mismatch' || readiness === 'mode-unverified') {\n console.error(\n `[AGL-2471] Refusing a charge against ${paymentProvider().id} account ` +\n `${String(input.accountId)}${\n context?.subject ? ` (${context.subject})` : ''\n }: ${readiness}. The stored account is not verified for this ` +\n `deployment's payment mode; the merchant must re-onboard.`,\n )\n }\n return readiness === 'ready'\n}\n"],"names":["STRIPE_CONNECT_PAYMENT_PROVIDER","paymentProvider","merchantAccountReadiness","input","accountId","trim","chargesEnabled","platformMode","accountLivemode","merchantAccountIsReady","context","readiness","console","error","id","String","subject"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,+BAA+B,QAAQ,uCAAmC;AAuInF,uEAAuE,GACvE,OAAO,SAASC;IACd,OAAOD;AACT;AAEA;;;;;;;;;;;;;;;;;CAiBC,GACD,OAAO,SAASE,yBACdC,KAAoC;IAEpC,MAAMC,YACJ,OAAOD,MAAMC,SAAS,KAAK,WAAWD,MAAMC,SAAS,CAACC,IAAI,KAAK;IACjE,IAAI,CAACD,WAAW,OAAO;IACvB,IAAID,MAAMG,cAAc,KAAK,MAAM,OAAO;IAC1C,MAAMC,eACJ,kBAAkBJ,QACdA,MAAMI,YAAY,GAClBN,kBAAkBM,YAAY;IACpC,4EAA4E;IAC5E,0EAA0E;IAC1E,4EAA4E;IAC5E,oBAAoB;IACpB,IAAI,OAAOJ,MAAMK,eAAe,KAAK,WAAW;QAC9C,wEAAwE;QACxE,iCAAiC;QACjC,IAAI,CAACD,cAAc,OAAO;QAC1B,OAAOJ,MAAMK,eAAe,KAAMD,CAAAA,iBAAiB,MAAK,IACpD,UACA;IACN;IACA,OAAOA,iBAAiB,SAAS,oBAAoB;AACvD;AAEA;;;;;;;;CAQC,GACD,OAAO,SAASE,uBACdN,KAAoC,EACpCO,OAA8B;IAE9B,MAAMC,YAAYT,yBAAyBC;IAC3C,IAAIQ,cAAc,mBAAmBA,cAAc,mBAAmB;QACpEC,QAAQC,KAAK,CACX,CAAC,qCAAqC,EAAEZ,kBAAkBa,EAAE,CAAC,SAAS,CAAC,GACrE,GAAGC,OAAOZ,MAAMC,SAAS,IACvBM,CAAAA,2BAAAA,QAASM,OAAO,IAAG,CAAC,EAAE,EAAEN,QAAQM,OAAO,CAAC,CAAC,CAAC,GAAG,GAC9C,EAAE,EAAEL,UAAU,8CAA8C,CAAC,GAC9D,CAAC,wDAAwD,CAAC;IAEhE;IACA,OAAOA,cAAc;AACvB"}
1
+ {"version":3,"sources":["../../../../../../../../libs/tenant/data/admin/src/lib/server/payment-provider.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 { STRIPE_CONNECT_PAYMENT_PROVIDER } from './payment-provider-stripe-connect'\n\n/**\n * The merchant's payment account — the one seam the payment vendor lives\n * behind when a TENANT takes money.\n *\n * ## Which money this is, and which it is not\n *\n * Two different accounts move money on this platform and only one of them is\n * here. The platform BILLS its customers — plans, add-ons, metered usage — on\n * its own account; that rail is infrastructure (`org-billing.ts`, the billing\n * webhook route, `api-idempotency.ts`, `stripe-deployment-mode.ts`) and names\n * its vendor where it runs. A tenant SELLS — a storefront order, a booked\n * appointment, a marketplace listing — into a connected merchant account of\n * its own, and every plugin that takes money reaches that account through\n * this contract: whether the account may be charged, which world (live or\n * test) the platform charges in, and what the provider says when the account\n * changes or a payout fails.\n *\n * Commerce's `PaymentProviderId` names the provider a CHECKOUT is created\n * with. This is the other half: the account the checkout pays into.\n *\n * ## One adapter, compiled in, and no registry — by failure direction\n *\n * Stripe Connect is the only adapter\n * (`payment-provider-stripe-connect.ts`), and {@link paymentProvider} returns\n * it without consulting any registry, the way the domain driver's built-ins\n * and the mail rail's are compiled into their libraries. A provider a plugin\n * registered could be ABSENT where a door reads it — a declaration that threw\n * part-way, a route bundle that evaluated the registry apart from boot's —\n * and every answer an absent provider could give at a money door is wrong: a\n * refusal takes every sale on every site down, and a default lets a checkout\n * proceed against an account nobody checked. Compiled in, it cannot be\n * absent, so neither can happen.\n *\n * It lives in this library rather than in a plugin because three plugins take\n * money into the same account — a storefront, a calendar and the marketplace\n * — and one plugin may not import another. A plugin that owned the adapter\n * would make the other two's sales depend on its install and on its\n * registration having run; the adapter itself sells nothing and holds no\n * product, only the platform's own connected-account integration.\n *\n * A second adapter is one module beside the first and a selector here. There\n * is no selector today because there is nothing to select: every plugin's\n * checkout is created against the same vendor.\n *\n * ## The contract every adapter owes\n *\n * 1. **An account the provider did not describe is never ready.** Every\n * {@link MerchantAccountReadiness} other than `'ready'` refuses the charge,\n * and only a literal boolean is a recorded answer.\n * 2. **Only what the provider stated is written.** An account event that\n * states nothing writes nothing, and a written record never invents a\n * `false` or a `true` from an absent field.\n * 3. **Failures propagate.** {@link PaymentProvider.applyAccountEvent} runs\n * inside the platform's billing webhook, and a throw is what earns the\n * redelivery; every write it makes is idempotent so that redelivery\n * converges.\n */\n\n/** Which world a platform credential or a merchant account charges in. */\nexport type PaymentMode = 'live' | 'test'\n\n/**\n * Why a stored merchant account may not be charged against. Every value\n * other than `'ready'` is a refusal.\n */\nexport type MerchantAccountReadiness =\n /** Charge away. */\n | 'ready'\n /** No merchant account is stored at all — the onboarding call to action. */\n | 'not-connected'\n /** The provider will not let this account take charges. */\n | 'charges-disabled'\n /**\n * The account's mode was never recorded (AGL-2471) AND this deployment is\n * LIVE. The onboarding route and the provider's account event both record\n * it, so a genuine merchant self-heals on the next of either.\n */\n | 'mode-unverified'\n /** The account belongs to the OTHER world. The AGL-2471 defect. */\n | 'mode-mismatch'\n\nexport interface MerchantAccountReadinessInput {\n /** The stored account id, whatever shape the document has. */\n accountId?: unknown\n /** Whether the provider said the account may take charges. */\n chargesEnabled?: unknown\n /** Whether the provider said the account is live — absent before AGL-2471. */\n accountLivemode?: unknown\n /** Defaults to {@link PaymentProvider.platformMode}. */\n platformMode?: PaymentMode | undefined\n}\n\n/** One event the platform's billing webhook received, as the provider sent it. */\nexport interface PaymentProviderEvent {\n /** The provider's own name for the event. */\n type: string\n /** The object the event describes. */\n object: unknown\n /** The whole event as delivered. */\n event: unknown\n}\n\nexport interface PaymentProvider {\n /** Stable id, for log lines. Never a display name. */\n readonly id: string\n /**\n * The mode this deployment's platform credential states about itself, read\n * without a network call; `undefined` when there is no credential or it\n * states nothing.\n */\n platformMode(): PaymentMode | undefined\n /**\n * The platform's mode, asked of the provider first and the credential\n * second — what an onboarding route records against a merchant account it\n * has just retrieved.\n */\n resolvePlatformMode(): Promise<PaymentMode | undefined>\n /**\n * Applies an event about a connected merchant account — its readiness\n * changed, a payout to it failed, a later payout landed — to the documents\n * in `collection` that store it. A plugin passes the collection holding ITS\n * merchant profiles; a non-matching account updates nothing.\n *\n * @returns `true` when the event was about a merchant account and has been\n * applied, so the caller's own sections have nothing to do with it;\n * `false` for every other event.\n */\n applyAccountEvent(\n collection: string,\n delivered: PaymentProviderEvent,\n ): Promise<boolean>\n}\n\n/** The provider every merchant account on this deployment is held at. */\nexport function paymentProvider(): PaymentProvider {\n return STRIPE_CONNECT_PAYMENT_PROVIDER\n}\n\n/**\n * Decides whether a stored merchant account may be charged against.\n *\n * Order matters: the two refusals that existed before AGL-2471 are asked\n * first, so an unconnected or restricted merchant still gets the answer they\n * always got, and only an account that WOULD have passed reaches the mode\n * question.\n *\n * WHY THE MODE RULE IS ASYMMETRIC, AND NOT \"REFUSE ANYTHING UNPROVEN\". An\n * unrecorded mode refuses only on a LIVE deployment. That is where real money\n * moves, and a live deployment can always re-establish the field: the\n * merchant reconnects, or the provider sends one account event. Everywhere\n * else — a test deployment, a developer machine, a self-hosted install still\n * in sandbox, the whole test suite — an unverified account keeps the\n * behavior it had before, because no real money can move there and the\n * provider enforces the mode boundary itself. A PROVEN mismatch is refused in\n * both directions, because it costs nothing to detect and is never right.\n */\nexport function merchantAccountReadiness(\n input: MerchantAccountReadinessInput,\n): MerchantAccountReadiness {\n const accountId =\n typeof input.accountId === 'string' ? input.accountId.trim() : ''\n if (!accountId) return 'not-connected'\n if (input.chargesEnabled !== true) return 'charges-disabled'\n const platformMode =\n 'platformMode' in input\n ? input.platformMode\n : paymentProvider().platformMode()\n // Three-valued on purpose, exactly as AGL-1997 reads `payoutsEnabled`: only\n // a literal boolean is a recorded answer. A string `'true'` or a `1` is a\n // field somebody else wrote, and inventing `true` from it would re-open the\n // hole this closes.\n if (typeof input.accountLivemode === 'boolean') {\n // A PROVEN mismatch is refused in either direction. It costs nothing to\n // detect and it is always wrong.\n if (!platformMode) return 'ready'\n return input.accountLivemode === (platformMode === 'live')\n ? 'ready'\n : 'mode-mismatch'\n }\n return platformMode === 'live' ? 'mode-unverified' : 'ready'\n}\n\n/**\n * The form every money door calls: `true` only when the account may be\n * charged, with the two mode refusals reported to the server log.\n *\n * The log line is the part the shopper's generic 409 cannot carry. Before\n * this, a mode mismatch surfaced as a 502 from the provider with nothing\n * anywhere naming the cause; the sale is still refused the same way, but now\n * somebody can find out why.\n */\nexport function merchantAccountIsReady(\n input: MerchantAccountReadinessInput,\n context?: { subject?: string },\n): boolean {\n const readiness = merchantAccountReadiness(input)\n if (readiness === 'mode-mismatch' || readiness === 'mode-unverified') {\n console.error(\n `[AGL-2471] Refusing a charge against ${paymentProvider().id} account ` +\n `${String(input.accountId)}${\n context?.subject ? ` (${context.subject})` : ''\n }: ${readiness}. The stored account is not verified for this ` +\n `deployment's payment mode; the merchant must re-onboard.`,\n )\n }\n return readiness === 'ready'\n}\n\n/*==========================================\n * WHO IS THE SELLER OF RECORD ON A SITE SALE\n *\n * Two shapes, decided by the seller's connected account, never by a flag the\n * request carries:\n *\n * - `direct`: the sale is created ON the seller's own Stripe account\n * (`Stripe-Account` header). The seller is the merchant of record: the\n * money lands in their balance, Stripe bills them its card fee, refunds\n * and chargebacks debit their balance, and Stripe Tax computes against\n * THEIR registrations. Aglyn takes its plan take as an\n * `application_fee_amount` and is charged nothing by Stripe for the sale.\n * Every account created from now on has this shape\n * (`DIRECT_CHARGE_ACCOUNT_PARAMS`).\n * - `destination`: the sale is created on AGLYN's account and transferred\n * on. Kept for the Express accounts created before the switch (Stripe\n * discourages direct charges on Express, whose dashboard cannot refund or\n * answer a dispute), for the register and Tap to Pay, which stay on the\n * platform account, and for plugin marketplace sales.\n *\n * The shape is recorded on the profile as `stripeChargeModel` by the connect\n * route, which reads it off the account Stripe returns. An absent value is\n * `destination`: the conservative reading, because a direct charge against an\n * Express account would put a refund and a dispute where nobody can act.\n *=========================================*/\nexport type SaleChargeModel = 'direct' | 'destination'\n\n/**\n * The `/v1/accounts` parameters for a new seller account: a full Stripe\n * account that Stripe bills and Stripe underwrites (the Standard shape, by\n * controller properties). The dashboard type cannot be changed later, which\n * is why it is set here and nowhere else.\n */\nexport const DIRECT_CHARGE_ACCOUNT_PARAMS: Readonly<Record<string, string>> = {\n 'controller[fees][payer]': 'account',\n 'controller[losses][payments]': 'stripe',\n 'controller[requirement_collection]': 'stripe',\n 'controller[stripe_dashboard][type]': 'full',\n}\n\n/** The charge shape a Stripe Account object supports. */\nexport function accountChargeModel(account: unknown): SaleChargeModel {\n const controller = (account as any)?.controller\n return controller?.fees?.payer === 'account' &&\n controller?.stripe_dashboard?.type === 'full'\n ? 'direct'\n : 'destination'\n}\n\n/** The charge shape recorded on a seller's profile (`stripeChargeModel`). */\nexport function saleChargeModel(recorded: unknown): SaleChargeModel {\n return recorded === 'direct' ? 'direct' : 'destination'\n}\n\n/**\n * The header that creates (or reads) a Stripe object ON the seller's account\n * for a direct charge, and nothing for a destination charge.\n */\nexport function connectedAccountHeader(\n model: SaleChargeModel,\n accountId: unknown,\n): Record<string, string> {\n const id = typeof accountId === 'string' ? accountId.trim() : ''\n return model === 'direct' && id ? { 'Stripe-Account': id } : {}\n}\n\n/**\n * The split for a DIRECT charge: Aglyn's take as the application fee, and no\n * `transfer_data`, because the money is already the seller's. Stripe rejects\n * a zero application fee, so a 0% plan sends no key at all.\n */\nexport function directChargeParams(\n feeCents: number,\n prefix: 'payment_intent_data' | '' = 'payment_intent_data',\n): Record<string, string> {\n const fee = Number.isFinite(feeCents) ? Math.max(0, Math.round(feeCents)) : 0\n if (fee <= 0) return {}\n const key = prefix ? `${prefix}[application_fee_amount]` : 'application_fee_amount'\n return { [key]: String(fee) }\n}\n"],"names":["STRIPE_CONNECT_PAYMENT_PROVIDER","paymentProvider","merchantAccountReadiness","input","accountId","trim","chargesEnabled","platformMode","accountLivemode","merchantAccountIsReady","context","readiness","console","error","id","String","subject","DIRECT_CHARGE_ACCOUNT_PARAMS","accountChargeModel","account","controller","fees","payer","stripe_dashboard","type","saleChargeModel","recorded","connectedAccountHeader","model","directChargeParams","feeCents","prefix","fee","Number","isFinite","Math","max","round","key"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,+BAA+B,QAAQ,uCAAmC;AAuInF,uEAAuE,GACvE,OAAO,SAASC;IACd,OAAOD;AACT;AAEA;;;;;;;;;;;;;;;;;CAiBC,GACD,OAAO,SAASE,yBACdC,KAAoC;IAEpC,MAAMC,YACJ,OAAOD,MAAMC,SAAS,KAAK,WAAWD,MAAMC,SAAS,CAACC,IAAI,KAAK;IACjE,IAAI,CAACD,WAAW,OAAO;IACvB,IAAID,MAAMG,cAAc,KAAK,MAAM,OAAO;IAC1C,MAAMC,eACJ,kBAAkBJ,QACdA,MAAMI,YAAY,GAClBN,kBAAkBM,YAAY;IACpC,4EAA4E;IAC5E,0EAA0E;IAC1E,4EAA4E;IAC5E,oBAAoB;IACpB,IAAI,OAAOJ,MAAMK,eAAe,KAAK,WAAW;QAC9C,wEAAwE;QACxE,iCAAiC;QACjC,IAAI,CAACD,cAAc,OAAO;QAC1B,OAAOJ,MAAMK,eAAe,KAAMD,CAAAA,iBAAiB,MAAK,IACpD,UACA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C,QAAgB,EAChBC,SAAqC,qBAAqB;IAE1D,MAAMC,MAAMC,OAAOC,QAAQ,CAACJ,YAAYK,KAAKC,GAAG,CAAC,GAAGD,KAAKE,KAAK,CAACP,aAAa;IAC5E,IAAIE,OAAO,GAAG,OAAO,CAAC;IACtB,MAAMM,MAAMP,SAAS,GAAGA,OAAO,wBAAwB,CAAC,GAAG;IAC3D,OAAO;QAAE,CAACO,IAAI,EAAEvB,OAAOiB;IAAK;AAC9B"}
@@ -500,6 +500,15 @@ const firestoreApp = ()=>firebaseAdmin.app().firestore();
500
500
  exported: false,
501
501
  note: 'Replay keys. The document id is a SHA-256 of the org id and the caller’s Idempotency-Key, and the row names a record id and nothing about a person. Disclosed as a COUNT so the export does not silently omit a collection the erasure destroys.'
502
502
  },
503
+ {
504
+ collection: 'pluginConnectionCredentials',
505
+ keyedBy: 'field',
506
+ subjects: [
507
+ 'org'
508
+ ],
509
+ exported: true,
510
+ note: 'EXISTENCE ONLY for the credential — the OAuth app a publishing workspace registered for each declared connection of its marketplace listing (AGL-4193): the listing and connection ids, and when and by which member the pair was last set. The sealed client secret carries `secret` in its name and is redacted (see redactSecrets); the sealed client id is named as an id, which defuses the shape gate, so the export redacts it explicitly. The document id is the listing id and the connection id, derived from no secret.'
511
+ },
503
512
  {
504
513
  collection: 'stripeCustomers',
505
514
  keyedBy: 'field',
@@ -1156,6 +1165,18 @@ function sourcesFor(subject) {
1156
1165
  data['outreachMailboxCredentials'] = await readByField(db, 'outreachMailboxCredentials', 'orgId', orgId);
1157
1166
  // Where each short tracking link the org's sequences sent points (AGL-3297).
1158
1167
  data['outreachLinks'] = await readByField(db, 'outreachLinks', 'orgId', orgId);
1168
+ // A marketplace listing's OAuth app per declared connection (AGL-4193),
1169
+ // keyed by the publishing workspace's `orgId`. `sealedClientSecret` is
1170
+ // withheld by `redactSecrets` on its name; `sealedClientId` is named as an
1171
+ // id, which defuses the shape gate, so it is withheld here by name.
1172
+ data['pluginConnectionCredentials'] = (await readByField(db, 'pluginConnectionCredentials', 'orgId', orgId)).map((row)=>{
1173
+ const fields = row.data;
1174
+ return fields && 'sealedClientId' in fields ? _extends({}, row, {
1175
+ data: _extends({}, fields, {
1176
+ sealedClientId: redactedMarker(true)
1177
+ })
1178
+ }) : row;
1179
+ });
1159
1180
  // Shipping (AGL-3612), tax services (AGL-3631), marketing platforms
1160
1181
  // (AGL-3639) and help desks (AGL-3824): top-level and keyed by `orgId`, the bound their
1161
1182
  // `orgKeyedCollections` erasure sweeps by. The sealed credentials are
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../libs/tenant/data/admin/src/lib/server/personal-data-export.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 * Personal-data export — access and portability, in a machine-readable form\n * (AGL-1974).\n *\n * Privacy Policy §7 grants portability (GDPR Art. 20) and nothing in the\n * product exported a person's or a workspace's personal data. Six surfaces\n * told customers to \"export first\" before deleting — the org settings Delete\n * tab, the Close account card, `erase-org-cli.mjs`, the staff org actions,\n * live DPA §11 and Terms §13.3 — all pointing at something that did not\n * exist. An access request was assembled by a staff member reading the console\n * by hand.\n *\n * ## THE PROPERTY THIS FILE EXISTS FOR\n *\n * **An export whose coverage differs from erasure's is a bug in one of them.**\n * Both answer the same question — *what do we hold about this subject* — and\n * the honest failure modes are symmetric: an export that misses a collection\n * under-discloses on an access request, and an erasure that misses the same\n * one leaves data behind after we said it was gone. Historically the second\n * kept happening (AGL-1444, AGL-1448, AGL-1970, AGL-1971 each found a\n * collection outside the cascade), which is exactly the evidence that a list\n * kept in one place and mirrored by hand in another will drift.\n *\n * The ideal is one enumeration both derive from. That is not available here:\n * `erase.ts` is under concurrent change and its sweep list is expressed as\n * code, not data. So the coverage is enumerated ONCE below, as data, and\n * `personal-data-export-coverage.spec.ts` DISCOVERS every collection\n * `erase.ts` touches out of its source and fails when the two disagree. A new\n * sweep added to the erasure turns this file red until somebody decides\n * whether the export discloses it — which is the decision that was being\n * skipped.\n *\n * That guard is worth more than the feature.\n *\n * ## What must NOT come out wholesale\n *\n * Three categories, and each is a way an access request becomes a breach:\n *\n * 1. **Another person's data.** A workspace is shared. A member asking what\n * we hold about THEM gets their own roster row, not the roster; their own\n * support messages, not the thread's other authors. Handled by exporting\n * the person and the workspace as different subjects with different\n * scopes, never by filtering a single blob after the fact.\n * 2. **Secrets.** An `apiKeys` row confirms that a credential exists — its\n * label, scopes, creator and dates, which are all facts about the subject\n * — and never re-discloses the credential. Note the document ID *is* the\n * SHA-256 of the token, so the id itself is withheld too; a hash handed\n * back is a verifier handed back.\n * 3. **Staff-only fields.** Internal notes, override reasons and moderation\n * state are about our handling, not about the person, and several name a\n * staff member.\n *\n * ## What it is NOT\n *\n * Not `GET /api/hosts/export` — that is a Pro+ site-design backup whose own\n * header says it never includes bookings, leads, submissions or secrets, and\n * offering it as a portability answer would be misdescribing it. Not the\n * `firestore-export` cron, which is an unscoped DR snapshot. Not the audit CSV.\n */\n\nimport { SITE_CARE_STAFF_COLLECTION } from '@aglyn/aglyn/app-utils/site-care'\nimport { firebaseAdmin } from './firebase-admin'\nimport { CONSOLE_DOMAINS_COLLECTION } from './console-domains'\n\nconst firestoreApp = () => firebaseAdmin.app().firestore()\n\n/** Which subject an export source belongs to. */\nexport type ExportSubject = 'user' | 'org'\n\n/** How a source is located — the axis a path cascade is blind to. */\nexport type ExportKeying =\n /** Top-level collection carrying the subject id in a FIELD. */\n | 'field'\n /** Top-level collection whose DOCUMENT ID is the subject id. */\n | 'doc-id'\n /** Under the subject's own document path. */\n | 'path'\n /** Reached through another collection's rows (a collection group). */\n | 'collection-group'\n /** Outside Firestore entirely. */\n | 'external'\n\nexport interface ExportSourceSpec {\n /** Firestore collection name, or an `external:` pseudo-name. */\n collection: string\n keyedBy: ExportKeying\n subjects: readonly ExportSubject[]\n /**\n * `true` when the export discloses it. `false` requires `reason` — and the\n * reason is the whole value of the field: it is a decision recorded at the\n * moment it was made, not an omission discovered later.\n */\n exported: boolean\n /** Why it is withheld, or how it is disclosed. Always present. */\n note: string\n}\n\n/**\n * Every collection `erase.ts` touches, and what the export does with it.\n *\n * Kept in the SAME order as the erasure's steps so a reader comparing the two\n * files reads them in step. `personal-data-export-coverage.spec.ts` proves the\n * set matches; this list carries the decision for each one.\n */\nexport const PERSONAL_DATA_SOURCES: readonly ExportSourceSpec[] = [\n // ── The person ────────────────────────────────────────────────────────\n {\n collection: 'users',\n keyedBy: 'doc-id',\n subjects: ['user'],\n exported: true,\n note: 'Profile: name, phone, postal address, legalAcceptances, and every subcollection (orgs, hostMemberships, notifications, passkeys).',\n },\n {\n collection: 'profiles',\n keyedBy: 'doc-id',\n subjects: ['user'],\n exported: true,\n note: 'The world-readable handle, display name and Stripe Connect account. Not reachable from the user tree (AGL-1970) — the same blind spot on both sides.',\n },\n // ── The workspace ─────────────────────────────────────────────────────\n {\n collection: 'orgs',\n keyedBy: 'doc-id',\n subjects: ['org'],\n exported: true,\n note: 'The org document and every subcollection: members, invites, roles, usage, apiUsage, analytics, datasets/records, contacts, lists, media, installs, activity, assistExchanges, retention.',\n },\n {\n collection: 'hosts',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Each site tree the org owns — pages, layouts, orders, form submissions. Secrets within are redacted, not omitted, so the export still says a webhook exists.',\n },\n {\n collection: 'hostIndex',\n keyedBy: 'doc-id',\n subjects: ['org'],\n exported: true,\n note: 'Subdomain/CNAME routing for each of the org’s sites. Configuration the customer set, so it is theirs to take.',\n },\n {\n collection: 'supplierDeliveries',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'The dropship outbox for each of the org’s sites, keyed by hostId (AGL-1448). Disclosed to the ORG and to no one else, and the reason is the unusual one: the personal data in the row is a SHOPPER’s — name, email and shipping address in the body we sign and POST to the supplier. That is the merchant’s own order record, which they already read in their console and for which they are the controller and we the processor, so an org access request is entitled to it. It is NOT a `user`-subject source: a console member asking what we hold about THEM is not the shopper, and returning these rows would answer their request with a third party’s address. Withholding it was not an option worth taking — `eraseHost` destroys these rows, so an export that omitted them would delete what it never disclosed.',\n },\n // ── Top-level, field-keyed: what a path cascade cannot see ────────────\n {\n collection: 'apiKeys',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'EXISTENCE ONLY — label, scopes, creating uid, dates. Never the credential, and never the document id, which is the SHA-256 of the token.',\n },\n {\n collection: 'outreachMailboxCredentials',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'EXISTENCE ONLY — which connected mailbox a credential authorizes, its provider, granted scopes and dates (AGL-2974), and since AGL-2978 the connected account’s address, its Google account id and the member who connected it: the organization’s own record of whose mailbox it holds. Every token is redacted by name and by shape (see redactSecrets) and never disclosed; the sealed refresh token and the id of the key that sealed it both carry `token` in their names. The document id is the mailbox id, not derived from any secret, so it is disclosed.',\n },\n {\n collection: 'outreachLinks',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Where each short tracking link in a sent Outreach sequence email points (AGL-3297): the enrollment, the step, the link’s index and the destination the step wrote. The organization’s own record of what it sent; the id is random and derived from no secret.',\n },\n {\n collection: 'shippingTrackers',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'One row per tracking number a label was bought for (AGL-3612): the site, the order record, the carrier, the tracking number and its latest status. The organization’s own record of what it shipped; the order it points at is already disclosed under its site. Org-only, for the reason `supplierDeliveries` gives: a tracking number locates a shopper’s parcel.',\n },\n {\n collection: 'shippingQuoteCache',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Carrier quotes for a site’s checkout, kept ten minutes (AGL-3612): the site, each service’s price and transit estimate, and when the row expires. No address is stored; the document id is a SHA-256 of the quoted request, an identifier rather than a verifier of any credential. Disclosed while it exists so the export does not omit a collection the erasure destroys.',\n },\n {\n collection: 'taxEngineConnections',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'EXISTENCE ONLY for the credential — each site’s connection to the merchant’s own Avalara AvaTax or TaxJar account (AGL-3631): provider, environment, account id and company code, ship-from address, default tax code, last test result and the member who connected it. The sealed API token and the id of the key that sealed it both carry `token` in their names and are redacted (see redactSecrets); the document id is the site id.',\n },\n {\n collection: 'taxEngineProductCodes',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'The tax code the merchant assigned each product at their tax service (AGL-3631). Catalog configuration the customer set, so it is theirs to take.',\n },\n {\n collection: 'taxEngineExemptions',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Customers the merchant recorded as tax-exempt (AGL-3631): email, name, exemption type, certificate number and the regions it covers. A SHOPPER’s data held for the merchant as controller, so disclosed to the ORG only, for the reason `supplierDeliveries` gives. The document id carries a truncated SHA-256 of the email — a lookup key, not a credential.',\n },\n {\n collection: 'taxEngineTransactions',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Each paid order as recorded with the merchant’s tax service, and the refunds reversed against it (AGL-3631): the sale sent (lines, ship-to address, the customer code, which is the shopper’s email), its status and last error. The merchant’s own tax record and a shopper’s address, so disclosed to the ORG only.',\n },\n {\n collection: 'marketingPlatformConnections',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'EXISTENCE ONLY for the credential — each site’s connection to the merchant’s own Mailchimp, Klaviyo, Omnisend or Attentive account (AGL-3639): provider, status, account name, the chosen list and tag, the sync switches, cursors and run timing. The sealed access and refresh tokens and the id of the key that sealed them carry `token` in their names and are redacted (see redactSecrets); the document id is the site id and the provider.',\n },\n {\n collection: 'marketingPlatformEvents',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Commerce events still owed to a connected marketing platform (AGL-3639): checkout started, order paid, fulfilled, refunded or cancelled, with the shopper’s email, the order, its items and value, and the tracking number. A SHOPPER’s data held for the merchant as controller, so disclosed to the ORG only, for the reason `supplierDeliveries` gives; a row is deleted once delivered.',\n },\n {\n collection: 'helpDeskConnections',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'EXISTENCE ONLY for the credential — each site’s connection to the merchant’s own Gorgias, Re:amaze, Kustomer, Gladly or Richpanel account (AGL-3824): provider, status, the account’s subdomain and name, the Richpanel support address, the chosen channel, inbox or custom object, the sync switches, cursors and run timing. The sealed API key, login and app client id, sealed together, and the id of the key that sealed them carry `token` in their names and are redacted (see redactSecrets); the document id is the site id and the provider.',\n },\n {\n collection: 'helpDeskOutbox',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Orders and contact form messages still owed to a connected help desk (AGL-3824): a buyer’s email and name with the order’s number, items and totals, or a message’s sender, subject and text. A SHOPPER’s or a visitor’s data held for the merchant as controller, so disclosed to the ORG only, for the reason `supplierDeliveries` gives; a row is deleted once delivered.',\n },\n {\n collection: 'helpDeskCustomers',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'What each help desk connection knows of a buyer (AGL-3824): their email and name, the help desk’s id for them and their ten latest orders, so each order sent carries the recent ones. A SHOPPER’s data held for the merchant as controller, so disclosed to the ORG only, for the reason `supplierDeliveries` gives. The document id carries a truncated SHA-256 of the email — a lookup key, not a credential.',\n },\n {\n collection: 'adConversionConnections',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'EXISTENCE ONLY for the credential — each site’s Conversions API connection to the merchant’s own Meta, TikTok or Pinterest ad account (AGL-3694): provider, status, the Pinterest ad account id, the test event code, and what was last sent or refused. The sealed access token and the id of the key that sealed it carry `token` in their names and are redacted (see redactSecrets); the document id is the site id and the provider.',\n },\n {\n collection: 'adConversionConsents',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'The advertising consent a shopper’s checkout carried, recorded only where it granted advertising on a site with a connection (AGL-3694): the consent status and when it was decided, the country, the page, the ad vendors’ browser ids, the IP address and the user agent. A SHOPPER’s data held for the merchant as controller, so disclosed to the ORG only; deleted when the order is reported or after 14 days.',\n },\n {\n collection: 'adConversionEvents',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Purchases and leads owed to a connected ad account (AGL-3694): the event id, order id, value and items, the visitor’s details as SHA-256 hashes, and the IP address, user agent and vendor browser ids. A SHOPPER’s data held for the merchant as controller, so disclosed to the ORG only; the personal fields are dropped once the event is sent, and every row expires after 14 days.',\n },\n {\n collection: 'domainRegistrations',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Each domain the workspace bought on this platform (AGL-3962): the name, the site it serves, the registrar and its order id, status, registration and expiry dates, auto-renew, what was charged for the first year and quoted for renewals and the invoices for each, the renewal state, the registrant’s name and email as typed at purchase, ICANN’s registrant email check, any dispute, the member who bought it, its latest events, and the registrar’s own prices at purchase. The registration itself, and the full registrant contact, are held by the registrar. Keyed by the domain name.',\n },\n {\n collection: 'domainConnectSessions',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Each one-click DNS request a site sent to its DNS provider through Domain Connect (AGL-3963): the domain and host, the provider and template, the member who started it and their email, its status, and when it was applied, resolved and expires. The document id is a SHA-256 of the state token the provider echoes back, a lookup key and not the token, which is never stored.',\n },\n {\n collection: 'posCellularReaders',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Each S710 reader a store turned 4G on for (AGL-4038): the site, the reader’s id and its serial number, the Terminal configuration, and when it had 4G. The organization’s own record of what it is charged for; it names no person.',\n },\n {\n collection: 'posCellularCharges',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Each month’s 4G charge for the organization’s card readers (AGL-4038): the month, how many readers, the amount, the outcome and the Stripe invoice id. The organization’s own billing record; it names no person.',\n },\n {\n collection: 'fulfillmentNetworkConnections',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'EXISTENCE ONLY for the grant — each site’s connection to the merchant’s own ShipBob, ShipMonk, Flexport or Amazon Multi-Channel Fulfillment account (AGL-3634, AGL-3697, AGL-3822): network, status, account name, ShipBob channel, ShipMonk store id, Amazon marketplaces, routing and stock settings, the last stock count by SKU and totals. The sealed access and refresh tokens (for ShipMonk and Flexport, the merchant’s own API key or token, sealed as the access token), the webhook token’s hash and the id of the key that sealed them carry `token` in their names, and ShipMonk’s sealed webhook signing secret carries `secret` in its name; all are redacted (see redactSecrets). The document id is the site id and the network.',\n },\n {\n collection: 'fulfillmentNetworkOrders',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Each paid order’s hand-off to a fulfillment network (AGL-3634): the order number, the lines sent with SKU and quantity, the network’s reference, the parcels read back with carrier, tracking number and status, and why anything was not sent. The merchant’s own fulfillment record of a SHOPPER’s order, so disclosed to the ORG only.',\n },\n {\n collection: 'courierConnections',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'EXISTENCE ONLY for the keys — each site’s connection to the merchant’s own DoorDash Drive developer account (AGL-3695): provider, the developer and key ids of its live and test keys, each key’s last test result, the store’s courier phone and note, and the member who connected it. The sealed signing secrets carry `secret` and the webhook token’s hash carries `token` in their names and are redacted (see redactSecrets); the document id is the site id and the provider.',\n },\n {\n collection: 'courierDeliveries',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Each local-delivery order’s courier (AGL-3695): the quote offered, the run booked and the runs before it — the courier’s reference, status, fee, arrival estimates, tracking link and any cancellation reason, and the member who booked it. No address or phone is stored here (they stay on the order); the merchant’s own record of a SHOPPER’s delivery, so disclosed to the ORG only.',\n },\n {\n collection: 'marketplaceConnections',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'EXISTENCE ONLY for the grant — each site’s connection to the merchant’s own Amazon, eBay, Etsy, TikTok Shop, Walmart or Faire seller account (AGL-3638): marketplace, status, account name, the marketplace sites the account sells on, the listing and order settings, the order cursor and the last sync’s counts. The sealed access and refresh tokens and the id of the key that sealed them carry `token` in their names and are redacted (see redactSecrets); the account’s marketplace ids are disclosed as stored. The document id is the site id and the marketplace. Its `log` and `listingState` subcollections (what each listing was last sent) are not read by this export.',\n },\n {\n collection: 'marketplaceOrders',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Each marketplace order the store imported (AGL-3638): the marketplace and its order id, the store order it became, which order line each marketplace line became, the marketplace’s fees, and each shipment confirmed back with carrier and tracking number. The merchant’s own record of a marketplace BUYER’s order, so disclosed to the ORG only; the buyer’s name and address are on the store’s order, not here.',\n },\n {\n collection: 'inventorySyncConnections',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'EXISTENCE ONLY for the keys — each site’s connection to the merchant’s own Cin7 Core, inFlow, Brightpearl or Ordoro account (AGL-3642): system, status, account name, the stock, product and order settings (location, the customer or Ordoro sales channel orders are recorded under, the tax rule), the last count by SKU, the last syncs’ counts, cursors and totals. The sealed API keys or grant and the id of the key that sealed them carry `credential` in their names and are redacted (see redactSecrets); Brightpearl’s account code and datacenter are disclosed as stored. The document id is the site id. Its `log` subcollection is not read by this export.',\n },\n {\n collection: 'inventorySyncOrders',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Each paid order’s hand-off to the connected inventory system (AGL-3642): the order number and our reference, the lines sent with SKU, quantity and price, the buyer’s name, email address and shipping address as sent, the totals, the system’s id and number for it, attempts and why it was not sent. The merchant’s own record of a SHOPPER’s order, so disclosed to the ORG only.',\n },\n {\n collection: 'inventorySyncProducts',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Each product linked between the store and the connected inventory system (AGL-3642): the system’s product id, the SKU, the version last synced, the store’s product and variant ids, and why it was not synced. Catalog data, no person’s.',\n },\n {\n collection: 'podConnections',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'EXISTENCE ONLY for the tokens — each site’s connection to the merchant’s own Printful store or Printify shop (AGL-3641): service, store id and name, currency, whether orders are sent automatically or held for review, whether prices sync, how shipments are heard about, and the last error. The sealed API token and webhook token and the id of the key that sealed them carry `token` in their names and are redacted (see redactSecrets).',\n },\n {\n collection: 'podProductLinks',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Each product imported from a print-on-demand service (AGL-3641): the service’s product and variant ids, the store product and variants it became, names, SKUs, what the service charges for each variant and the store’s price. Catalog data, no person’s.',\n },\n {\n collection: 'podOrders',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'The part of each paid order a print-on-demand service makes and ships (AGL-3641): the store order and its number, the service’s order id, the lines sent with quantity and cost, its status, costs, attempts and errors, and each parcel’s carrier and tracking number. No buyer name, address or email is kept here; they are on the store’s order. The merchant’s own record of a SHOPPER’s order, so disclosed to the ORG only.',\n },\n {\n collection: 'deliveryAppStores',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Each site’s link to the merchant’s own DoorDash, Uber Eats or Grubhub store (AGL-3644): the service, the store id it shows the merchant, the settings (accept automatically, prep minutes), the items matched to products and those waiting, and the menu’s last send. No credential is stored: every call is signed with the deployment’s partner credentials.',\n },\n {\n collection: 'deliveryAppOrders',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Each order a delivery service sent a site’s register (AGL-3644): the service and its order id and short code, the items with their options and instructions, the totals and refunds, where it stood at the counter, and the store order it became. The buyer appears by first name and last initial only. The merchant’s own record of a delivery BUYER’s order, so disclosed to the ORG only.',\n },\n {\n collection: 'zapierHooks',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Each Zapier REST hook a site’s API key subscribed (AGL-3643): the site, the events, the API key’s public id and name, delivery counts and dates. EXISTENCE ONLY for the URL — `targetUrl` is the capability Zapier minted for the Zap, a bearer URL whose secret is in its path, so it is redacted by name (see redactSecrets).',\n },\n {\n collection: 'zapierHookDeliveries',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Markers that one event reached one Zapier hook, so a retry does not post it twice (AGL-3643): the hook, the status and the time. The document id is a SHA-256 of the event and hook, an identifier rather than a verifier of any credential; no customer data, and a TTL policy removes each row.',\n },\n {\n collection: 'ssoDomains',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'The public SSO routing document: domain, GCIP tenant and provider ids, IdP display name. `token` is redacted.',\n },\n {\n collection: CONSOLE_DOMAINS_COLLECTION,\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Custom console domain claims the org holds.',\n },\n {\n collection: 'apiIdempotency',\n keyedBy: 'field',\n subjects: ['org'],\n exported: false,\n note: 'Replay keys. The document id is a SHA-256 of the org id and the caller’s Idempotency-Key, and the row names a record id and nothing about a person. Disclosed as a COUNT so the export does not silently omit a collection the erasure destroys.',\n },\n {\n collection: 'stripeCustomers',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'The local reverse index: which Stripe customer id belongs to this workspace. An identifier the customer already holds on their own invoices.',\n },\n {\n collection: 'orgSlugs',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Every workspace name the org has ever held, rename tombstones included — naming history is a fact about them.',\n },\n {\n collection: 'publisherHandles',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Marketplace handle reservations and rename tombstones (AGL-1970).',\n },\n {\n collection: 'publisherProfiles',\n keyedBy: 'doc-id',\n subjects: ['org'],\n exported: true,\n note: 'The public publisher identity — handle, display name, bio, website, avatar, publisher agreement. `stripeAccountId` is the org’s own payout destination and is disclosed; nothing here is a credential.',\n },\n {\n collection: 'marketplaceListings',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Listings the org published. These deliberately OUTLIVE an erasure (AGL-1448 Tier 3) — which makes disclosing them on an access request more important, not less: they are the part that does not go away.',\n },\n {\n collection: 'supportTickets',\n keyedBy: 'field',\n subjects: ['org', 'user'],\n exported: true,\n note: 'For an ORG: every thread and its messages, except a Site Care request’s staff-only intake (the other workspaces its sender belongs to, AGL-4031). For a PERSON: only the messages they themselves authored — a thread has other authors, and handing a member the whole conversation would disclose colleagues’ words to them.',\n },\n // ── Retained past erasure on statutory grounds ────────────────────────\n {\n collection: 'platformRevenue',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Per-transaction tax filing records. GDPR Art. 17(3)(b) exempts them from ERASURE (AGL-1811); it does not exempt them from ACCESS. If a transaction of theirs is in there it is disclosable — and the export is the only place a customer can see what survived their erasure.',\n },\n {\n collection: 'storefrontTaxCollected',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Sales tax charged to shoppers on the org’s storefront (AGL-1904). Same statutory retention, same access obligation.',\n },\n {\n collection: 'posHardwareSales',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'The platform’s record of each card reader order the org bought from the hardware shop (AGL-4038): lines, amounts, tax, Stripe ids, status dates and the country, state and postal code it shipped to — never the buyer. Kept past ERASURE as a tax and accounting record, GDPR Art. 17(3)(b); disclosed on ACCESS like the other two.',\n },\n // ── Records of our own handling ───────────────────────────────────────\n {\n collection: 'adminAudit',\n keyedBy: 'field',\n subjects: ['org', 'user'],\n exported: false,\n note: 'STAFF-ONLY. Rows name the staff actor, carry override reasons and internal notes, and are the record of our handling rather than data about the subject. `/admin/audit` → Export CSV serves a request that specifically asks for them, after a staff read.',\n },\n]\n\n/** Sources this export deliberately withholds, with the reason. */\nexport const EXPORT_WITHHELD = PERSONAL_DATA_SOURCES.filter((s) => !s.exported)\n\n/** Collection names the export claims to cover, for the coverage guard. */\nexport const EXPORT_COVERED_COLLECTIONS: readonly string[] =\n PERSONAL_DATA_SOURCES.map((source) => source.collection)\n\n/**\n * ## WHY THIS IS SHAPE-DRIVEN AND NOT A LIST OF NAMES\n *\n * It used to be a list of names, anchored on separators:\n *\n * /(^|[._-])(secret|token|password|apikey|…)($|[._-])/i\n *\n * That pattern requires a `.`, `_`, `-`, or a string boundary on both sides\n * of the word, so it reads `password_hash` and `webhooks.secret` and misses\n * `supplierToken` and `passwordScrypt` — the exact two fields the AGL-1881\n * review found leaving the platform in a customer's own export file. One is\n * a live bearer credential a supplier authenticates with; the other is a\n * shopper's scrypt password hash. **A denylist of names is always one naming\n * convention behind, and camelCase is the proof.**\n *\n * So the name half is now tokenized rather than separator-anchored, and it is\n * no longer the only gate. Three run, in order, and any of them redacts:\n *\n * * **(A) The name, tokenized.** `supplierToken` splits to\n * `['supplier','token']` the same way `supplier_token` and\n * `SUPPLIER-TOKEN` do, so the convention stops mattering. A name matches\n * on a single secret word or on an adjacent pair (`client secret`).\n * * **(B) The VALUE's shape, whatever the key is called.** This is the half\n * that does not need to know the schema: a PEM block, a JWT, a vendor\n * prefix (`sk_live_`, `whsec_`, `ghp_`, `AKIA`…), a `$2b$`/`$argon2` hash,\n * this repo's own `salt:hash` scrypt form, or an opaque high-entropy\n * string is a credential whether the field is called `supplierToken`,\n * `t`, or `notes`. **Gate B is the \"redact unless known safe\" default**:\n * a credential-shaped string is withheld unless its key names it as a\n * content identifier (see {@link SAFE_VALUE_WORDS}).\n * * **(C) Credentials carried inside a URL.** `?token=`, `?sig=`,\n * `?key=`, and `https://user:pass@host` are stripped from the URL rather\n * than the URL being blanked, because a media object's `url` field really\n * does carry a live Firebase download token in a query parameter, and the\n * location of the customer's own file is exactly what an access request\n * asks for. Precision beats blanking here.\n *\n * ### Why the KEY half is still deny-based, when the value half is not\n *\n * A true allowlist of field names is not available on this data. The export\n * walks documents whose field names our customers author — canvas nodes,\n * dataset records, custom metadata, form submissions — so an allowlist of\n * names would blank most of the file and turn an access request into a\n * non-answer, which is the under-disclosure this feature exists to stop. The\n * allowlist therefore lives where the vocabulary IS ours: value shapes. An\n * unrecognized VALUE shape is passed through (it is prose, a number, a date,\n * a customer's own content); an unrecognized value shape that looks like a\n * credential is withheld. That is the inversion the review asked for, put\n * where it can hold.\n *\n * ### The one deliberate carve-out\n *\n * `token`/`tokens` is also a metering word — `tokensUsed: 14203` on an\n * assist exchange is a usage count, and blanking it would blank a real\n * disclosure. A credential is a STRING; a count is a number. So a numeric or\n * boolean value under a name that matched only on a metering word passes\n * through. Nothing else in the vocabulary gets that treatment.\n *\n * A false positive costs a redacted field in an export. A false negative\n * costs a credential. Everything below is tuned in that direction.\n */\n\n/**\n * Split a field name into lowercase word tokens, convention-independently.\n *\n * `supplierToken`, `supplier_token`, `SUPPLIER-TOKEN` and `Supplier.Token`\n * all become `['supplier','token']`. Acronym runs split at the last capital\n * (`SSOTokenId` → `['sso','token','id']`) and digits break a word\n * (`apiKey2` → `['api','key','2']`), so a numbered field cannot hide.\n */\nexport function fieldNameTokens(key: unknown): string[] {\n return String(key ?? '')\n .replace(/[^A-Za-z0-9]+/g, ' ')\n .replace(/([a-z0-9])([A-Z])/g, '$1 $2')\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')\n .replace(/([A-Za-z])([0-9])/g, '$1 $2')\n .toLowerCase()\n .split(' ')\n .filter(Boolean)\n}\n\n/**\n * Words that make a field a credential on their own.\n *\n * Deliberately short. Every entry here is a word that has no innocent\n * meaning on a stored VALUE — `hmac`, `scrypt` and `bcrypt` name the\n * algorithm that produced a verifier, `passphrase` and `credential` name the\n * thing itself. `key` is NOT here and must never be: `publicKey` on a\n * passkey and `sortKey` on a dataset are not secrets, which is what\n * {@link SECRET_WORD_PAIRS} is for.\n */\nconst SECRET_WORDS = new Set([\n 'secret',\n 'secrets',\n 'password',\n 'passwords',\n 'passwd',\n 'pwd',\n 'passphrase',\n 'token',\n 'tokens',\n 'credential',\n 'credentials',\n 'apikey',\n 'privatekey',\n 'scrypt',\n 'bcrypt',\n 'argon',\n 'argon2',\n 'pbkdf2',\n 'hmac',\n 'otp',\n 'totp',\n 'authorization',\n])\n\n/**\n * Words that are a credential only next to another word.\n *\n * `key` is meaningless alone and decisive after `api`, `private`, `signing`,\n * `secret`, `session` or `encryption`; `token` after `access`/`refresh` is\n * already caught by {@link SECRET_WORDS} and listed here anyway so the pair\n * table reads as the complete statement of the rule.\n */\nconst SECRET_WORD_PAIRS = new Set([\n 'api key',\n 'private key',\n 'signing key',\n 'secret key',\n 'session key',\n 'encryption key',\n 'client secret',\n 'access token',\n 'refresh token',\n 'webhook secret',\n 'shared secret',\n // A Stripe payment link is a live bearer URL: whoever holds it can pay.\n // Named in the AGL-1443 inventory of what the old dump actually carried.\n 'payment link',\n // A Zapier REST hook's `targetUrl` (AGL-3643) is the same kind of bearer\n // URL: whoever holds it can post into the Zap, and its secret is in the\n // path, which the URL scrub does not read.\n 'target url',\n 'auth code',\n 'recovery code',\n 'backup code',\n])\n\n/**\n * The metering carve-out — see the header. A name that matched ONLY on one\n * of these, over a number or a boolean, is a count and is disclosed.\n */\nconst METERING_WORDS = new Set(['token', 'tokens'])\n\n/**\n * Key words that mark a high-entropy value as a content identifier rather\n * than a credential, defusing gate (B) only.\n *\n * A SHA-256 has exactly the shape of a 64-character secret and is not one.\n * Gate (A) is never defused by this list: `apiKeyId` is redacted, because\n * the name says credential and an id of a credential is not worth the\n * argument.\n */\nconst SAFE_VALUE_WORDS = new Set([\n // A passkey's `publicKey` is public by definition and has exactly the shape\n // of a secret. Safe to list because gate (A) is never defused here — a\n // `publicToken` is still redacted, on the strength of `token`.\n 'public',\n 'id',\n 'ids',\n 'uid',\n 'uuid',\n 'guid',\n 'hash',\n 'hashes',\n 'sha',\n 'sha1',\n 'sha256',\n 'sha512',\n 'md5',\n 'crc',\n 'crc32c',\n 'etag',\n 'checksum',\n 'digest',\n 'fingerprint',\n 'generation',\n 'version',\n 'revision',\n 'slug',\n 'path',\n 'url',\n 'uri',\n 'href',\n 'src',\n 'color',\n 'colour',\n 'hex',\n])\n\n/** Vendor credential prefixes — unambiguous, and worth naming explicitly. */\nconst CREDENTIAL_PREFIXES = [\n 'sk_live_',\n 'sk_test_',\n 'rk_live_',\n 'rk_test_',\n 'whsec_',\n 'ghp_',\n 'gho_',\n 'ghu_',\n 'ghs_',\n 'ghr_',\n 'github_pat_',\n 'xoxb-',\n 'xoxp-',\n 'xapp-',\n 'xoxa-',\n 'AKIA',\n 'ASIA',\n 'AIza',\n 'ya29.',\n 'SG.',\n 're_',\n 'shpat_',\n 'shpss_',\n 'npm_',\n 'glpat-',\n 'sq0csp-',\n 'sq0atp-',\n]\n\n/** A PEM block that carries a private key or a certificate request. */\nconst PEM_PATTERN = /-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----/\n\n/** Modular crypt format: bcrypt, argon2, scrypt, PBKDF2, sha512-crypt. */\nconst CRYPT_HASH_PATTERN = /^\\$(2[abxy]?|argon2[a-z]*|scrypt|pbkdf2[^$]*|[56])\\$/\n\n/** This repo's own scrypt storage form: `{16+ hex salt}:{32+ hex hash}`. */\nconst SALTED_HASH_PATTERN = /^[0-9a-f]{16,}:[0-9a-f]{32,}$/i\n\n/** A JSON Web Token — three base64url segments. */\nconst JWT_PATTERN = /^[A-Za-z0-9_-]{8,}\\.[A-Za-z0-9_-]{8,}\\.[A-Za-z0-9_-]{8,}$/\n\n/** A UUID, which is an identifier far more often than it is a credential. */\nconst UUID_PATTERN =\n /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i\n\n/** Charset of an opaque credential: base64, base64url or hex, nothing else. */\nconst OPAQUE_CHARSET = /^[A-Za-z0-9_+/=-]+$/\n\n/**\n * The window an opaque secret lives in.\n *\n * Below 32 characters the false-positive rate against ordinary identifiers is\n * not worth it and the value is too short to be a modern credential anyway.\n * Above 512 it is customer CONTENT — a base64 image, a compressed canvas\n * blob, an encoded document — and blanking those is the \"gutting the export\"\n * failure this file is explicitly trying not to commit.\n */\nconst OPAQUE_MIN_LENGTH = 32\nconst OPAQUE_MAX_LENGTH = 512\n\n/** Shannon entropy per character. Prose and slugs sit well below this. */\nconst OPAQUE_MIN_ENTROPY = 3.2\n\nfunction shannonEntropyPerChar(text: string): number {\n const counts = new Map<string, number>()\n for (const character of text) {\n counts.set(character, (counts.get(character) ?? 0) + 1)\n }\n let entropy = 0\n for (const count of counts.values()) {\n const p = count / text.length\n entropy -= p * Math.log2(p)\n }\n return entropy\n}\n\n/**\n * Does this STRING look like a credential, ignoring what it is called?\n *\n * Exported because the guard spec asserts each limb independently — a shape\n * detector tested only through the redactor is a detector whose gaps are\n * invisible.\n */\nexport function looksLikeCredential(value: string): boolean {\n const text = value.trim()\n if (!text) return false\n if (PEM_PATTERN.test(text)) return true\n if (CRYPT_HASH_PATTERN.test(text)) return true\n if (SALTED_HASH_PATTERN.test(text)) return true\n if (CREDENTIAL_PREFIXES.some((prefix) => text.startsWith(prefix))) return true\n if (JWT_PATTERN.test(text)) return true\n // Anything with whitespace is prose, and `data:` is an inline asset. Both\n // are customer content, and neither is a bearer credential.\n if (/\\s/.test(text)) return false\n if (/^data:/i.test(text)) return false\n if (UUID_PATTERN.test(text)) return false\n if (text.length < OPAQUE_MIN_LENGTH || text.length > OPAQUE_MAX_LENGTH) {\n return false\n }\n if (!OPAQUE_CHARSET.test(text)) return false\n return shannonEntropyPerChar(text) >= OPAQUE_MIN_ENTROPY\n}\n\n/** What a stripped URL parameter reads as, so the removal is visible. */\nexport const REDACTED_URL_PARAM = 'REDACTED'\n\n/** Query parameters that carry a bearer credential inside a URL. */\nconst URL_CREDENTIAL_PARAMS = new Set([\n 'token',\n 'access_token',\n 'accesstoken',\n 'id_token',\n 'refresh_token',\n 'auth',\n 'authorization',\n 'apikey',\n 'api_key',\n 'key',\n 'sig',\n 'signature',\n 'secret',\n 'password',\n 'downloadtoken',\n])\n\n/**\n * Strip the credential out of a URL, keeping the URL.\n *\n * A media object's `url` is `…/o/{path}?alt=media&token={uuid}` — a live,\n * unauthenticated download credential, in a field an access request has a\n * real interest in. Blanking the whole value would tell the customer nothing\n * about where their own file is; keeping it whole hands out the credential.\n * So the parameter is replaced and the rest survives. `user:pass@` userinfo\n * goes the same way.\n *\n * Returns the input unchanged when it is not a URL — every non-URL string\n * has already been decided by the shape gate.\n */\nexport function scrubUrlCredentials(value: string): string {\n if (!/^https?:\\/\\//i.test(value)) return value\n let url: URL\n try {\n url = new URL(value)\n } catch {\n return value\n }\n let changed = false\n if (url.username || url.password) {\n url.username = ''\n url.password = ''\n changed = true\n }\n for (const name of Array.from(url.searchParams.keys())) {\n if (!URL_CREDENTIAL_PARAMS.has(name.toLowerCase())) continue\n if (!url.searchParams.get(name)) continue\n url.searchParams.set(name, REDACTED_URL_PARAM)\n changed = true\n }\n return changed ? url.toString() : value\n}\n\n/**\n * Gate (A): does the NAME say credential?\n *\n * `value` is consulted only for the metering carve-out described in the\n * header — a `tokensUsed: 14203` is a count, not a credential.\n */\nexport function secretByName(key: unknown, value?: unknown): boolean {\n const tokens = fieldNameTokens(key)\n if (!tokens.length) return false\n const hits = tokens.filter((token) => SECRET_WORDS.has(token))\n for (let index = 0; index + 1 < tokens.length; index += 1) {\n if (SECRET_WORD_PAIRS.has(`${tokens[index]} ${tokens[index + 1]}`)) {\n return true\n }\n }\n if (!hits.length) return false\n // Matched only on a metering word, over a number or a boolean: a count.\n const metering = hits.every((token) => METERING_WORDS.has(token))\n if (metering && (typeof value === 'number' || typeof value === 'boolean')) {\n return false\n }\n return true\n}\n\n/** Gate (B)'s defuser: does the NAME say this high-entropy value is an id? */\nfunction nameMarksContentIdentifier(key: unknown): boolean {\n return fieldNameTokens(key).some((token) => SAFE_VALUE_WORDS.has(token))\n}\n\n/** What a redacted value is replaced with — presence, never content. */\nexport interface RedactedValue {\n redacted: true\n /** Whether a value was actually there, so absence is distinguishable. */\n present: boolean\n reason: 'secret'\n}\n\nconst redactedMarker = (present: boolean): RedactedValue => ({\n redacted: true,\n present,\n reason: 'secret',\n})\n\n/**\n * Deep-copy a document, replacing every credential-shaped value with a\n * presence marker.\n *\n * Presence rather than deletion, because \"we hold a webhook secret for you\"\n * is itself a true and disclosable fact, and a silently-absent key would make\n * the export look like it holds less than it does — the under-disclosure this\n * feature exists to stop, reintroduced by the safety measure.\n *\n * Firestore values that are not plain JSON (Timestamp, GeoPoint, DocumentRef,\n * Buffer) are stringified rather than walked: they carry no nested keys to\n * redact, and `JSON.stringify` on a Timestamp yields `{_seconds,_nanoseconds}`,\n * which is not a date to a human reading the file.\n *\n * Three gates, any of which redacts — the name (A), the value's shape (B),\n * and a credential embedded in a URL (C). See the header above\n * {@link fieldNameTokens} for why the value half is the one that carries the\n * \"withhold unless known safe\" default.\n */\nexport function redactSecrets(value: unknown, key = ''): unknown {\n // (A) The name, tokenized — convention-independent.\n if (key && secretByName(key, value)) {\n return redactedMarker(value !== undefined && value !== null && value !== '')\n }\n if (value === null || value === undefined) return value ?? null\n if (typeof value === 'string') {\n // (C) A URL that carries its credential in a parameter keeps the URL and\n // loses the credential — see {@link scrubUrlCredentials}.\n const scrubbed = scrubUrlCredentials(value)\n if (scrubbed !== value) return scrubbed\n // (B) The shape, whatever the field is called. Withheld unless the name\n // marks it as a content identifier.\n if (looksLikeCredential(value) && !nameMarksContentIdentifier(key)) {\n return redactedMarker(true)\n }\n return value\n }\n if (Array.isArray(value)) return value.map((entry) => redactSecrets(entry, key))\n if (typeof value === 'object') {\n const source = value as Record<string, unknown>\n // Firestore Timestamp — the only non-plain value common enough to be\n // worth rendering rather than dumping.\n if (typeof (source as any).toDate === 'function') {\n try {\n return (source as any).toDate().toISOString()\n } catch {\n return String(value)\n }\n }\n if (typeof (source as any).toBase64 === 'function') return '[binary]'\n const out: Record<string, unknown> = {}\n for (const [childKey, childValue] of Object.entries(source)) {\n out[childKey] = redactSecrets(childValue, childKey)\n }\n return out\n }\n return value\n}\n\nexport interface ExportedDocument {\n /** Document id — omitted where the id is itself a secret (see `apiKeys`). */\n id?: string\n path?: string\n data: unknown\n}\n\nexport interface PersonalDataExport {\n subject: { type: ExportSubject; id: string }\n generatedAt: string\n /**\n * The disclosure decision for every source, copied into the file the\n * customer receives. An export that silently omits a collection is\n * indistinguishable from one that has nothing to report; this makes the two\n * different, and it is what a supervisory authority would ask to see.\n */\n coverage: readonly ExportSourceSpec[]\n /** Collection name → the documents disclosed for it. */\n data: Record<string, ExportedDocument[]>\n /** Collection name → row count, for sources disclosed as a count only. */\n counts: Record<string, number>\n /** Places we hold data that is not in Firestore. */\n elsewhere: readonly string[]\n}\n\n/** Data we hold outside Firestore — named, because a file that omits them reads as complete. */\nconst ELSEWHERE = [\n 'Stripe — customer object, payment methods, invoices. Request from Stripe or ask us.',\n 'Resend — transactional email delivery logs.',\n 'Google Analytics — 14-month retention, not keyed to an account.',\n 'Cloud Storage — uploaded media and avatars, under users/{uid}/, orgs/{orgId}/ and hosts/{hostId}/. Listed by path in this file; the bytes are served by their own URLs.',\n]\n\nfunction sourcesFor(subject: ExportSubject): ExportSourceSpec[] {\n return PERSONAL_DATA_SOURCES.filter((source) => source.subjects.includes(subject))\n}\n\n/** Read a top-level collection bounded by a field equal to the subject id. */\nasync function readByField(\n db: any,\n collection: string,\n field: string,\n id: string,\n options: { includeIds?: boolean } = {},\n): Promise<ExportedDocument[]> {\n const rows = await db.collection(collection).where(field, '==', id).get()\n return rows.docs.map((doc: any) => ({\n // `apiKeys` document ids are the SHA-256 of the token: an id handed back\n // is a verifier handed back, so the caller opts in rather than out.\n ...(options.includeIds === false ? {} : { id: doc.id }),\n data: redactSecrets(doc.data()),\n }))\n}\n\n/** Read one document by id, or nothing when it does not exist. */\nasync function readDoc(\n db: any,\n collection: string,\n id: string,\n): Promise<ExportedDocument[]> {\n const snapshot = await db.collection(collection).doc(id).get()\n if (!snapshot.exists) return []\n return [{ id, data: redactSecrets(snapshot.data()) }]\n}\n\n/**\n * Walk a document and everything beneath it.\n *\n * `listCollections()` rather than a hard-coded subcollection list, for the\n * same reason the erasure uses `recursiveDelete`: a subcollection added next\n * quarter is reached without anybody remembering this file exists. Bounded by\n * `maxDepth` because the tree is customer-shaped and an unbounded recursion\n * inside a request is how AGL-1455 lost erasures to a 60-second timeout.\n */\nasync function readSubtree(\n db: any,\n ref: any,\n depth = 0,\n maxDepth = 4,\n): Promise<ExportedDocument[]> {\n const snapshot = await ref.get()\n const found: ExportedDocument[] = []\n if (snapshot.exists) {\n found.push({ path: ref.path, data: redactSecrets(snapshot.data()) })\n }\n if (depth >= maxDepth) return found\n const children = (await ref.listCollections?.()) ?? []\n for (const child of children) {\n const rows = await child.get()\n for (const doc of rows.docs) {\n found.push(...(await readSubtree(db, doc.ref, depth + 1, maxDepth)))\n }\n }\n return found\n}\n\nexport interface ExportOptions {\n /** Injectable for tests; defaults to the admin app's Firestore. */\n firestore?: any\n /** Stops a pathological workspace from building an unbounded file. */\n maxDepth?: number\n}\n\n/**\n * Everything we hold about a PERSON, as the person themselves may ask for it\n * (GDPR Art. 15 and Art. 20).\n *\n * Scoped to them, never to the workspaces they belong to. Their membership row\n * in each org is theirs; the roster around it is their colleagues'. An org\n * export is a separate call with a separate authorization, which is the whole\n * reason the two are different functions rather than one with a flag.\n */\nexport async function exportUserData(\n uid: string,\n options: ExportOptions = {},\n): Promise<PersonalDataExport> {\n const db = options.firestore ?? firestoreApp()\n const data: Record<string, ExportedDocument[]> = {}\n const counts: Record<string, number> = {}\n\n // The profile tree — `users/{uid}` and every subcollection under it.\n data['users'] = await readSubtree(\n db,\n db.collection('users').doc(uid),\n 0,\n options.maxDepth ?? 4,\n )\n\n // The public identity, which the user tree does not reach (AGL-1970).\n data['profiles'] = await readDoc(db, 'profiles', uid)\n\n // ONLY the messages this person wrote. The threads belong to a workspace\n // and carry other people's words; handing a member the whole conversation\n // to answer their own access request is a disclosure nobody consented to.\n const messages = await db\n .collectionGroup('messages')\n .where('authorId', '==', uid)\n .get()\n .catch(() => ({ docs: [] as any[] }))\n data['supportTickets'] = messages.docs.map((doc: any) => ({\n path: doc.ref.path,\n data: redactSecrets(doc.data()),\n }))\n\n return {\n subject: { type: 'user', id: uid },\n generatedAt: new Date().toISOString(),\n coverage: sourcesFor('user'),\n data,\n counts,\n elsewhere: ELSEWHERE,\n }\n}\n\n/**\n * Everything we hold about a WORKSPACE, for its owner (Art. 15 for the\n * personal data in it, and the \"export before you delete\" the Delete tab,\n * DPA §11 and Terms §13.3 have been promising).\n *\n * Every top-level collection the erasure sweeps by `orgId` is read here by the\n * same bound, so the two see the same rows. Where a source is withheld, its\n * COUNT is still reported: a collection that appears in neither the data nor\n * the counts is indistinguishable from one that does not exist, and that\n * ambiguity is what makes an incomplete export undetectable.\n */\nexport async function exportOrgData(\n orgId: string,\n options: ExportOptions = {},\n): Promise<PersonalDataExport> {\n const db = options.firestore ?? firestoreApp()\n const data: Record<string, ExportedDocument[]> = {}\n const counts: Record<string, number> = {}\n\n data['orgs'] = await readSubtree(\n db,\n db.collection('orgs').doc(orgId),\n 0,\n options.maxDepth ?? 4,\n )\n\n // Sites: the routing entry and the whole tree for each.\n const hosts = await db.collection('hosts').where('orgId', '==', orgId).get()\n const hostDocs: ExportedDocument[] = []\n const routing: ExportedDocument[] = []\n const outbox: ExportedDocument[] = []\n for (const host of hosts.docs) {\n hostDocs.push(...(await readSubtree(db, host.ref, 0, options.maxDepth ?? 4)))\n routing.push(...(await readDoc(db, 'hostIndex', host.id)))\n // Keyed by `hostId`, not `orgId`, so it is read here rather than in the\n // field-keyed loop below — the same bound `eraseHostSupplierDeliveries`\n // sweeps by, so the export and the erasure see the same rows.\n outbox.push(...(await readByField(db, 'supplierDeliveries', 'hostId', host.id)))\n }\n data['hosts'] = hostDocs\n data['hostIndex'] = routing\n data['supplierDeliveries'] = outbox\n\n // The field-keyed collections a path cascade is blind to — the ones the\n // erasure had to grow a sweep for, one issue at a time.\n for (const collection of [\n 'ssoDomains',\n CONSOLE_DOMAINS_COLLECTION,\n 'stripeCustomers',\n 'orgSlugs',\n 'publisherHandles',\n 'platformRevenue',\n 'storefrontTaxCollected',\n 'posHardwareSales',\n ]) {\n data[collection] = await readByField(db, collection, 'orgId', orgId)\n }\n\n // Existence, never the credential — and not the id either, which is the\n // token's SHA-256.\n data['apiKeys'] = await readByField(db, 'apiKeys', 'orgId', orgId, {\n includeIds: false,\n })\n\n // Which mailboxes the reps connected, never the grant behind one: the\n // tokens are withheld by `redactSecrets` like every other read here. The id\n // is the mailbox's own, so unlike `apiKeys` it stays.\n data['outreachMailboxCredentials'] = await readByField(\n db,\n 'outreachMailboxCredentials',\n 'orgId',\n orgId,\n )\n\n // Where each short tracking link the org's sequences sent points (AGL-3297).\n data['outreachLinks'] = await readByField(db, 'outreachLinks', 'orgId', orgId)\n\n // Shipping (AGL-3612), tax services (AGL-3631), marketing platforms\n // (AGL-3639) and help desks (AGL-3824): top-level and keyed by `orgId`, the bound their\n // `orgKeyedCollections` erasure sweeps by. The sealed credentials are\n // withheld by `redactSecrets` on their names.\n for (const collection of [\n 'shippingTrackers',\n 'shippingQuoteCache',\n 'taxEngineConnections',\n 'taxEngineProductCodes',\n 'taxEngineExemptions',\n 'taxEngineTransactions',\n 'marketingPlatformConnections',\n 'marketingPlatformEvents',\n 'helpDeskConnections',\n 'helpDeskOutbox',\n 'helpDeskCustomers',\n 'adConversionConnections',\n 'adConversionConsents',\n 'adConversionEvents',\n 'fulfillmentNetworkConnections',\n 'fulfillmentNetworkOrders',\n 'courierConnections',\n 'courierDeliveries',\n 'marketplaceConnections',\n 'marketplaceOrders',\n 'inventorySyncConnections',\n 'inventorySyncOrders',\n 'inventorySyncProducts',\n 'podConnections',\n 'podProductLinks',\n 'podOrders',\n 'deliveryAppStores',\n 'deliveryAppOrders',\n 'domainRegistrations',\n 'domainConnectSessions',\n 'posCellularReaders',\n 'posCellularCharges',\n ]) {\n data[collection] = await readByField(db, collection, 'orgId', orgId)\n }\n\n data['publisherProfiles'] = await readDoc(db, 'publisherProfiles', orgId)\n data['marketplaceListings'] = await readByField(\n db,\n 'marketplaceListings',\n 'profileId',\n orgId,\n )\n\n // Support threads WITH their messages — for an org the whole thread is the\n // org's own record, unlike the person-scoped export above.\n const tickets = await db\n .collection('supportTickets')\n .where('orgId', '==', orgId)\n .get()\n const ticketDocs: ExportedDocument[] = []\n for (const ticket of tickets.docs) {\n // Not a Site Care request's staff-only intake (AGL-4031): which other\n // workspaces its sender belongs to is the sender's, not this org's.\n const staffOnly = `/${SITE_CARE_STAFF_COLLECTION}/`\n ticketDocs.push(...(await readSubtree(db, ticket.ref, 0, 2)).filter((found) => !found.path.includes(staffOnly)))\n }\n data['supportTickets'] = ticketDocs\n\n // Withheld, but counted — see the note on this function.\n const replayKeys = await db\n .collection('apiIdempotency')\n .where('orgId', '==', orgId)\n .get()\n counts['apiIdempotency'] = replayKeys.docs.length\n\n return {\n subject: { type: 'org', id: orgId },\n generatedAt: new Date().toISOString(),\n coverage: sourcesFor('org'),\n data,\n counts,\n elsewhere: ELSEWHERE,\n }\n}\n\n/** A filename a human can file: subject, id and the date it was produced. */\nexport function exportFilename(exported: PersonalDataExport): string {\n const day = exported.generatedAt.slice(0, 10)\n return `aglyn-${exported.subject.type}-data-${exported.subject.id}-${day}.json`\n}\n\nexport default exportUserData\n"],"names":["SITE_CARE_STAFF_COLLECTION","firebaseAdmin","CONSOLE_DOMAINS_COLLECTION","firestoreApp","app","firestore","PERSONAL_DATA_SOURCES","collection","keyedBy","subjects","exported","note","EXPORT_WITHHELD","filter","s","EXPORT_COVERED_COLLECTIONS","map","source","fieldNameTokens","key","String","replace","toLowerCase","split","Boolean","SECRET_WORDS","Set","SECRET_WORD_PAIRS","METERING_WORDS","SAFE_VALUE_WORDS","CREDENTIAL_PREFIXES","PEM_PATTERN","CRYPT_HASH_PATTERN","SALTED_HASH_PATTERN","JWT_PATTERN","UUID_PATTERN","OPAQUE_CHARSET","OPAQUE_MIN_LENGTH","OPAQUE_MAX_LENGTH","OPAQUE_MIN_ENTROPY","shannonEntropyPerChar","text","counts","Map","character","set","get","entropy","count","values","p","length","Math","log2","looksLikeCredential","value","trim","test","some","prefix","startsWith","REDACTED_URL_PARAM","URL_CREDENTIAL_PARAMS","scrubUrlCredentials","url","URL","changed","username","password","name","Array","from","searchParams","keys","has","toString","secretByName","tokens","hits","token","index","metering","every","nameMarksContentIdentifier","redactedMarker","present","redacted","reason","redactSecrets","undefined","scrubbed","isArray","entry","toDate","toISOString","toBase64","out","childKey","childValue","Object","entries","ELSEWHERE","sourcesFor","subject","includes","readByField","db","field","id","options","rows","where","docs","doc","includeIds","data","readDoc","snapshot","exists","readSubtree","ref","depth","maxDepth","found","push","path","children","listCollections","child","exportUserData","uid","messages","collectionGroup","catch","type","generatedAt","Date","coverage","elsewhere","exportOrgData","orgId","hosts","hostDocs","routing","outbox","host","tickets","ticketDocs","ticket","staffOnly","replayKeys","exportFilename","day","slice"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0DC,GAED,SAASA,0BAA0B,QAAQ,mCAAkC;AAC7E,SAASC,aAAa,QAAQ,sBAAkB;AAChD,SAASC,0BAA0B,QAAQ,uBAAmB;AAE9D,MAAMC,eAAe,IAAMF,cAAcG,GAAG,GAAGC,SAAS;AAiCxD;;;;;;CAMC,GACD,OAAO,MAAMC,wBAAqD;IAChE,yEAAyE;IACzE;QACEC,YAAY;QACZC,SAAS;QACTC,UAAU;YAAC;SAAO;QAClBC,UAAU;QACVC,MAAM;IACR;IACA;QACEJ,YAAY;QACZC,SAAS;QACTC,UAAU;YAAC;SAAO;QAClBC,UAAU;QACVC,MAAM;IACR;IACA,yEAAyE;IACzE;QACEJ,YAAY;QACZC,SAAS;QACTC,UAAU;YAAC;SAAM;QACjBC,UAAU;QACVC,MAAM;IACR;IACA;QACEJ,YAAY;QACZC,SAAS;QACTC,UAAU;YAAC;SAAM;QACjBC,UAAU;QACVC,MAAM;IACR;IACA;QACEJ,YAAY;QACZC,SAAS;QACTC,UAAU;YAAC;SAAM;QACjBC,UAAU;QACVC,MAAM;IACR;IACA;QACEJ,YAAY;QACZC,SAAS;QACTC,UAAU;YAAC;SAAM;QACjBC,UAAU;QACVC,MAAM;IACR;IACA,yEAAyE;IACzE;QACEJ,YAAY;QACZC,SAAS;QACTC,UAAU;YAAC;SAAM;QACjBC,UAAU;QACVC,MAAM;IACR;IACA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AI;IAChC;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA,wEAAwE;IACxE,yEAAyE;IACzE;IACA,yEAAyE;IACzE,wEAAwE;IACxE,2CAA2C;IAC3C;IACA;IACA;IACA;CACD;AAED;;;CAGC,GACD,MAAME,iBAAiB,IAAIF,IAAI;IAAC;IAAS;CAAS;AAElD;;;;;;;;CAQC,GACD,MAAMG,mBAAmB,IAAIH,IAAI;IAC/B,4EAA4E;IAC5E,uEAAuE;IACvE,+DAA+D;IAC/D;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAED,2EAA2E,GAC3E,MAAMI,sBAAsB;IAC1B;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAED,qEAAqE,GACrE,MAAMC,cAAc;AAEpB,wEAAwE,GACxE,MAAMC,qBAAqB;AAE3B,0EAA0E,GAC1E,MAAMC,sBAAsB;AAE5B,iDAAiD,GACjD,MAAMC,cAAc;AAEpB,2EAA2E,GAC3E,MAAMC,eACJ;AAEF,6EAA6E,GAC7E,MAAMC,iBAAiB;AAEvB;;;;;;;;CAQC,GACD,MAAMC,oBAAoB;AAC1B,MAAMC,oBAAoB;AAE1B,wEAAwE,GACxE,MAAMC,qBAAqB;AAE3B,SAASC,sBAAsBC,IAAY;IACzC,MAAMC,SAAS,IAAIC;IACnB,KAAK,MAAMC,aAAaH,KAAM;YACLC;QAAvBA,OAAOG,GAAG,CAACD,WAAW,EAACF,cAAAA,OAAOI,GAAG,CAACF,sBAAXF,cAAyB,KAAK;IACvD;IACA,IAAIK,UAAU;IACd,KAAK,MAAMC,SAASN,OAAOO,MAAM,GAAI;QACnC,MAAM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AG,EAAC,EAAG3G,MAAM,CAAC,CAAC8G,QAAU,CAACA,MAAME,IAAI,CAACrB,QAAQ,CAAC6C;IACtG;IACAlC,IAAI,CAAC,iBAAiB,GAAGgC;IAEzB,yDAAyD;IACzD,MAAMG,aAAa,MAAM5C,GACtBnG,UAAU,CAAC,kBACXwG,KAAK,CAAC,SAAS,MAAM6B,OACrB9F,GAAG;IACNJ,MAAM,CAAC,iBAAiB,GAAG4G,WAAWtC,IAAI,CAAC7D,MAAM;IAEjD,OAAO;QACLoD,SAAS;YAAE+B,MAAM;YAAO1B,IAAIgC;QAAM;QAClCL,aAAa,IAAIC,OAAO1C,WAAW;QACnC2C,UAAUnC,WAAW;QACrBa;QACAzE;QACAgG,WAAWrC;IACb;AACF;AAEA,2EAA2E,GAC3E,OAAO,SAASkD,eAAe7I,QAA4B;IACzD,MAAM8I,MAAM9I,SAAS6H,WAAW,CAACkB,KAAK,CAAC,GAAG;IAC1C,OAAO,CAAC,MAAM,EAAE/I,SAAS6F,OAAO,CAAC+B,IAAI,CAAC,MAAM,EAAE5H,SAAS6F,OAAO,CAACK,EAAE,CAAC,CAAC,EAAE4C,IAAI,KAAK,CAAC;AACjF;AAEA,eAAevB,eAAc"}
1
+ {"version":3,"sources":["../../../../../../../../libs/tenant/data/admin/src/lib/server/personal-data-export.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 * Personal-data export — access and portability, in a machine-readable form\n * (AGL-1974).\n *\n * Privacy Policy §7 grants portability (GDPR Art. 20) and nothing in the\n * product exported a person's or a workspace's personal data. Six surfaces\n * told customers to \"export first\" before deleting — the org settings Delete\n * tab, the Close account card, `erase-org-cli.mjs`, the staff org actions,\n * live DPA §11 and Terms §13.3 — all pointing at something that did not\n * exist. An access request was assembled by a staff member reading the console\n * by hand.\n *\n * ## THE PROPERTY THIS FILE EXISTS FOR\n *\n * **An export whose coverage differs from erasure's is a bug in one of them.**\n * Both answer the same question — *what do we hold about this subject* — and\n * the honest failure modes are symmetric: an export that misses a collection\n * under-discloses on an access request, and an erasure that misses the same\n * one leaves data behind after we said it was gone. Historically the second\n * kept happening (AGL-1444, AGL-1448, AGL-1970, AGL-1971 each found a\n * collection outside the cascade), which is exactly the evidence that a list\n * kept in one place and mirrored by hand in another will drift.\n *\n * The ideal is one enumeration both derive from. That is not available here:\n * `erase.ts` is under concurrent change and its sweep list is expressed as\n * code, not data. So the coverage is enumerated ONCE below, as data, and\n * `personal-data-export-coverage.spec.ts` DISCOVERS every collection\n * `erase.ts` touches out of its source and fails when the two disagree. A new\n * sweep added to the erasure turns this file red until somebody decides\n * whether the export discloses it — which is the decision that was being\n * skipped.\n *\n * That guard is worth more than the feature.\n *\n * ## What must NOT come out wholesale\n *\n * Three categories, and each is a way an access request becomes a breach:\n *\n * 1. **Another person's data.** A workspace is shared. A member asking what\n * we hold about THEM gets their own roster row, not the roster; their own\n * support messages, not the thread's other authors. Handled by exporting\n * the person and the workspace as different subjects with different\n * scopes, never by filtering a single blob after the fact.\n * 2. **Secrets.** An `apiKeys` row confirms that a credential exists — its\n * label, scopes, creator and dates, which are all facts about the subject\n * — and never re-discloses the credential. Note the document ID *is* the\n * SHA-256 of the token, so the id itself is withheld too; a hash handed\n * back is a verifier handed back.\n * 3. **Staff-only fields.** Internal notes, override reasons and moderation\n * state are about our handling, not about the person, and several name a\n * staff member.\n *\n * ## What it is NOT\n *\n * Not `GET /api/hosts/export` — that is a Pro+ site-design backup whose own\n * header says it never includes bookings, leads, submissions or secrets, and\n * offering it as a portability answer would be misdescribing it. Not the\n * `firestore-export` cron, which is an unscoped DR snapshot. Not the audit CSV.\n */\n\nimport { SITE_CARE_STAFF_COLLECTION } from '@aglyn/aglyn/app-utils/site-care'\nimport { firebaseAdmin } from './firebase-admin'\nimport { CONSOLE_DOMAINS_COLLECTION } from './console-domains'\n\nconst firestoreApp = () => firebaseAdmin.app().firestore()\n\n/** Which subject an export source belongs to. */\nexport type ExportSubject = 'user' | 'org'\n\n/** How a source is located — the axis a path cascade is blind to. */\nexport type ExportKeying =\n /** Top-level collection carrying the subject id in a FIELD. */\n | 'field'\n /** Top-level collection whose DOCUMENT ID is the subject id. */\n | 'doc-id'\n /** Under the subject's own document path. */\n | 'path'\n /** Reached through another collection's rows (a collection group). */\n | 'collection-group'\n /** Outside Firestore entirely. */\n | 'external'\n\nexport interface ExportSourceSpec {\n /** Firestore collection name, or an `external:` pseudo-name. */\n collection: string\n keyedBy: ExportKeying\n subjects: readonly ExportSubject[]\n /**\n * `true` when the export discloses it. `false` requires `reason` — and the\n * reason is the whole value of the field: it is a decision recorded at the\n * moment it was made, not an omission discovered later.\n */\n exported: boolean\n /** Why it is withheld, or how it is disclosed. Always present. */\n note: string\n}\n\n/**\n * Every collection `erase.ts` touches, and what the export does with it.\n *\n * Kept in the SAME order as the erasure's steps so a reader comparing the two\n * files reads them in step. `personal-data-export-coverage.spec.ts` proves the\n * set matches; this list carries the decision for each one.\n */\nexport const PERSONAL_DATA_SOURCES: readonly ExportSourceSpec[] = [\n // ── The person ────────────────────────────────────────────────────────\n {\n collection: 'users',\n keyedBy: 'doc-id',\n subjects: ['user'],\n exported: true,\n note: 'Profile: name, phone, postal address, legalAcceptances, and every subcollection (orgs, hostMemberships, notifications, passkeys).',\n },\n {\n collection: 'profiles',\n keyedBy: 'doc-id',\n subjects: ['user'],\n exported: true,\n note: 'The world-readable handle, display name and Stripe Connect account. Not reachable from the user tree (AGL-1970) — the same blind spot on both sides.',\n },\n // ── The workspace ─────────────────────────────────────────────────────\n {\n collection: 'orgs',\n keyedBy: 'doc-id',\n subjects: ['org'],\n exported: true,\n note: 'The org document and every subcollection: members, invites, roles, usage, apiUsage, analytics, datasets/records, contacts, lists, media, installs, activity, assistExchanges, retention.',\n },\n {\n collection: 'hosts',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Each site tree the org owns — pages, layouts, orders, form submissions. Secrets within are redacted, not omitted, so the export still says a webhook exists.',\n },\n {\n collection: 'hostIndex',\n keyedBy: 'doc-id',\n subjects: ['org'],\n exported: true,\n note: 'Subdomain/CNAME routing for each of the org’s sites. Configuration the customer set, so it is theirs to take.',\n },\n {\n collection: 'supplierDeliveries',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'The dropship outbox for each of the org’s sites, keyed by hostId (AGL-1448). Disclosed to the ORG and to no one else, and the reason is the unusual one: the personal data in the row is a SHOPPER’s — name, email and shipping address in the body we sign and POST to the supplier. That is the merchant’s own order record, which they already read in their console and for which they are the controller and we the processor, so an org access request is entitled to it. It is NOT a `user`-subject source: a console member asking what we hold about THEM is not the shopper, and returning these rows would answer their request with a third party’s address. Withholding it was not an option worth taking — `eraseHost` destroys these rows, so an export that omitted them would delete what it never disclosed.',\n },\n // ── Top-level, field-keyed: what a path cascade cannot see ────────────\n {\n collection: 'apiKeys',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'EXISTENCE ONLY — label, scopes, creating uid, dates. Never the credential, and never the document id, which is the SHA-256 of the token.',\n },\n {\n collection: 'outreachMailboxCredentials',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'EXISTENCE ONLY — which connected mailbox a credential authorizes, its provider, granted scopes and dates (AGL-2974), and since AGL-2978 the connected account’s address, its Google account id and the member who connected it: the organization’s own record of whose mailbox it holds. Every token is redacted by name and by shape (see redactSecrets) and never disclosed; the sealed refresh token and the id of the key that sealed it both carry `token` in their names. The document id is the mailbox id, not derived from any secret, so it is disclosed.',\n },\n {\n collection: 'outreachLinks',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Where each short tracking link in a sent Outreach sequence email points (AGL-3297): the enrollment, the step, the link’s index and the destination the step wrote. The organization’s own record of what it sent; the id is random and derived from no secret.',\n },\n {\n collection: 'shippingTrackers',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'One row per tracking number a label was bought for (AGL-3612): the site, the order record, the carrier, the tracking number and its latest status. The organization’s own record of what it shipped; the order it points at is already disclosed under its site. Org-only, for the reason `supplierDeliveries` gives: a tracking number locates a shopper’s parcel.',\n },\n {\n collection: 'shippingQuoteCache',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Carrier quotes for a site’s checkout, kept ten minutes (AGL-3612): the site, each service’s price and transit estimate, and when the row expires. No address is stored; the document id is a SHA-256 of the quoted request, an identifier rather than a verifier of any credential. Disclosed while it exists so the export does not omit a collection the erasure destroys.',\n },\n {\n collection: 'taxEngineConnections',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'EXISTENCE ONLY for the credential — each site’s connection to the merchant’s own Avalara AvaTax or TaxJar account (AGL-3631): provider, environment, account id and company code, ship-from address, default tax code, last test result and the member who connected it. The sealed API token and the id of the key that sealed it both carry `token` in their names and are redacted (see redactSecrets); the document id is the site id.',\n },\n {\n collection: 'taxEngineProductCodes',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'The tax code the merchant assigned each product at their tax service (AGL-3631). Catalog configuration the customer set, so it is theirs to take.',\n },\n {\n collection: 'taxEngineExemptions',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Customers the merchant recorded as tax-exempt (AGL-3631): email, name, exemption type, certificate number and the regions it covers. A SHOPPER’s data held for the merchant as controller, so disclosed to the ORG only, for the reason `supplierDeliveries` gives. The document id carries a truncated SHA-256 of the email — a lookup key, not a credential.',\n },\n {\n collection: 'taxEngineTransactions',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Each paid order as recorded with the merchant’s tax service, and the refunds reversed against it (AGL-3631): the sale sent (lines, ship-to address, the customer code, which is the shopper’s email), its status and last error. The merchant’s own tax record and a shopper’s address, so disclosed to the ORG only.',\n },\n {\n collection: 'marketingPlatformConnections',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'EXISTENCE ONLY for the credential — each site’s connection to the merchant’s own Mailchimp, Klaviyo, Omnisend or Attentive account (AGL-3639): provider, status, account name, the chosen list and tag, the sync switches, cursors and run timing. The sealed access and refresh tokens and the id of the key that sealed them carry `token` in their names and are redacted (see redactSecrets); the document id is the site id and the provider.',\n },\n {\n collection: 'marketingPlatformEvents',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Commerce events still owed to a connected marketing platform (AGL-3639): checkout started, order paid, fulfilled, refunded or cancelled, with the shopper’s email, the order, its items and value, and the tracking number. A SHOPPER’s data held for the merchant as controller, so disclosed to the ORG only, for the reason `supplierDeliveries` gives; a row is deleted once delivered.',\n },\n {\n collection: 'helpDeskConnections',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'EXISTENCE ONLY for the credential — each site’s connection to the merchant’s own Gorgias, Re:amaze, Kustomer, Gladly or Richpanel account (AGL-3824): provider, status, the account’s subdomain and name, the Richpanel support address, the chosen channel, inbox or custom object, the sync switches, cursors and run timing. The sealed API key, login and app client id, sealed together, and the id of the key that sealed them carry `token` in their names and are redacted (see redactSecrets); the document id is the site id and the provider.',\n },\n {\n collection: 'helpDeskOutbox',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Orders and contact form messages still owed to a connected help desk (AGL-3824): a buyer’s email and name with the order’s number, items and totals, or a message’s sender, subject and text. A SHOPPER’s or a visitor’s data held for the merchant as controller, so disclosed to the ORG only, for the reason `supplierDeliveries` gives; a row is deleted once delivered.',\n },\n {\n collection: 'helpDeskCustomers',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'What each help desk connection knows of a buyer (AGL-3824): their email and name, the help desk’s id for them and their ten latest orders, so each order sent carries the recent ones. A SHOPPER’s data held for the merchant as controller, so disclosed to the ORG only, for the reason `supplierDeliveries` gives. The document id carries a truncated SHA-256 of the email — a lookup key, not a credential.',\n },\n {\n collection: 'adConversionConnections',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'EXISTENCE ONLY for the credential — each site’s Conversions API connection to the merchant’s own Meta, TikTok or Pinterest ad account (AGL-3694): provider, status, the Pinterest ad account id, the test event code, and what was last sent or refused. The sealed access token and the id of the key that sealed it carry `token` in their names and are redacted (see redactSecrets); the document id is the site id and the provider.',\n },\n {\n collection: 'adConversionConsents',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'The advertising consent a shopper’s checkout carried, recorded only where it granted advertising on a site with a connection (AGL-3694): the consent status and when it was decided, the country, the page, the ad vendors’ browser ids, the IP address and the user agent. A SHOPPER’s data held for the merchant as controller, so disclosed to the ORG only; deleted when the order is reported or after 14 days.',\n },\n {\n collection: 'adConversionEvents',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Purchases and leads owed to a connected ad account (AGL-3694): the event id, order id, value and items, the visitor’s details as SHA-256 hashes, and the IP address, user agent and vendor browser ids. A SHOPPER’s data held for the merchant as controller, so disclosed to the ORG only; the personal fields are dropped once the event is sent, and every row expires after 14 days.',\n },\n {\n collection: 'domainRegistrations',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Each domain the workspace bought on this platform (AGL-3962): the name, the site it serves, the registrar and its order id, status, registration and expiry dates, auto-renew, what was charged for the first year and quoted for renewals and the invoices for each, the renewal state, the registrant’s name and email as typed at purchase, ICANN’s registrant email check, any dispute, the member who bought it, its latest events, and the registrar’s own prices at purchase. The registration itself, and the full registrant contact, are held by the registrar. Keyed by the domain name.',\n },\n {\n collection: 'domainConnectSessions',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Each one-click DNS request a site sent to its DNS provider through Domain Connect (AGL-3963): the domain and host, the provider and template, the member who started it and their email, its status, and when it was applied, resolved and expires. The document id is a SHA-256 of the state token the provider echoes back, a lookup key and not the token, which is never stored.',\n },\n {\n collection: 'posCellularReaders',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Each S710 reader a store turned 4G on for (AGL-4038): the site, the reader’s id and its serial number, the Terminal configuration, and when it had 4G. The organization’s own record of what it is charged for; it names no person.',\n },\n {\n collection: 'posCellularCharges',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Each month’s 4G charge for the organization’s card readers (AGL-4038): the month, how many readers, the amount, the outcome and the Stripe invoice id. The organization’s own billing record; it names no person.',\n },\n {\n collection: 'fulfillmentNetworkConnections',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'EXISTENCE ONLY for the grant — each site’s connection to the merchant’s own ShipBob, ShipMonk, Flexport or Amazon Multi-Channel Fulfillment account (AGL-3634, AGL-3697, AGL-3822): network, status, account name, ShipBob channel, ShipMonk store id, Amazon marketplaces, routing and stock settings, the last stock count by SKU and totals. The sealed access and refresh tokens (for ShipMonk and Flexport, the merchant’s own API key or token, sealed as the access token), the webhook token’s hash and the id of the key that sealed them carry `token` in their names, and ShipMonk’s sealed webhook signing secret carries `secret` in its name; all are redacted (see redactSecrets). The document id is the site id and the network.',\n },\n {\n collection: 'fulfillmentNetworkOrders',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Each paid order’s hand-off to a fulfillment network (AGL-3634): the order number, the lines sent with SKU and quantity, the network’s reference, the parcels read back with carrier, tracking number and status, and why anything was not sent. The merchant’s own fulfillment record of a SHOPPER’s order, so disclosed to the ORG only.',\n },\n {\n collection: 'courierConnections',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'EXISTENCE ONLY for the keys — each site’s connection to the merchant’s own DoorDash Drive developer account (AGL-3695): provider, the developer and key ids of its live and test keys, each key’s last test result, the store’s courier phone and note, and the member who connected it. The sealed signing secrets carry `secret` and the webhook token’s hash carries `token` in their names and are redacted (see redactSecrets); the document id is the site id and the provider.',\n },\n {\n collection: 'courierDeliveries',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Each local-delivery order’s courier (AGL-3695): the quote offered, the run booked and the runs before it — the courier’s reference, status, fee, arrival estimates, tracking link and any cancellation reason, and the member who booked it. No address or phone is stored here (they stay on the order); the merchant’s own record of a SHOPPER’s delivery, so disclosed to the ORG only.',\n },\n {\n collection: 'marketplaceConnections',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'EXISTENCE ONLY for the grant — each site’s connection to the merchant’s own Amazon, eBay, Etsy, TikTok Shop, Walmart or Faire seller account (AGL-3638): marketplace, status, account name, the marketplace sites the account sells on, the listing and order settings, the order cursor and the last sync’s counts. The sealed access and refresh tokens and the id of the key that sealed them carry `token` in their names and are redacted (see redactSecrets); the account’s marketplace ids are disclosed as stored. The document id is the site id and the marketplace. Its `log` and `listingState` subcollections (what each listing was last sent) are not read by this export.',\n },\n {\n collection: 'marketplaceOrders',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Each marketplace order the store imported (AGL-3638): the marketplace and its order id, the store order it became, which order line each marketplace line became, the marketplace’s fees, and each shipment confirmed back with carrier and tracking number. The merchant’s own record of a marketplace BUYER’s order, so disclosed to the ORG only; the buyer’s name and address are on the store’s order, not here.',\n },\n {\n collection: 'inventorySyncConnections',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'EXISTENCE ONLY for the keys — each site’s connection to the merchant’s own Cin7 Core, inFlow, Brightpearl or Ordoro account (AGL-3642): system, status, account name, the stock, product and order settings (location, the customer or Ordoro sales channel orders are recorded under, the tax rule), the last count by SKU, the last syncs’ counts, cursors and totals. The sealed API keys or grant and the id of the key that sealed them carry `credential` in their names and are redacted (see redactSecrets); Brightpearl’s account code and datacenter are disclosed as stored. The document id is the site id. Its `log` subcollection is not read by this export.',\n },\n {\n collection: 'inventorySyncOrders',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Each paid order’s hand-off to the connected inventory system (AGL-3642): the order number and our reference, the lines sent with SKU, quantity and price, the buyer’s name, email address and shipping address as sent, the totals, the system’s id and number for it, attempts and why it was not sent. The merchant’s own record of a SHOPPER’s order, so disclosed to the ORG only.',\n },\n {\n collection: 'inventorySyncProducts',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Each product linked between the store and the connected inventory system (AGL-3642): the system’s product id, the SKU, the version last synced, the store’s product and variant ids, and why it was not synced. Catalog data, no person’s.',\n },\n {\n collection: 'podConnections',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'EXISTENCE ONLY for the tokens — each site’s connection to the merchant’s own Printful store or Printify shop (AGL-3641): service, store id and name, currency, whether orders are sent automatically or held for review, whether prices sync, how shipments are heard about, and the last error. The sealed API token and webhook token and the id of the key that sealed them carry `token` in their names and are redacted (see redactSecrets).',\n },\n {\n collection: 'podProductLinks',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Each product imported from a print-on-demand service (AGL-3641): the service’s product and variant ids, the store product and variants it became, names, SKUs, what the service charges for each variant and the store’s price. Catalog data, no person’s.',\n },\n {\n collection: 'podOrders',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'The part of each paid order a print-on-demand service makes and ships (AGL-3641): the store order and its number, the service’s order id, the lines sent with quantity and cost, its status, costs, attempts and errors, and each parcel’s carrier and tracking number. No buyer name, address or email is kept here; they are on the store’s order. The merchant’s own record of a SHOPPER’s order, so disclosed to the ORG only.',\n },\n {\n collection: 'deliveryAppStores',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Each site’s link to the merchant’s own DoorDash, Uber Eats or Grubhub store (AGL-3644): the service, the store id it shows the merchant, the settings (accept automatically, prep minutes), the items matched to products and those waiting, and the menu’s last send. No credential is stored: every call is signed with the deployment’s partner credentials.',\n },\n {\n collection: 'deliveryAppOrders',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Each order a delivery service sent a site’s register (AGL-3644): the service and its order id and short code, the items with their options and instructions, the totals and refunds, where it stood at the counter, and the store order it became. The buyer appears by first name and last initial only. The merchant’s own record of a delivery BUYER’s order, so disclosed to the ORG only.',\n },\n {\n collection: 'zapierHooks',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Each Zapier REST hook a site’s API key subscribed (AGL-3643): the site, the events, the API key’s public id and name, delivery counts and dates. EXISTENCE ONLY for the URL — `targetUrl` is the capability Zapier minted for the Zap, a bearer URL whose secret is in its path, so it is redacted by name (see redactSecrets).',\n },\n {\n collection: 'zapierHookDeliveries',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Markers that one event reached one Zapier hook, so a retry does not post it twice (AGL-3643): the hook, the status and the time. The document id is a SHA-256 of the event and hook, an identifier rather than a verifier of any credential; no customer data, and a TTL policy removes each row.',\n },\n {\n collection: 'ssoDomains',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'The public SSO routing document: domain, GCIP tenant and provider ids, IdP display name. `token` is redacted.',\n },\n {\n collection: CONSOLE_DOMAINS_COLLECTION,\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Custom console domain claims the org holds.',\n },\n {\n collection: 'apiIdempotency',\n keyedBy: 'field',\n subjects: ['org'],\n exported: false,\n note: 'Replay keys. The document id is a SHA-256 of the org id and the caller’s Idempotency-Key, and the row names a record id and nothing about a person. Disclosed as a COUNT so the export does not silently omit a collection the erasure destroys.',\n },\n {\n collection: 'pluginConnectionCredentials',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'EXISTENCE ONLY for the credential — the OAuth app a publishing workspace registered for each declared connection of its marketplace listing (AGL-4193): the listing and connection ids, and when and by which member the pair was last set. The sealed client secret carries `secret` in its name and is redacted (see redactSecrets); the sealed client id is named as an id, which defuses the shape gate, so the export redacts it explicitly. The document id is the listing id and the connection id, derived from no secret.',\n },\n {\n collection: 'stripeCustomers',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'The local reverse index: which Stripe customer id belongs to this workspace. An identifier the customer already holds on their own invoices.',\n },\n {\n collection: 'orgSlugs',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Every workspace name the org has ever held, rename tombstones included — naming history is a fact about them.',\n },\n {\n collection: 'publisherHandles',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Marketplace handle reservations and rename tombstones (AGL-1970).',\n },\n {\n collection: 'publisherProfiles',\n keyedBy: 'doc-id',\n subjects: ['org'],\n exported: true,\n note: 'The public publisher identity — handle, display name, bio, website, avatar, publisher agreement. `stripeAccountId` is the org’s own payout destination and is disclosed; nothing here is a credential.',\n },\n {\n collection: 'marketplaceListings',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Listings the org published. These deliberately OUTLIVE an erasure (AGL-1448 Tier 3) — which makes disclosing them on an access request more important, not less: they are the part that does not go away.',\n },\n {\n collection: 'supportTickets',\n keyedBy: 'field',\n subjects: ['org', 'user'],\n exported: true,\n note: 'For an ORG: every thread and its messages, except a Site Care request’s staff-only intake (the other workspaces its sender belongs to, AGL-4031). For a PERSON: only the messages they themselves authored — a thread has other authors, and handing a member the whole conversation would disclose colleagues’ words to them.',\n },\n // ── Retained past erasure on statutory grounds ────────────────────────\n {\n collection: 'platformRevenue',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Per-transaction tax filing records. GDPR Art. 17(3)(b) exempts them from ERASURE (AGL-1811); it does not exempt them from ACCESS. If a transaction of theirs is in there it is disclosable — and the export is the only place a customer can see what survived their erasure.',\n },\n {\n collection: 'storefrontTaxCollected',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'Sales tax charged to shoppers on the org’s storefront (AGL-1904). Same statutory retention, same access obligation.',\n },\n {\n collection: 'posHardwareSales',\n keyedBy: 'field',\n subjects: ['org'],\n exported: true,\n note: 'The platform’s record of each card reader order the org bought from the hardware shop (AGL-4038): lines, amounts, tax, Stripe ids, status dates and the country, state and postal code it shipped to — never the buyer. Kept past ERASURE as a tax and accounting record, GDPR Art. 17(3)(b); disclosed on ACCESS like the other two.',\n },\n // ── Records of our own handling ───────────────────────────────────────\n {\n collection: 'adminAudit',\n keyedBy: 'field',\n subjects: ['org', 'user'],\n exported: false,\n note: 'STAFF-ONLY. Rows name the staff actor, carry override reasons and internal notes, and are the record of our handling rather than data about the subject. `/admin/audit` → Export CSV serves a request that specifically asks for them, after a staff read.',\n },\n]\n\n/** Sources this export deliberately withholds, with the reason. */\nexport const EXPORT_WITHHELD = PERSONAL_DATA_SOURCES.filter((s) => !s.exported)\n\n/** Collection names the export claims to cover, for the coverage guard. */\nexport const EXPORT_COVERED_COLLECTIONS: readonly string[] =\n PERSONAL_DATA_SOURCES.map((source) => source.collection)\n\n/**\n * ## WHY THIS IS SHAPE-DRIVEN AND NOT A LIST OF NAMES\n *\n * It used to be a list of names, anchored on separators:\n *\n * /(^|[._-])(secret|token|password|apikey|…)($|[._-])/i\n *\n * That pattern requires a `.`, `_`, `-`, or a string boundary on both sides\n * of the word, so it reads `password_hash` and `webhooks.secret` and misses\n * `supplierToken` and `passwordScrypt` — the exact two fields the AGL-1881\n * review found leaving the platform in a customer's own export file. One is\n * a live bearer credential a supplier authenticates with; the other is a\n * shopper's scrypt password hash. **A denylist of names is always one naming\n * convention behind, and camelCase is the proof.**\n *\n * So the name half is now tokenized rather than separator-anchored, and it is\n * no longer the only gate. Three run, in order, and any of them redacts:\n *\n * * **(A) The name, tokenized.** `supplierToken` splits to\n * `['supplier','token']` the same way `supplier_token` and\n * `SUPPLIER-TOKEN` do, so the convention stops mattering. A name matches\n * on a single secret word or on an adjacent pair (`client secret`).\n * * **(B) The VALUE's shape, whatever the key is called.** This is the half\n * that does not need to know the schema: a PEM block, a JWT, a vendor\n * prefix (`sk_live_`, `whsec_`, `ghp_`, `AKIA`…), a `$2b$`/`$argon2` hash,\n * this repo's own `salt:hash` scrypt form, or an opaque high-entropy\n * string is a credential whether the field is called `supplierToken`,\n * `t`, or `notes`. **Gate B is the \"redact unless known safe\" default**:\n * a credential-shaped string is withheld unless its key names it as a\n * content identifier (see {@link SAFE_VALUE_WORDS}).\n * * **(C) Credentials carried inside a URL.** `?token=`, `?sig=`,\n * `?key=`, and `https://user:pass@host` are stripped from the URL rather\n * than the URL being blanked, because a media object's `url` field really\n * does carry a live Firebase download token in a query parameter, and the\n * location of the customer's own file is exactly what an access request\n * asks for. Precision beats blanking here.\n *\n * ### Why the KEY half is still deny-based, when the value half is not\n *\n * A true allowlist of field names is not available on this data. The export\n * walks documents whose field names our customers author — canvas nodes,\n * dataset records, custom metadata, form submissions — so an allowlist of\n * names would blank most of the file and turn an access request into a\n * non-answer, which is the under-disclosure this feature exists to stop. The\n * allowlist therefore lives where the vocabulary IS ours: value shapes. An\n * unrecognized VALUE shape is passed through (it is prose, a number, a date,\n * a customer's own content); an unrecognized value shape that looks like a\n * credential is withheld. That is the inversion the review asked for, put\n * where it can hold.\n *\n * ### The one deliberate carve-out\n *\n * `token`/`tokens` is also a metering word — `tokensUsed: 14203` on an\n * assist exchange is a usage count, and blanking it would blank a real\n * disclosure. A credential is a STRING; a count is a number. So a numeric or\n * boolean value under a name that matched only on a metering word passes\n * through. Nothing else in the vocabulary gets that treatment.\n *\n * A false positive costs a redacted field in an export. A false negative\n * costs a credential. Everything below is tuned in that direction.\n */\n\n/**\n * Split a field name into lowercase word tokens, convention-independently.\n *\n * `supplierToken`, `supplier_token`, `SUPPLIER-TOKEN` and `Supplier.Token`\n * all become `['supplier','token']`. Acronym runs split at the last capital\n * (`SSOTokenId` → `['sso','token','id']`) and digits break a word\n * (`apiKey2` → `['api','key','2']`), so a numbered field cannot hide.\n */\nexport function fieldNameTokens(key: unknown): string[] {\n return String(key ?? '')\n .replace(/[^A-Za-z0-9]+/g, ' ')\n .replace(/([a-z0-9])([A-Z])/g, '$1 $2')\n .replace(/([A-Z]+)([A-Z][a-z])/g, '$1 $2')\n .replace(/([A-Za-z])([0-9])/g, '$1 $2')\n .toLowerCase()\n .split(' ')\n .filter(Boolean)\n}\n\n/**\n * Words that make a field a credential on their own.\n *\n * Deliberately short. Every entry here is a word that has no innocent\n * meaning on a stored VALUE — `hmac`, `scrypt` and `bcrypt` name the\n * algorithm that produced a verifier, `passphrase` and `credential` name the\n * thing itself. `key` is NOT here and must never be: `publicKey` on a\n * passkey and `sortKey` on a dataset are not secrets, which is what\n * {@link SECRET_WORD_PAIRS} is for.\n */\nconst SECRET_WORDS = new Set([\n 'secret',\n 'secrets',\n 'password',\n 'passwords',\n 'passwd',\n 'pwd',\n 'passphrase',\n 'token',\n 'tokens',\n 'credential',\n 'credentials',\n 'apikey',\n 'privatekey',\n 'scrypt',\n 'bcrypt',\n 'argon',\n 'argon2',\n 'pbkdf2',\n 'hmac',\n 'otp',\n 'totp',\n 'authorization',\n])\n\n/**\n * Words that are a credential only next to another word.\n *\n * `key` is meaningless alone and decisive after `api`, `private`, `signing`,\n * `secret`, `session` or `encryption`; `token` after `access`/`refresh` is\n * already caught by {@link SECRET_WORDS} and listed here anyway so the pair\n * table reads as the complete statement of the rule.\n */\nconst SECRET_WORD_PAIRS = new Set([\n 'api key',\n 'private key',\n 'signing key',\n 'secret key',\n 'session key',\n 'encryption key',\n 'client secret',\n 'access token',\n 'refresh token',\n 'webhook secret',\n 'shared secret',\n // A Stripe payment link is a live bearer URL: whoever holds it can pay.\n // Named in the AGL-1443 inventory of what the old dump actually carried.\n 'payment link',\n // A Zapier REST hook's `targetUrl` (AGL-3643) is the same kind of bearer\n // URL: whoever holds it can post into the Zap, and its secret is in the\n // path, which the URL scrub does not read.\n 'target url',\n 'auth code',\n 'recovery code',\n 'backup code',\n])\n\n/**\n * The metering carve-out — see the header. A name that matched ONLY on one\n * of these, over a number or a boolean, is a count and is disclosed.\n */\nconst METERING_WORDS = new Set(['token', 'tokens'])\n\n/**\n * Key words that mark a high-entropy value as a content identifier rather\n * than a credential, defusing gate (B) only.\n *\n * A SHA-256 has exactly the shape of a 64-character secret and is not one.\n * Gate (A) is never defused by this list: `apiKeyId` is redacted, because\n * the name says credential and an id of a credential is not worth the\n * argument.\n */\nconst SAFE_VALUE_WORDS = new Set([\n // A passkey's `publicKey` is public by definition and has exactly the shape\n // of a secret. Safe to list because gate (A) is never defused here — a\n // `publicToken` is still redacted, on the strength of `token`.\n 'public',\n 'id',\n 'ids',\n 'uid',\n 'uuid',\n 'guid',\n 'hash',\n 'hashes',\n 'sha',\n 'sha1',\n 'sha256',\n 'sha512',\n 'md5',\n 'crc',\n 'crc32c',\n 'etag',\n 'checksum',\n 'digest',\n 'fingerprint',\n 'generation',\n 'version',\n 'revision',\n 'slug',\n 'path',\n 'url',\n 'uri',\n 'href',\n 'src',\n 'color',\n 'colour',\n 'hex',\n])\n\n/** Vendor credential prefixes — unambiguous, and worth naming explicitly. */\nconst CREDENTIAL_PREFIXES = [\n 'sk_live_',\n 'sk_test_',\n 'rk_live_',\n 'rk_test_',\n 'whsec_',\n 'ghp_',\n 'gho_',\n 'ghu_',\n 'ghs_',\n 'ghr_',\n 'github_pat_',\n 'xoxb-',\n 'xoxp-',\n 'xapp-',\n 'xoxa-',\n 'AKIA',\n 'ASIA',\n 'AIza',\n 'ya29.',\n 'SG.',\n 're_',\n 'shpat_',\n 'shpss_',\n 'npm_',\n 'glpat-',\n 'sq0csp-',\n 'sq0atp-',\n]\n\n/** A PEM block that carries a private key or a certificate request. */\nconst PEM_PATTERN = /-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----/\n\n/** Modular crypt format: bcrypt, argon2, scrypt, PBKDF2, sha512-crypt. */\nconst CRYPT_HASH_PATTERN = /^\\$(2[abxy]?|argon2[a-z]*|scrypt|pbkdf2[^$]*|[56])\\$/\n\n/** This repo's own scrypt storage form: `{16+ hex salt}:{32+ hex hash}`. */\nconst SALTED_HASH_PATTERN = /^[0-9a-f]{16,}:[0-9a-f]{32,}$/i\n\n/** A JSON Web Token — three base64url segments. */\nconst JWT_PATTERN = /^[A-Za-z0-9_-]{8,}\\.[A-Za-z0-9_-]{8,}\\.[A-Za-z0-9_-]{8,}$/\n\n/** A UUID, which is an identifier far more often than it is a credential. */\nconst UUID_PATTERN =\n /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i\n\n/** Charset of an opaque credential: base64, base64url or hex, nothing else. */\nconst OPAQUE_CHARSET = /^[A-Za-z0-9_+/=-]+$/\n\n/**\n * The window an opaque secret lives in.\n *\n * Below 32 characters the false-positive rate against ordinary identifiers is\n * not worth it and the value is too short to be a modern credential anyway.\n * Above 512 it is customer CONTENT — a base64 image, a compressed canvas\n * blob, an encoded document — and blanking those is the \"gutting the export\"\n * failure this file is explicitly trying not to commit.\n */\nconst OPAQUE_MIN_LENGTH = 32\nconst OPAQUE_MAX_LENGTH = 512\n\n/** Shannon entropy per character. Prose and slugs sit well below this. */\nconst OPAQUE_MIN_ENTROPY = 3.2\n\nfunction shannonEntropyPerChar(text: string): number {\n const counts = new Map<string, number>()\n for (const character of text) {\n counts.set(character, (counts.get(character) ?? 0) + 1)\n }\n let entropy = 0\n for (const count of counts.values()) {\n const p = count / text.length\n entropy -= p * Math.log2(p)\n }\n return entropy\n}\n\n/**\n * Does this STRING look like a credential, ignoring what it is called?\n *\n * Exported because the guard spec asserts each limb independently — a shape\n * detector tested only through the redactor is a detector whose gaps are\n * invisible.\n */\nexport function looksLikeCredential(value: string): boolean {\n const text = value.trim()\n if (!text) return false\n if (PEM_PATTERN.test(text)) return true\n if (CRYPT_HASH_PATTERN.test(text)) return true\n if (SALTED_HASH_PATTERN.test(text)) return true\n if (CREDENTIAL_PREFIXES.some((prefix) => text.startsWith(prefix))) return true\n if (JWT_PATTERN.test(text)) return true\n // Anything with whitespace is prose, and `data:` is an inline asset. Both\n // are customer content, and neither is a bearer credential.\n if (/\\s/.test(text)) return false\n if (/^data:/i.test(text)) return false\n if (UUID_PATTERN.test(text)) return false\n if (text.length < OPAQUE_MIN_LENGTH || text.length > OPAQUE_MAX_LENGTH) {\n return false\n }\n if (!OPAQUE_CHARSET.test(text)) return false\n return shannonEntropyPerChar(text) >= OPAQUE_MIN_ENTROPY\n}\n\n/** What a stripped URL parameter reads as, so the removal is visible. */\nexport const REDACTED_URL_PARAM = 'REDACTED'\n\n/** Query parameters that carry a bearer credential inside a URL. */\nconst URL_CREDENTIAL_PARAMS = new Set([\n 'token',\n 'access_token',\n 'accesstoken',\n 'id_token',\n 'refresh_token',\n 'auth',\n 'authorization',\n 'apikey',\n 'api_key',\n 'key',\n 'sig',\n 'signature',\n 'secret',\n 'password',\n 'downloadtoken',\n])\n\n/**\n * Strip the credential out of a URL, keeping the URL.\n *\n * A media object's `url` is `…/o/{path}?alt=media&token={uuid}` — a live,\n * unauthenticated download credential, in a field an access request has a\n * real interest in. Blanking the whole value would tell the customer nothing\n * about where their own file is; keeping it whole hands out the credential.\n * So the parameter is replaced and the rest survives. `user:pass@` userinfo\n * goes the same way.\n *\n * Returns the input unchanged when it is not a URL — every non-URL string\n * has already been decided by the shape gate.\n */\nexport function scrubUrlCredentials(value: string): string {\n if (!/^https?:\\/\\//i.test(value)) return value\n let url: URL\n try {\n url = new URL(value)\n } catch {\n return value\n }\n let changed = false\n if (url.username || url.password) {\n url.username = ''\n url.password = ''\n changed = true\n }\n for (const name of Array.from(url.searchParams.keys())) {\n if (!URL_CREDENTIAL_PARAMS.has(name.toLowerCase())) continue\n if (!url.searchParams.get(name)) continue\n url.searchParams.set(name, REDACTED_URL_PARAM)\n changed = true\n }\n return changed ? url.toString() : value\n}\n\n/**\n * Gate (A): does the NAME say credential?\n *\n * `value` is consulted only for the metering carve-out described in the\n * header — a `tokensUsed: 14203` is a count, not a credential.\n */\nexport function secretByName(key: unknown, value?: unknown): boolean {\n const tokens = fieldNameTokens(key)\n if (!tokens.length) return false\n const hits = tokens.filter((token) => SECRET_WORDS.has(token))\n for (let index = 0; index + 1 < tokens.length; index += 1) {\n if (SECRET_WORD_PAIRS.has(`${tokens[index]} ${tokens[index + 1]}`)) {\n return true\n }\n }\n if (!hits.length) return false\n // Matched only on a metering word, over a number or a boolean: a count.\n const metering = hits.every((token) => METERING_WORDS.has(token))\n if (metering && (typeof value === 'number' || typeof value === 'boolean')) {\n return false\n }\n return true\n}\n\n/** Gate (B)'s defuser: does the NAME say this high-entropy value is an id? */\nfunction nameMarksContentIdentifier(key: unknown): boolean {\n return fieldNameTokens(key).some((token) => SAFE_VALUE_WORDS.has(token))\n}\n\n/** What a redacted value is replaced with — presence, never content. */\nexport interface RedactedValue {\n redacted: true\n /** Whether a value was actually there, so absence is distinguishable. */\n present: boolean\n reason: 'secret'\n}\n\nconst redactedMarker = (present: boolean): RedactedValue => ({\n redacted: true,\n present,\n reason: 'secret',\n})\n\n/**\n * Deep-copy a document, replacing every credential-shaped value with a\n * presence marker.\n *\n * Presence rather than deletion, because \"we hold a webhook secret for you\"\n * is itself a true and disclosable fact, and a silently-absent key would make\n * the export look like it holds less than it does — the under-disclosure this\n * feature exists to stop, reintroduced by the safety measure.\n *\n * Firestore values that are not plain JSON (Timestamp, GeoPoint, DocumentRef,\n * Buffer) are stringified rather than walked: they carry no nested keys to\n * redact, and `JSON.stringify` on a Timestamp yields `{_seconds,_nanoseconds}`,\n * which is not a date to a human reading the file.\n *\n * Three gates, any of which redacts — the name (A), the value's shape (B),\n * and a credential embedded in a URL (C). See the header above\n * {@link fieldNameTokens} for why the value half is the one that carries the\n * \"withhold unless known safe\" default.\n */\nexport function redactSecrets(value: unknown, key = ''): unknown {\n // (A) The name, tokenized — convention-independent.\n if (key && secretByName(key, value)) {\n return redactedMarker(value !== undefined && value !== null && value !== '')\n }\n if (value === null || value === undefined) return value ?? null\n if (typeof value === 'string') {\n // (C) A URL that carries its credential in a parameter keeps the URL and\n // loses the credential — see {@link scrubUrlCredentials}.\n const scrubbed = scrubUrlCredentials(value)\n if (scrubbed !== value) return scrubbed\n // (B) The shape, whatever the field is called. Withheld unless the name\n // marks it as a content identifier.\n if (looksLikeCredential(value) && !nameMarksContentIdentifier(key)) {\n return redactedMarker(true)\n }\n return value\n }\n if (Array.isArray(value)) return value.map((entry) => redactSecrets(entry, key))\n if (typeof value === 'object') {\n const source = value as Record<string, unknown>\n // Firestore Timestamp — the only non-plain value common enough to be\n // worth rendering rather than dumping.\n if (typeof (source as any).toDate === 'function') {\n try {\n return (source as any).toDate().toISOString()\n } catch {\n return String(value)\n }\n }\n if (typeof (source as any).toBase64 === 'function') return '[binary]'\n const out: Record<string, unknown> = {}\n for (const [childKey, childValue] of Object.entries(source)) {\n out[childKey] = redactSecrets(childValue, childKey)\n }\n return out\n }\n return value\n}\n\nexport interface ExportedDocument {\n /** Document id — omitted where the id is itself a secret (see `apiKeys`). */\n id?: string\n path?: string\n data: unknown\n}\n\nexport interface PersonalDataExport {\n subject: { type: ExportSubject; id: string }\n generatedAt: string\n /**\n * The disclosure decision for every source, copied into the file the\n * customer receives. An export that silently omits a collection is\n * indistinguishable from one that has nothing to report; this makes the two\n * different, and it is what a supervisory authority would ask to see.\n */\n coverage: readonly ExportSourceSpec[]\n /** Collection name → the documents disclosed for it. */\n data: Record<string, ExportedDocument[]>\n /** Collection name → row count, for sources disclosed as a count only. */\n counts: Record<string, number>\n /** Places we hold data that is not in Firestore. */\n elsewhere: readonly string[]\n}\n\n/** Data we hold outside Firestore — named, because a file that omits them reads as complete. */\nconst ELSEWHERE = [\n 'Stripe — customer object, payment methods, invoices. Request from Stripe or ask us.',\n 'Resend — transactional email delivery logs.',\n 'Google Analytics — 14-month retention, not keyed to an account.',\n 'Cloud Storage — uploaded media and avatars, under users/{uid}/, orgs/{orgId}/ and hosts/{hostId}/. Listed by path in this file; the bytes are served by their own URLs.',\n]\n\nfunction sourcesFor(subject: ExportSubject): ExportSourceSpec[] {\n return PERSONAL_DATA_SOURCES.filter((source) => source.subjects.includes(subject))\n}\n\n/** Read a top-level collection bounded by a field equal to the subject id. */\nasync function readByField(\n db: any,\n collection: string,\n field: string,\n id: string,\n options: { includeIds?: boolean } = {},\n): Promise<ExportedDocument[]> {\n const rows = await db.collection(collection).where(field, '==', id).get()\n return rows.docs.map((doc: any) => ({\n // `apiKeys` document ids are the SHA-256 of the token: an id handed back\n // is a verifier handed back, so the caller opts in rather than out.\n ...(options.includeIds === false ? {} : { id: doc.id }),\n data: redactSecrets(doc.data()),\n }))\n}\n\n/** Read one document by id, or nothing when it does not exist. */\nasync function readDoc(\n db: any,\n collection: string,\n id: string,\n): Promise<ExportedDocument[]> {\n const snapshot = await db.collection(collection).doc(id).get()\n if (!snapshot.exists) return []\n return [{ id, data: redactSecrets(snapshot.data()) }]\n}\n\n/**\n * Walk a document and everything beneath it.\n *\n * `listCollections()` rather than a hard-coded subcollection list, for the\n * same reason the erasure uses `recursiveDelete`: a subcollection added next\n * quarter is reached without anybody remembering this file exists. Bounded by\n * `maxDepth` because the tree is customer-shaped and an unbounded recursion\n * inside a request is how AGL-1455 lost erasures to a 60-second timeout.\n */\nasync function readSubtree(\n db: any,\n ref: any,\n depth = 0,\n maxDepth = 4,\n): Promise<ExportedDocument[]> {\n const snapshot = await ref.get()\n const found: ExportedDocument[] = []\n if (snapshot.exists) {\n found.push({ path: ref.path, data: redactSecrets(snapshot.data()) })\n }\n if (depth >= maxDepth) return found\n const children = (await ref.listCollections?.()) ?? []\n for (const child of children) {\n const rows = await child.get()\n for (const doc of rows.docs) {\n found.push(...(await readSubtree(db, doc.ref, depth + 1, maxDepth)))\n }\n }\n return found\n}\n\nexport interface ExportOptions {\n /** Injectable for tests; defaults to the admin app's Firestore. */\n firestore?: any\n /** Stops a pathological workspace from building an unbounded file. */\n maxDepth?: number\n}\n\n/**\n * Everything we hold about a PERSON, as the person themselves may ask for it\n * (GDPR Art. 15 and Art. 20).\n *\n * Scoped to them, never to the workspaces they belong to. Their membership row\n * in each org is theirs; the roster around it is their colleagues'. An org\n * export is a separate call with a separate authorization, which is the whole\n * reason the two are different functions rather than one with a flag.\n */\nexport async function exportUserData(\n uid: string,\n options: ExportOptions = {},\n): Promise<PersonalDataExport> {\n const db = options.firestore ?? firestoreApp()\n const data: Record<string, ExportedDocument[]> = {}\n const counts: Record<string, number> = {}\n\n // The profile tree — `users/{uid}` and every subcollection under it.\n data['users'] = await readSubtree(\n db,\n db.collection('users').doc(uid),\n 0,\n options.maxDepth ?? 4,\n )\n\n // The public identity, which the user tree does not reach (AGL-1970).\n data['profiles'] = await readDoc(db, 'profiles', uid)\n\n // ONLY the messages this person wrote. The threads belong to a workspace\n // and carry other people's words; handing a member the whole conversation\n // to answer their own access request is a disclosure nobody consented to.\n const messages = await db\n .collectionGroup('messages')\n .where('authorId', '==', uid)\n .get()\n .catch(() => ({ docs: [] as any[] }))\n data['supportTickets'] = messages.docs.map((doc: any) => ({\n path: doc.ref.path,\n data: redactSecrets(doc.data()),\n }))\n\n return {\n subject: { type: 'user', id: uid },\n generatedAt: new Date().toISOString(),\n coverage: sourcesFor('user'),\n data,\n counts,\n elsewhere: ELSEWHERE,\n }\n}\n\n/**\n * Everything we hold about a WORKSPACE, for its owner (Art. 15 for the\n * personal data in it, and the \"export before you delete\" the Delete tab,\n * DPA §11 and Terms §13.3 have been promising).\n *\n * Every top-level collection the erasure sweeps by `orgId` is read here by the\n * same bound, so the two see the same rows. Where a source is withheld, its\n * COUNT is still reported: a collection that appears in neither the data nor\n * the counts is indistinguishable from one that does not exist, and that\n * ambiguity is what makes an incomplete export undetectable.\n */\nexport async function exportOrgData(\n orgId: string,\n options: ExportOptions = {},\n): Promise<PersonalDataExport> {\n const db = options.firestore ?? firestoreApp()\n const data: Record<string, ExportedDocument[]> = {}\n const counts: Record<string, number> = {}\n\n data['orgs'] = await readSubtree(\n db,\n db.collection('orgs').doc(orgId),\n 0,\n options.maxDepth ?? 4,\n )\n\n // Sites: the routing entry and the whole tree for each.\n const hosts = await db.collection('hosts').where('orgId', '==', orgId).get()\n const hostDocs: ExportedDocument[] = []\n const routing: ExportedDocument[] = []\n const outbox: ExportedDocument[] = []\n for (const host of hosts.docs) {\n hostDocs.push(...(await readSubtree(db, host.ref, 0, options.maxDepth ?? 4)))\n routing.push(...(await readDoc(db, 'hostIndex', host.id)))\n // Keyed by `hostId`, not `orgId`, so it is read here rather than in the\n // field-keyed loop below — the same bound `eraseHostSupplierDeliveries`\n // sweeps by, so the export and the erasure see the same rows.\n outbox.push(...(await readByField(db, 'supplierDeliveries', 'hostId', host.id)))\n }\n data['hosts'] = hostDocs\n data['hostIndex'] = routing\n data['supplierDeliveries'] = outbox\n\n // The field-keyed collections a path cascade is blind to — the ones the\n // erasure had to grow a sweep for, one issue at a time.\n for (const collection of [\n 'ssoDomains',\n CONSOLE_DOMAINS_COLLECTION,\n 'stripeCustomers',\n 'orgSlugs',\n 'publisherHandles',\n 'platformRevenue',\n 'storefrontTaxCollected',\n 'posHardwareSales',\n ]) {\n data[collection] = await readByField(db, collection, 'orgId', orgId)\n }\n\n // Existence, never the credential — and not the id either, which is the\n // token's SHA-256.\n data['apiKeys'] = await readByField(db, 'apiKeys', 'orgId', orgId, {\n includeIds: false,\n })\n\n // Which mailboxes the reps connected, never the grant behind one: the\n // tokens are withheld by `redactSecrets` like every other read here. The id\n // is the mailbox's own, so unlike `apiKeys` it stays.\n data['outreachMailboxCredentials'] = await readByField(\n db,\n 'outreachMailboxCredentials',\n 'orgId',\n orgId,\n )\n\n // Where each short tracking link the org's sequences sent points (AGL-3297).\n data['outreachLinks'] = await readByField(db, 'outreachLinks', 'orgId', orgId)\n\n // A marketplace listing's OAuth app per declared connection (AGL-4193),\n // keyed by the publishing workspace's `orgId`. `sealedClientSecret` is\n // withheld by `redactSecrets` on its name; `sealedClientId` is named as an\n // id, which defuses the shape gate, so it is withheld here by name.\n data['pluginConnectionCredentials'] = (\n await readByField(db, 'pluginConnectionCredentials', 'orgId', orgId)\n ).map((row) => {\n const fields = row.data as Record<string, unknown> | null\n return fields && 'sealedClientId' in fields\n ? { ...row, data: { ...fields, sealedClientId: redactedMarker(true) } }\n : row\n })\n\n // Shipping (AGL-3612), tax services (AGL-3631), marketing platforms\n // (AGL-3639) and help desks (AGL-3824): top-level and keyed by `orgId`, the bound their\n // `orgKeyedCollections` erasure sweeps by. The sealed credentials are\n // withheld by `redactSecrets` on their names.\n for (const collection of [\n 'shippingTrackers',\n 'shippingQuoteCache',\n 'taxEngineConnections',\n 'taxEngineProductCodes',\n 'taxEngineExemptions',\n 'taxEngineTransactions',\n 'marketingPlatformConnections',\n 'marketingPlatformEvents',\n 'helpDeskConnections',\n 'helpDeskOutbox',\n 'helpDeskCustomers',\n 'adConversionConnections',\n 'adConversionConsents',\n 'adConversionEvents',\n 'fulfillmentNetworkConnections',\n 'fulfillmentNetworkOrders',\n 'courierConnections',\n 'courierDeliveries',\n 'marketplaceConnections',\n 'marketplaceOrders',\n 'inventorySyncConnections',\n 'inventorySyncOrders',\n 'inventorySyncProducts',\n 'podConnections',\n 'podProductLinks',\n 'podOrders',\n 'deliveryAppStores',\n 'deliveryAppOrders',\n 'domainRegistrations',\n 'domainConnectSessions',\n 'posCellularReaders',\n 'posCellularCharges',\n ]) {\n data[collection] = await readByField(db, collection, 'orgId', orgId)\n }\n\n data['publisherProfiles'] = await readDoc(db, 'publisherProfiles', orgId)\n data['marketplaceListings'] = await readByField(\n db,\n 'marketplaceListings',\n 'profileId',\n orgId,\n )\n\n // Support threads WITH their messages — for an org the whole thread is the\n // org's own record, unlike the person-scoped export above.\n const tickets = await db\n .collection('supportTickets')\n .where('orgId', '==', orgId)\n .get()\n const ticketDocs: ExportedDocument[] = []\n for (const ticket of tickets.docs) {\n // Not a Site Care request's staff-only intake (AGL-4031): which other\n // workspaces its sender belongs to is the sender's, not this org's.\n const staffOnly = `/${SITE_CARE_STAFF_COLLECTION}/`\n ticketDocs.push(...(await readSubtree(db, ticket.ref, 0, 2)).filter((found) => !found.path.includes(staffOnly)))\n }\n data['supportTickets'] = ticketDocs\n\n // Withheld, but counted — see the note on this function.\n const replayKeys = await db\n .collection('apiIdempotency')\n .where('orgId', '==', orgId)\n .get()\n counts['apiIdempotency'] = replayKeys.docs.length\n\n return {\n subject: { type: 'org', id: orgId },\n generatedAt: new Date().toISOString(),\n coverage: sourcesFor('org'),\n data,\n counts,\n elsewhere: ELSEWHERE,\n }\n}\n\n/** A filename a human can file: subject, id and the date it was produced. */\nexport function exportFilename(exported: PersonalDataExport): string {\n const day = exported.generatedAt.slice(0, 10)\n return `aglyn-${exported.subject.type}-data-${exported.subject.id}-${day}.json`\n}\n\nexport default exportUserData\n"],"names":["SITE_CARE_STAFF_COLLECTION","firebaseAdmin","CONSOLE_DOMAINS_COLLECTION","firestoreApp","app","firestore","PERSONAL_DATA_SOURCES","collection","keyedBy","subjects","exported","note","EXPORT_WITHHELD","filter","s","EXPORT_COVERED_COLLECTIONS","map","source","fieldNameTokens","key","String","replace","toLowerCase","split","Boolean","SECRET_WORDS","Set","SECRET_WORD_PAIRS","METERING_WORDS","SAFE_VALUE_WORDS","CREDENTIAL_PREFIXES","PEM_PATTERN","CRYPT_HASH_PATTERN","SALTED_HASH_PATTERN","JWT_PATTERN","UUID_PATTERN","OPAQUE_CHARSET","OPAQUE_MIN_LENGTH","OPAQUE_MAX_LENGTH","OPAQUE_MIN_ENTROPY","shannonEntropyPerChar","text","counts","Map","character","set","get","entropy","count","values","p","length","Math","log2","looksLikeCredential","value","trim","test","some","prefix","startsWith","REDACTED_URL_PARAM","URL_CREDENTIAL_PARAMS","scrubUrlCredentials","url","URL","changed","username","password","name","Array","from","searchParams","keys","has","toString","secretByName","tokens","hits","token","index","metering","every","nameMarksContentIdentifier","redactedMarker","present","redacted","reason","redactSecrets","undefined","scrubbed","isArray","entry","toDate","toISOString","toBase64","out","childKey","childValue","Object","entries","ELSEWHERE","sourcesFor","subject","includes","readByField","db","field","id","options","rows","where","docs","doc","includeIds","data","readDoc","snapshot","exists","readSubtree","ref","depth","maxDepth","found","push","path","children","listCollections","child","exportUserData","uid","messages","collectionGroup","catch","type","generatedAt","Date","coverage","elsewhere","exportOrgData","orgId","hosts","hostDocs","routing","outbox","host","row","fields","sealedClientId","tickets","ticketDocs","ticket","staffOnly","replayKeys","exportFilename","day","slice"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0DC,GAED,SAASA,0BAA0B,QAAQ,mCAAkC;AAC7E,SAASC,aAAa,QAAQ,sBAAkB;AAChD,SAASC,0BAA0B,QAAQ,uBAAmB;AAE9D,MAAMC,eAAe,IAAMF,cAAcG,GAAG,GAAGC,SAAS;AAiCxD;;;;;;CAMC,GACD,OAAO,MAAMC,wBAAqD;IAChE,yEAAyE;IACzE;QACEC,YAAY;QACZC,SAAS;QACTC,UAAU;YAAC;SAAO;QAClBC,UAAU;QACVC,MAAM;IACR;IACA;QACEJ,YAAY;QACZC,SAAS;QACTC,UAAU;YAAC;SAAO;QAClBC,UAAU;QACVC,MAAM;IACR;IACA,yEAAyE;IACzE;QACEJ,YAAY;QACZC,SAAS;QACTC,UAAU;YAAC;SAAM;QACjBC,UAAU;QACVC,MAAM;IACR;IACA;QACEJ,YAAY;QACZC,SAAS;QACTC,UAAU;YAAC;SAAM;QACjBC,UAAU;QACVC,MAAM;IACR;IACA;QACEJ,YAAY;QACZC,SAAS;QACTC,UAAU;YAAC;SAAM;QACjBC,UAAU;QACVC,MAAM;IACR;IACA;QACEJ,YAAY;QACZC,SAAS;QACTC,UAAU;YAAC;SAAM;QACjBC,UAAU;QACVC,MAAM;IACR;IACA,yEAAyE;IACzE;QACEJ,YAAY;QACZC,SAAS;QACTC,UAAU;YAAC;SAAM;QACjBC,UAAU;QACVC,MAAM;IACR;IACA;QACEJ,YAAY;QACZC,SAAS;QACTC,UAAU;YAAC;SAAM;QACjBC,UAAU;QACVC,MAAM;IACR;IACA;QACEJ,YAAY;QACZC,SAAS;QACTC,UAAU;YAAC;SAAM;QACjBC,UAAU;QACVC,MAAM;IACR;IACA;QACEJ,YAAY;QACZC,SAAS;QACTC,UAAU;YAAC;SAA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CAAE;QACjC,sEAAsE;QACtE,oEAAoE;QACpE,MAAMwC,YAAY,CAAC,CAAC,EAAExJ,2BAA2B,CAAC,CAAC;QACnDsJ,WAAW1B,IAAI,IAAI,AAAC,CAAA,MAAML,YAAYb,IAAI6C,OAAO/B,GAAG,EAAE,GAAG,EAAC,EAAG3G,MAAM,CAAC,CAAC8G,QAAU,CAACA,MAAME,IAAI,CAACrB,QAAQ,CAACgD;IACtG;IACArC,IAAI,CAAC,iBAAiB,GAAGmC;IAEzB,yDAAyD;IACzD,MAAMG,aAAa,MAAM/C,GACtBnG,UAAU,CAAC,kBACXwG,KAAK,CAAC,SAAS,MAAM6B,OACrB9F,GAAG;IACNJ,MAAM,CAAC,iBAAiB,GAAG+G,WAAWzC,IAAI,CAAC7D,MAAM;IAEjD,OAAO;QACLoD,SAAS;YAAE+B,MAAM;YAAO1B,IAAIgC;QAAM;QAClCL,aAAa,IAAIC,OAAO1C,WAAW;QACnC2C,UAAUnC,WAAW;QACrBa;QACAzE;QACAgG,WAAWrC;IACb;AACF;AAEA,2EAA2E,GAC3E,OAAO,SAASqD,eAAehJ,QAA4B;IACzD,MAAMiJ,MAAMjJ,SAAS6H,WAAW,CAACqB,KAAK,CAAC,GAAG;IAC1C,OAAO,CAAC,MAAM,EAAElJ,SAAS6F,OAAO,CAAC+B,IAAI,CAAC,MAAM,EAAE5H,SAAS6F,OAAO,CAACK,EAAE,CAAC,CAAC,EAAE+C,IAAI,KAAK,CAAC;AACjF;AAEA,eAAe1B,eAAc"}
package/src/tenancy.d.ts CHANGED
@@ -20,8 +20,8 @@ export * from './lib/server/api-keys';
20
20
  export * from './lib/server/account-emails';
21
21
  export * from './lib/server/auth-pools';
22
22
  export * from './lib/server/client-error-report';
23
- export { merchantAccountIsReady, merchantAccountReadiness, paymentProvider, } from './lib/server/payment-provider';
24
- export type { MerchantAccountReadiness, MerchantAccountReadinessInput, PaymentMode, PaymentProvider, PaymentProviderEvent, } from './lib/server/payment-provider';
23
+ export { accountChargeModel, connectedAccountHeader, DIRECT_CHARGE_ACCOUNT_PARAMS, directChargeParams, merchantAccountIsReady, merchantAccountReadiness, paymentProvider, saleChargeModel, } from './lib/server/payment-provider';
24
+ export type { SaleChargeModel, MerchantAccountReadiness, MerchantAccountReadinessInput, PaymentMode, PaymentProvider, PaymentProviderEvent, } from './lib/server/payment-provider';
25
25
  export * from './lib/server/auth-handoff';
26
26
  export * from './lib/server/console-domains';
27
27
  export * from './lib/server/dns-probe';
package/src/tenancy.js CHANGED
@@ -23,7 +23,7 @@ export * from "./lib/server/client-error-report.js";
23
23
  // a plugin asks the contract, and the doors that only need the readiness rule
24
24
  // import `@aglyn/tenant-data-admin/server/payment-provider` directly, which
25
25
  // loads no Firebase.
26
- export { merchantAccountIsReady, merchantAccountReadiness, paymentProvider } from "./lib/server/payment-provider.js";
26
+ export { accountChargeModel, connectedAccountHeader, DIRECT_CHARGE_ACCOUNT_PARAMS, directChargeParams, merchantAccountIsReady, merchantAccountReadiness, paymentProvider, saleChargeModel } from "./lib/server/payment-provider.js";
27
27
  export * from "./lib/server/auth-handoff.js";
28
28
  export * from "./lib/server/console-domains.js";
29
29
  export * from "./lib/server/dns-probe.js";
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../libs/tenant/data/admin/src/tenancy.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2022 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\nexport * from './lib/server/analytics-retention'\nexport * from './lib/server/api-http'\nexport * from './lib/server/api-keys'\nexport * from './lib/server/account-emails'\nexport * from './lib/server/auth-pools'\nexport * from './lib/server/client-error-report'\n// The merchant's payment account, as a contract. Its adapter is not exported:\n// a plugin asks the contract, and the doors that only need the readiness rule\n// import `@aglyn/tenant-data-admin/server/payment-provider` directly, which\n// loads no Firebase.\nexport {\n merchantAccountIsReady,\n merchantAccountReadiness,\n paymentProvider,\n} from './lib/server/payment-provider'\nexport type {\n MerchantAccountReadiness,\n MerchantAccountReadinessInput,\n PaymentMode,\n PaymentProvider,\n PaymentProviderEvent,\n} from './lib/server/payment-provider'\nexport * from './lib/server/auth-handoff'\nexport * from './lib/server/console-domains'\nexport * from './lib/server/dns-probe'\n// Whether a name points at the tenant edge, for the verify route and the\n// domains plugin's one-click DNS (AGL-3963).\nexport * from './lib/server/tenant-dns-check'\nexport * from './lib/server/sending-domains'\nexport * from './lib/server/sender-readiness'\nexport * from './lib/server/host-sending-domain'\nexport * from './lib/server/sending-domain-debt'\nexport * from './lib/server/sending-domain-recheck'\n// The hosting seam itself, so a door can ask whether this deployment is able\n// to register a name at all before it promises the caller one.\n// `workspace-domains` re-exports the pieces its own callers share with it; the\n// provider behind it is not among them.\nexport { domainProvider } from './lib/server/domain-provider'\nexport type {\n DomainProvider,\n DomainProviderId,\n DomainScope,\n} from './lib/server/domain-provider'\nexport * from './lib/server/platform-domain-names'\nexport * from './lib/server/consume-once'\nexport * from './lib/server/csp-aggregate'\nexport * from './lib/server/data-storage-gate'\nexport * from './lib/server/contact-suppression'\nexport * from './lib/server/email-suppression'\n// The double opt-in quarantine, after the module whose keying it shares and\n// whose `filterTopicSendable` is the reader that makes it a quarantine rather\n// than a stored fact.\nexport * from './lib/server/topic-subscriptions'\nexport * from './lib/server/email-unsubscribe-link'\nexport * from './lib/server/email-flow-gate'\n// Side-effecting on purpose, for the reason `email-send-rate` below is:\n// evaluating this module INSTALLS the marketing gate on `sendEmail`, so the\n// unsubscribe header, the suppression check and the frequency ceiling reach\n// every bulk sender without a call at each server entrypoint.\nexport * from './lib/server/email-marketing-gate'\n// A consent group change (AGL-3320): the carries of the three stores above,\n// and the executor that runs a change around them.\nexport * from './lib/server/consent-group-carry'\nexport * from './lib/server/consent-group-change'\n// A person's refusal kept after the record it was written on is deleted\n// (AGL-3338): the delete's write, the list gate's read, and the change's carry.\nexport * from './lib/server/retained-refusals'\nexport * from './lib/server/sms-keywords'\nexport * from './lib/server/document-id'\nexport * from './lib/server/collection-preview-token'\nexport * from './lib/server/edit-access-authz'\nexport * from './lib/server/edit-access-token'\nexport * from './lib/server/edit-hint-token'\nexport * from './lib/server/email-metering'\n// Side-effecting on purpose (AGL-2409): evaluating this module INSTALLS the\n// platform send-rate governor on `sendEmail`. Every server surface already\n// imports this barrel, so nothing has to remember to call an installer.\nexport * from './lib/server/email-send-rate'\n// Side-effecting on purpose, for the same reason (AGL-4145): evaluating this\n// module INSTALLS the daily transactional ceiling on `sendEmail`, so a site's\n// non-campaign mail is counted per organization per UTC day on every send\n// path at once.\nexport * from './lib/server/email-transactional-ceiling'\n// Side-effecting on purpose, for the same reason (AGL-3328): evaluating this\n// module INSTALLS the deliverability preflight on `sendEmail`, so a recipient\n// whose domain takes no mail is refused, and bulk mail behind a gateway that\n// refused its sending domain twice is held, on every send path at once.\nexport * from './lib/server/email-deliverability'\nexport * from './lib/server/email-sender-reputation'\nexport * from './lib/server/erase'\nexport * from './lib/server/erase-person'\nexport * from './lib/server/dynamic-list-materialize'\nexport * from './lib/server/firebase-admin'\nexport * from './lib/server/free-workspace-cap'\nexport * from './lib/server/ga4-measurement-protocol'\nexport * from './lib/server/host-memberships'\n// Connecting a name to a site, for the attach route and for plugins that\n// bought the name (AGL-3961).\nexport * from './lib/server/host-custom-domain'\nexport * from './lib/server/custom-domain-redirects'\nexport * from './lib/server/host-visitor-records'\nexport * from './lib/server/list-members'\nexport * from './lib/server/lockdown'\nexport * from './lib/server/token-revocation'\nexport * from './lib/server/tenant-write-lockdown'\nexport * from './lib/server/outbound-send-review'\n// The same review for a published page, read where it is composed (AGL-3356).\nexport * from './lib/server/hosted-page-review'\n// Every hold, flag, lock and pause tells owners and staff through one seam (AGL-3368).\nexport * from './lib/server/risk-notice'\nexport * from './lib/server/host-email-tokens'\nexport * from './lib/server/notifications'\n// Every operator alert raises through one entry point, and every health check\n// remembers its state (AGL-3377).\nexport * from './lib/server/operator-alerts'\nexport * from './lib/server/operator-health'\nexport * from './lib/server/org-billing'\nexport * from './lib/server/organizations'\n// Per-member permission overrides, org-wide and per site (AGL-4047).\nexport * from './lib/server/member-permission-overrides'\n// Platform staff take no customer seat, and a workspace is asked to upgrade\n// as a separate step after it is handed over (AGL-3466).\nexport * from './lib/server/staff-seat'\nexport * from './lib/server/upgrade-proposal'\nexport * from './lib/server/duplicate-activity'\nexport * from './lib/server/duplicate-resource'\nexport * from './lib/server/workspace-domains'\nexport * from './lib/server/membership-recover-throttle'\nexport * from './lib/server/password-reset-throttle'\nexport * from './lib/server/rate-limit-store'\nexport * from './lib/server/verify-email-cooldown'\nexport * from './lib/server/vercel-drain-signature'\nexport * from './lib/server/vercel-log-drain'\nexport * from './lib/server/visitor-write-rate-limit'\nexport * from './lib/server/card-payment-velocity'\nexport * from './lib/server/console-api-rate-limit'\nexport * from './lib/server/realm-plugins'\nexport * from './lib/server/release-flags'\nexport * from './lib/server/resolve-people'\nexport * from './lib/server/member-photo'\nexport * from './lib/server/personal-data-export'\nexport * from './lib/server/media-delivery'\nexport * from './lib/server/media-download-tokens'\nexport * from './lib/server/media-quarantine'\nexport * from './lib/server/media-signing'\nexport * from './lib/server/media-storage-path'\nexport * from './lib/server/safe-equal'\nexport * from './lib/server/media-strong-digest'\nexport * from './lib/server/media-tombstone'\nexport * from './lib/server/media-delivery-regeneration'\nexport * from './lib/server/media-variants'\nexport * from './lib/server/media-photo-links'\n// The one-screen build for a client (AGL-3958): staff hold its record.\nexport * from './lib/server/client-build'\nexport * from './lib/server/serve-media-cdn'\nexport * from './lib/server/serve-plugin-fetch'\nexport * from './lib/server/configured-url-fetch'\nexport * from './lib/server/sso-break-glass-owners'\nexport * from './lib/server/sso-domain-policy'\nexport * from './lib/server/sso-enforcement'\nexport * from './lib/server/sso-provisioning'\nexport * from './lib/server/update-existing'\nexport * from './lib/server/contact-company-link'\nexport * from './lib/server/contact-email-index'\nexport * from './lib/server/upsert-contact'\nexport * from './lib/server/crm-records'\n// The `nextTaskAtMs` a contact, a company and a deal carry, recomputed from\n// their open tasks by every server-side task writer (AGL-2661).\n// Where a one-to-one email's activity row lives and how the delivery\n// webhook advances it (AGL-2615).\n// A member's own addresses in a workspace, and the signed link that\n// confirms one (AGL-2975).\nexport * from './lib/server/member-email-aliases'\nexport * from './lib/server/user-profiles'\n// One answer to an account's name and photo, and the SSO sign-in fill of a\n// blank Auth record (AGL-3721).\nexport * from './lib/server/account-identity'\n// The one \"New account\" staff notice per account, keyed on the auth\n// record's creation (AGL-3225).\nexport * from './lib/server/new-account-announcement'\nexport * from './lib/server/legal-acceptance'\n// The person's decision about the platform's own product email, on their\n// document and on the operator's marketing contact (AGL-3185).\nexport * from './lib/server/platform-marketing-consent'\n"],"names":["merchantAccountIsReady","merchantAccountReadiness","paymentProvider","domainProvider"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,cAAc,sCAAkC;AAChD,cAAc,2BAAuB;AACrC,cAAc,2BAAuB;AACrC,cAAc,iCAA6B;AAC3C,cAAc,6BAAyB;AACvC,cAAc,sCAAkC;AAChD,8EAA8E;AAC9E,8EAA8E;AAC9E,4EAA4E;AAC5E,qBAAqB;AACrB,SACEA,sBAAsB,EACtBC,wBAAwB,EACxBC,eAAe,QACV,mCAA+B;AAQtC,cAAc,+BAA2B;AACzC,cAAc,kCAA8B;AAC5C,cAAc,4BAAwB;AACtC,yEAAyE;AACzE,6CAA6C;AAC7C,cAAc,mCAA+B;AAC7C,cAAc,kCAA8B;AAC5C,cAAc,mCAA+B;AAC7C,cAAc,sCAAkC;AAChD,cAAc,sCAAkC;AAChD,cAAc,yCAAqC;AACnD,6EAA6E;AAC7E,+DAA+D;AAC/D,+EAA+E;AAC/E,wCAAwC;AACxC,SAASC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E;AACrE,kCAAkC;AAClC,oEAAoE;AACpE,2BAA2B;AAC3B,cAAc,uCAAmC;AACjD,cAAc,gCAA4B;AAC1C,2EAA2E;AAC3E,gCAAgC;AAChC,cAAc,mCAA+B;AAC7C,oEAAoE;AACpE,gCAAgC;AAChC,cAAc,2CAAuC;AACrD,cAAc,mCAA+B;AAC7C,yEAAyE;AACzE,+DAA+D;AAC/D,cAAc,6CAAyC"}
1
+ {"version":3,"sources":["../../../../../../libs/tenant/data/admin/src/tenancy.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2022 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\nexport * from './lib/server/analytics-retention'\nexport * from './lib/server/api-http'\nexport * from './lib/server/api-keys'\nexport * from './lib/server/account-emails'\nexport * from './lib/server/auth-pools'\nexport * from './lib/server/client-error-report'\n// The merchant's payment account, as a contract. Its adapter is not exported:\n// a plugin asks the contract, and the doors that only need the readiness rule\n// import `@aglyn/tenant-data-admin/server/payment-provider` directly, which\n// loads no Firebase.\nexport {\n accountChargeModel,\n connectedAccountHeader,\n DIRECT_CHARGE_ACCOUNT_PARAMS,\n directChargeParams,\n merchantAccountIsReady,\n merchantAccountReadiness,\n paymentProvider,\n saleChargeModel,\n} from './lib/server/payment-provider'\nexport type {\n SaleChargeModel,\n MerchantAccountReadiness,\n MerchantAccountReadinessInput,\n PaymentMode,\n PaymentProvider,\n PaymentProviderEvent,\n} from './lib/server/payment-provider'\nexport * from './lib/server/auth-handoff'\nexport * from './lib/server/console-domains'\nexport * from './lib/server/dns-probe'\n// Whether a name points at the tenant edge, for the verify route and the\n// domains plugin's one-click DNS (AGL-3963).\nexport * from './lib/server/tenant-dns-check'\nexport * from './lib/server/sending-domains'\nexport * from './lib/server/sender-readiness'\nexport * from './lib/server/host-sending-domain'\nexport * from './lib/server/sending-domain-debt'\nexport * from './lib/server/sending-domain-recheck'\n// The hosting seam itself, so a door can ask whether this deployment is able\n// to register a name at all before it promises the caller one.\n// `workspace-domains` re-exports the pieces its own callers share with it; the\n// provider behind it is not among them.\nexport { domainProvider } from './lib/server/domain-provider'\nexport type {\n DomainProvider,\n DomainProviderId,\n DomainScope,\n} from './lib/server/domain-provider'\nexport * from './lib/server/platform-domain-names'\nexport * from './lib/server/consume-once'\nexport * from './lib/server/csp-aggregate'\nexport * from './lib/server/data-storage-gate'\nexport * from './lib/server/contact-suppression'\nexport * from './lib/server/email-suppression'\n// The double opt-in quarantine, after the module whose keying it shares and\n// whose `filterTopicSendable` is the reader that makes it a quarantine rather\n// than a stored fact.\nexport * from './lib/server/topic-subscriptions'\nexport * from './lib/server/email-unsubscribe-link'\nexport * from './lib/server/email-flow-gate'\n// Side-effecting on purpose, for the reason `email-send-rate` below is:\n// evaluating this module INSTALLS the marketing gate on `sendEmail`, so the\n// unsubscribe header, the suppression check and the frequency ceiling reach\n// every bulk sender without a call at each server entrypoint.\nexport * from './lib/server/email-marketing-gate'\n// A consent group change (AGL-3320): the carries of the three stores above,\n// and the executor that runs a change around them.\nexport * from './lib/server/consent-group-carry'\nexport * from './lib/server/consent-group-change'\n// A person's refusal kept after the record it was written on is deleted\n// (AGL-3338): the delete's write, the list gate's read, and the change's carry.\nexport * from './lib/server/retained-refusals'\nexport * from './lib/server/sms-keywords'\nexport * from './lib/server/document-id'\nexport * from './lib/server/collection-preview-token'\nexport * from './lib/server/edit-access-authz'\nexport * from './lib/server/edit-access-token'\nexport * from './lib/server/edit-hint-token'\nexport * from './lib/server/email-metering'\n// Side-effecting on purpose (AGL-2409): evaluating this module INSTALLS the\n// platform send-rate governor on `sendEmail`. Every server surface already\n// imports this barrel, so nothing has to remember to call an installer.\nexport * from './lib/server/email-send-rate'\n// Side-effecting on purpose, for the same reason (AGL-4145): evaluating this\n// module INSTALLS the daily transactional ceiling on `sendEmail`, so a site's\n// non-campaign mail is counted per organization per UTC day on every send\n// path at once.\nexport * from './lib/server/email-transactional-ceiling'\n// Side-effecting on purpose, for the same reason (AGL-3328): evaluating this\n// module INSTALLS the deliverability preflight on `sendEmail`, so a recipient\n// whose domain takes no mail is refused, and bulk mail behind a gateway that\n// refused its sending domain twice is held, on every send path at once.\nexport * from './lib/server/email-deliverability'\nexport * from './lib/server/email-sender-reputation'\nexport * from './lib/server/erase'\nexport * from './lib/server/erase-person'\nexport * from './lib/server/dynamic-list-materialize'\nexport * from './lib/server/firebase-admin'\nexport * from './lib/server/free-workspace-cap'\nexport * from './lib/server/ga4-measurement-protocol'\nexport * from './lib/server/host-memberships'\n// Connecting a name to a site, for the attach route and for plugins that\n// bought the name (AGL-3961).\nexport * from './lib/server/host-custom-domain'\nexport * from './lib/server/custom-domain-redirects'\nexport * from './lib/server/host-visitor-records'\nexport * from './lib/server/list-members'\nexport * from './lib/server/lockdown'\nexport * from './lib/server/token-revocation'\nexport * from './lib/server/tenant-write-lockdown'\nexport * from './lib/server/outbound-send-review'\n// The same review for a published page, read where it is composed (AGL-3356).\nexport * from './lib/server/hosted-page-review'\n// Every hold, flag, lock and pause tells owners and staff through one seam (AGL-3368).\nexport * from './lib/server/risk-notice'\nexport * from './lib/server/host-email-tokens'\nexport * from './lib/server/notifications'\n// Every operator alert raises through one entry point, and every health check\n// remembers its state (AGL-3377).\nexport * from './lib/server/operator-alerts'\nexport * from './lib/server/operator-health'\nexport * from './lib/server/org-billing'\nexport * from './lib/server/organizations'\n// Per-member permission overrides, org-wide and per site (AGL-4047).\nexport * from './lib/server/member-permission-overrides'\n// Platform staff take no customer seat, and a workspace is asked to upgrade\n// as a separate step after it is handed over (AGL-3466).\nexport * from './lib/server/staff-seat'\nexport * from './lib/server/upgrade-proposal'\nexport * from './lib/server/duplicate-activity'\nexport * from './lib/server/duplicate-resource'\nexport * from './lib/server/workspace-domains'\nexport * from './lib/server/membership-recover-throttle'\nexport * from './lib/server/password-reset-throttle'\nexport * from './lib/server/rate-limit-store'\nexport * from './lib/server/verify-email-cooldown'\nexport * from './lib/server/vercel-drain-signature'\nexport * from './lib/server/vercel-log-drain'\nexport * from './lib/server/visitor-write-rate-limit'\nexport * from './lib/server/card-payment-velocity'\nexport * from './lib/server/console-api-rate-limit'\nexport * from './lib/server/realm-plugins'\nexport * from './lib/server/release-flags'\nexport * from './lib/server/resolve-people'\nexport * from './lib/server/member-photo'\nexport * from './lib/server/personal-data-export'\nexport * from './lib/server/media-delivery'\nexport * from './lib/server/media-download-tokens'\nexport * from './lib/server/media-quarantine'\nexport * from './lib/server/media-signing'\nexport * from './lib/server/media-storage-path'\nexport * from './lib/server/safe-equal'\nexport * from './lib/server/media-strong-digest'\nexport * from './lib/server/media-tombstone'\nexport * from './lib/server/media-delivery-regeneration'\nexport * from './lib/server/media-variants'\nexport * from './lib/server/media-photo-links'\n// The one-screen build for a client (AGL-3958): staff hold its record.\nexport * from './lib/server/client-build'\nexport * from './lib/server/serve-media-cdn'\nexport * from './lib/server/serve-plugin-fetch'\nexport * from './lib/server/configured-url-fetch'\nexport * from './lib/server/sso-break-glass-owners'\nexport * from './lib/server/sso-domain-policy'\nexport * from './lib/server/sso-enforcement'\nexport * from './lib/server/sso-provisioning'\nexport * from './lib/server/update-existing'\nexport * from './lib/server/contact-company-link'\nexport * from './lib/server/contact-email-index'\nexport * from './lib/server/upsert-contact'\nexport * from './lib/server/crm-records'\n// The `nextTaskAtMs` a contact, a company and a deal carry, recomputed from\n// their open tasks by every server-side task writer (AGL-2661).\n// Where a one-to-one email's activity row lives and how the delivery\n// webhook advances it (AGL-2615).\n// A member's own addresses in a workspace, and the signed link that\n// confirms one (AGL-2975).\nexport * from './lib/server/member-email-aliases'\nexport * from './lib/server/user-profiles'\n// One answer to an account's name and photo, and the SSO sign-in fill of a\n// blank Auth record (AGL-3721).\nexport * from './lib/server/account-identity'\n// The one \"New account\" staff notice per account, keyed on the auth\n// record's creation (AGL-3225).\nexport * from './lib/server/new-account-announcement'\nexport * from './lib/server/legal-acceptance'\n// The person's decision about the platform's own product email, on their\n// document and on the operator's marketing contact (AGL-3185).\nexport * from './lib/server/platform-marketing-consent'\n"],"names":["accountChargeModel","connectedAccountHeader","DIRECT_CHARGE_ACCOUNT_PARAMS","directChargeParams","merchantAccountIsReady","merchantAccountReadiness","paymentProvider","saleChargeModel","domainProvider"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,cAAc,sCAAkC;AAChD,cAAc,2BAAuB;AACrC,cAAc,2BAAuB;AACrC,cAAc,iCAA6B;AAC3C,cAAc,6BAAyB;AACvC,cAAc,sCAAkC;AAChD,8EAA8E;AAC9E,8EAA8E;AAC9E,4EAA4E;AAC5E,qBAAqB;AACrB,SACEA,kBAAkB,EAClBC,sBAAsB,EACtBC,4BAA4B,EAC5BC,kBAAkB,EAClBC,sBAAsB,EACtBC,wBAAwB,EACxBC,eAAe,EACfC,eAAe,QACV,mCAA+B;AAStC,cAAc,+BAA2B;AACzC,cAAc,kCAA8B;AAC5C,cAAc,4BAAwB;AACtC,yEAAyE;AACzE,6CAA6C;AAC7C,cAAc,mCAA+B;AAC7C,cAAc,kCAA8B;AAC5C,cAAc,mCAA+B;AAC7C,cAAc,sCAAkC;AAChD,cAAc,sCAAkC;AAChD,cAAc,yCAAqC;AACnD,6EAA6E;AAC7E,+DAA+D;AAC/D,+EAA+E;AAC/E,wCAAwC;AACxC,SAASC,cAAc,QAAQ,kCAA8B;AAM7D,cAAc,wCAAoC;AAClD,cAAc,+BAA2B;AACzC,cAAc,gCAA4B;AAC1C,cAAc,oCAAgC;AAC9C,cAAc,sCAAkC;AAChD,cAAc,oCAAgC;AAC9C,4EAA4E;AAC5E,8EAA8E;AAC9E,sBAAsB;AACtB,cAAc,sCAAkC;AAChD,cAAc,yCAAqC;AACnD,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