@aglyn/tenant-feature-instance 1.0.0-beta.143

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +3 -0
  3. package/jest.config.d.ts +36 -0
  4. package/package.json +45 -0
  5. package/src/index.d.ts +17 -0
  6. package/src/index.js +18 -0
  7. package/src/index.js.map +1 -0
  8. package/src/lib/components/duplicate-resource-dialog.d.ts +77 -0
  9. package/src/lib/components/duplicate-resource-dialog.js +217 -0
  10. package/src/lib/components/duplicate-resource-dialog.js.map +1 -0
  11. package/src/lib/constants/firebase-config.d.ts +68 -0
  12. package/src/lib/constants/firebase-config.js +155 -0
  13. package/src/lib/constants/firebase-config.js.map +1 -0
  14. package/src/lib/constants/firebase-emulator-hosts.d.ts +60 -0
  15. package/src/lib/constants/firebase-emulator-hosts.js +81 -0
  16. package/src/lib/constants/firebase-emulator-hosts.js.map +1 -0
  17. package/src/lib/constants/mock-data.d.ts +24 -0
  18. package/src/lib/constants/mock-data.js +49 -0
  19. package/src/lib/constants/mock-data.js.map +1 -0
  20. package/src/lib/constants/site-paths.d.ts +47 -0
  21. package/src/lib/constants/site-paths.js +66 -0
  22. package/src/lib/constants/site-paths.js.map +1 -0
  23. package/src/lib/hooks/firebase/auth-persistence.d.ts +74 -0
  24. package/src/lib/hooks/firebase/auth-persistence.js +117 -0
  25. package/src/lib/hooks/firebase/auth-persistence.js.map +1 -0
  26. package/src/lib/hooks/firebase/firebase-services.d.ts +172 -0
  27. package/src/lib/hooks/firebase/firebase-services.js +522 -0
  28. package/src/lib/hooks/firebase/firebase-services.js.map +1 -0
  29. package/src/lib/hooks/firebase/firestore-cache.d.ts +125 -0
  30. package/src/lib/hooks/firebase/firestore-cache.js +152 -0
  31. package/src/lib/hooks/firebase/firestore-cache.js.map +1 -0
  32. package/src/lib/hooks/firebase/firestore-shared-client-state.d.ts +169 -0
  33. package/src/lib/hooks/firebase/firestore-shared-client-state.js +316 -0
  34. package/src/lib/hooks/firebase/firestore-shared-client-state.js.map +1 -0
  35. package/src/lib/hooks/firestore-denial-reporter.d.ts +192 -0
  36. package/src/lib/hooks/firestore-denial-reporter.js +293 -0
  37. package/src/lib/hooks/firestore-denial-reporter.js.map +1 -0
  38. package/src/lib/hooks/helpers/besigner-nodes-converter.d.ts +62 -0
  39. package/src/lib/hooks/helpers/besigner-nodes-converter.js +91 -0
  40. package/src/lib/hooks/helpers/besigner-nodes-converter.js.map +1 -0
  41. package/src/lib/hooks/helpers/guarded-nodes-save.d.ts +80 -0
  42. package/src/lib/hooks/helpers/guarded-nodes-save.js +89 -0
  43. package/src/lib/hooks/helpers/guarded-nodes-save.js.map +1 -0
  44. package/src/lib/hooks/helpers/guarded-seed-write.d.ts +125 -0
  45. package/src/lib/hooks/helpers/guarded-seed-write.js +193 -0
  46. package/src/lib/hooks/helpers/guarded-seed-write.js.map +1 -0
  47. package/src/lib/hooks/helpers/listen-options.d.ts +91 -0
  48. package/src/lib/hooks/helpers/listen-options.js +92 -0
  49. package/src/lib/hooks/helpers/listen-options.js.map +1 -0
  50. package/src/lib/hooks/helpers/use-doc.d.ts +38 -0
  51. package/src/lib/hooks/helpers/use-doc.js +213 -0
  52. package/src/lib/hooks/helpers/use-doc.js.map +1 -0
  53. package/src/lib/hooks/helpers/use-modify-doc-callback.d.ts +28 -0
  54. package/src/lib/hooks/helpers/use-modify-doc-callback.js +110 -0
  55. package/src/lib/hooks/helpers/use-modify-doc-callback.js.map +1 -0
  56. package/src/lib/hooks/host-collection-queries.d.ts +125 -0
  57. package/src/lib/hooks/host-collection-queries.js +126 -0
  58. package/src/lib/hooks/host-collection-queries.js.map +1 -0
  59. package/src/lib/hooks/list-filter-constraints.d.ts +64 -0
  60. package/src/lib/hooks/list-filter-constraints.js +288 -0
  61. package/src/lib/hooks/list-filter-constraints.js.map +1 -0
  62. package/src/lib/hooks/sorted-collection-window.d.ts +207 -0
  63. package/src/lib/hooks/sorted-collection-window.js +150 -0
  64. package/src/lib/hooks/sorted-collection-window.js.map +1 -0
  65. package/src/lib/hooks/use-component-version.d.ts +43 -0
  66. package/src/lib/hooks/use-component-version.js +73 -0
  67. package/src/lib/hooks/use-component-version.js.map +1 -0
  68. package/src/lib/hooks/use-component.d.ts +39 -0
  69. package/src/lib/hooks/use-component.js +55 -0
  70. package/src/lib/hooks/use-component.js.map +1 -0
  71. package/src/lib/hooks/use-console-host-route.d.ts +24 -0
  72. package/src/lib/hooks/use-console-host-route.js +77 -0
  73. package/src/lib/hooks/use-console-host-route.js.map +1 -0
  74. package/src/lib/hooks/use-duplicate-resource-api.d.ts +43 -0
  75. package/src/lib/hooks/use-duplicate-resource-api.js +61 -0
  76. package/src/lib/hooks/use-duplicate-resource-api.js.map +1 -0
  77. package/src/lib/hooks/use-firestore-collection.d.ts +62 -0
  78. package/src/lib/hooks/use-firestore-collection.js +307 -0
  79. package/src/lib/hooks/use-firestore-collection.js.map +1 -0
  80. package/src/lib/hooks/use-firestore-doc.d.ts +42 -0
  81. package/src/lib/hooks/use-firestore-doc.js +192 -0
  82. package/src/lib/hooks/use-firestore-doc.js.map +1 -0
  83. package/src/lib/hooks/use-form-version.d.ts +44 -0
  84. package/src/lib/hooks/use-form-version.js +73 -0
  85. package/src/lib/hooks/use-form-version.js.map +1 -0
  86. package/src/lib/hooks/use-host-activity-logger.d.ts +35 -0
  87. package/src/lib/hooks/use-host-activity-logger.js +96 -0
  88. package/src/lib/hooks/use-host-activity-logger.js.map +1 -0
  89. package/src/lib/hooks/use-host-campaigns.d.ts +53 -0
  90. package/src/lib/hooks/use-host-campaigns.js +93 -0
  91. package/src/lib/hooks/use-host-campaigns.js.map +1 -0
  92. package/src/lib/hooks/use-host-org-id.d.ts +96 -0
  93. package/src/lib/hooks/use-host-org-id.js +154 -0
  94. package/src/lib/hooks/use-host-org-id.js.map +1 -0
  95. package/src/lib/hooks/use-host-resource-api.d.ts +43 -0
  96. package/src/lib/hooks/use-host-resource-api.js +60 -0
  97. package/src/lib/hooks/use-host-resource-api.js.map +1 -0
  98. package/src/lib/hooks/use-host-template.d.ts +44 -0
  99. package/src/lib/hooks/use-host-template.js +82 -0
  100. package/src/lib/hooks/use-host-template.js.map +1 -0
  101. package/src/lib/hooks/use-host-version-api.d.ts +59 -0
  102. package/src/lib/hooks/use-host-version-api.js +69 -0
  103. package/src/lib/hooks/use-host-version-api.js.map +1 -0
  104. package/src/lib/hooks/use-host.d.ts +101 -0
  105. package/src/lib/hooks/use-host.js +45 -0
  106. package/src/lib/hooks/use-host.js.map +1 -0
  107. package/src/lib/hooks/use-layout-version.d.ts +33 -0
  108. package/src/lib/hooks/use-layout-version.js +64 -0
  109. package/src/lib/hooks/use-layout-version.js.map +1 -0
  110. package/src/lib/hooks/use-layout.d.ts +41 -0
  111. package/src/lib/hooks/use-layout.js +49 -0
  112. package/src/lib/hooks/use-layout.js.map +1 -0
  113. package/src/lib/hooks/use-live-artifact-count.d.ts +50 -0
  114. package/src/lib/hooks/use-live-artifact-count.js +102 -0
  115. package/src/lib/hooks/use-live-artifact-count.js.map +1 -0
  116. package/src/lib/hooks/use-org-member-options.d.ts +57 -0
  117. package/src/lib/hooks/use-org-member-options.js +112 -0
  118. package/src/lib/hooks/use-org-member-options.js.map +1 -0
  119. package/src/lib/hooks/use-org-plan.d.ts +46 -0
  120. package/src/lib/hooks/use-org-plan.js +86 -0
  121. package/src/lib/hooks/use-org-plan.js.map +1 -0
  122. package/src/lib/hooks/use-paged-collection.d.ts +95 -0
  123. package/src/lib/hooks/use-paged-collection.js +130 -0
  124. package/src/lib/hooks/use-paged-collection.js.map +1 -0
  125. package/src/lib/hooks/use-plugin-config.d.ts +38 -0
  126. package/src/lib/hooks/use-plugin-config.js +120 -0
  127. package/src/lib/hooks/use-plugin-config.js.map +1 -0
  128. package/src/lib/hooks/use-scope-tokens.d.ts +28 -0
  129. package/src/lib/hooks/use-scope-tokens.js +100 -0
  130. package/src/lib/hooks/use-scope-tokens.js.map +1 -0
  131. package/src/lib/hooks/use-screen-version.d.ts +33 -0
  132. package/src/lib/hooks/use-screen-version.js +65 -0
  133. package/src/lib/hooks/use-screen-version.js.map +1 -0
  134. package/src/lib/hooks/use-screen.d.ts +68 -0
  135. package/src/lib/hooks/use-screen.js +50 -0
  136. package/src/lib/hooks/use-screen.js.map +1 -0
  137. package/src/lib/hooks/use-sending-identity-api.d.ts +197 -0
  138. package/src/lib/hooks/use-sending-identity-api.js +95 -0
  139. package/src/lib/hooks/use-sending-identity-api.js.map +1 -0
  140. package/src/lib/hooks/use-sorted-paged-collection.d.ts +48 -0
  141. package/src/lib/hooks/use-sorted-paged-collection.js +213 -0
  142. package/src/lib/hooks/use-sorted-paged-collection.js.map +1 -0
  143. package/src/lib/hooks/use-switcher-collection.d.ts +105 -0
  144. package/src/lib/hooks/use-switcher-collection.js +275 -0
  145. package/src/lib/hooks/use-switcher-collection.js.map +1 -0
  146. package/src/lib/hooks/use-user-name.d.ts +51 -0
  147. package/src/lib/hooks/use-user-name.js +90 -0
  148. package/src/lib/hooks/use-user-name.js.map +1 -0
  149. package/src/lib/hooks/use-user-photo.d.ts +50 -0
  150. package/src/lib/hooks/use-user-photo.js +87 -0
  151. package/src/lib/hooks/use-user-photo.js.map +1 -0
  152. package/src/lib/tenant.d.ts +61 -0
  153. package/src/lib/tenant.js +62 -0
  154. package/src/lib/tenant.js.map +1 -0
@@ -0,0 +1,68 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { type FirebaseOptions } from 'firebase/app';
18
+ export declare const RECAPTCHA_API_KEY: string;
19
+ export declare const FIREBASE_CLIENT_APP_NAME = "DEFAULT_AGLYN";
20
+ /**
21
+ * The App Check reCAPTCHA site key, or `null` when it is unset or blank
22
+ * (AGL-2049).
23
+ *
24
+ * ## Why a guard, when `new ReCaptchaV3Provider(undefined)` does not throw
25
+ *
26
+ * That is precisely the problem. It does not throw — it stores the value and
27
+ * returns, `initializeAppCheck` returns normally, and the SDK then requests
28
+ * `https://www.google.com/recaptcha/api.js?render=undefined`. The failure is
29
+ * ASYNCHRONOUS, so the `try/catch` both call sites wrap this in never sees it.
30
+ * What the operator gets is a provider registered against an app it can never
31
+ * mint a token for, plus console errors on every page, and nothing anywhere
32
+ * that says the key is missing.
33
+ *
34
+ * Two configurations reach it:
35
+ *
36
+ * - **Self-host.** `.env.selfhost.example` ships the variable EMPTY, so the
37
+ * documented self-host path lands here by default. AGL-2049 named this and
38
+ * deliberately left it; this is that fix.
39
+ * - **A misconfigured deployment.** On the `aglyn-tenant` Vercel project this
40
+ * variable was misspelled `NEXT_PUBLIC_RECPATCHA_PUBLIC_KEY` for three
41
+ * years and eleven months, so `RECAPTCHA_API_KEY` was `undefined` in every
42
+ * tenant build ever made. Nothing in the repo read the misspelling, so no
43
+ * lint rule, schema or review could have found it — and nothing at runtime
44
+ * said so either, which is the part this changes.
45
+ *
46
+ * Skipping registration is strictly better than registering a broken one: an
47
+ * app with no App Check provider is a known, visible state (calls are
48
+ * unattested and enforcement refuses them with a clear code), whereas an app
49
+ * with a provider that cannot mint tokens looks configured and is not.
50
+ *
51
+ * ## Read at CALL time, not at module load
52
+ *
53
+ * `NEXT_PUBLIC_*` is inlined textually by webpack's DefinePlugin wherever the
54
+ * expression appears, so this is exactly as static in a production bundle as
55
+ * the module-level constant above. Reading it inside the function is what
56
+ * lets a test drive both directions — with a key and without — instead of
57
+ * asserting the guard exists and never running it.
58
+ */
59
+ export declare function appCheckSiteKey(): string | null;
60
+ /** The one message both call sites log, so a search finds either. */
61
+ export declare const APP_CHECK_KEY_MISSING_MESSAGE: string;
62
+ /**
63
+ * Firebase client-side configuration assembled directly from NEXT_PUBLIC_*
64
+ * environment variables so that Next.js webpack DefinePlugin substitutes
65
+ * them at build time and no intermediate constant indirection can carry a
66
+ * stale undefined value across a cached compilation.
67
+ */
68
+ export declare const fbClientAppOptions: FirebaseOptions;
@@ -0,0 +1,155 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ export const RECAPTCHA_API_KEY = process.env.NEXT_PUBLIC_RECAPTCHA_PUBLIC_KEY;
17
+ export const FIREBASE_CLIENT_APP_NAME = 'DEFAULT_AGLYN';
18
+ /**
19
+ * The App Check reCAPTCHA site key, or `null` when it is unset or blank
20
+ * (AGL-2049).
21
+ *
22
+ * ## Why a guard, when `new ReCaptchaV3Provider(undefined)` does not throw
23
+ *
24
+ * That is precisely the problem. It does not throw — it stores the value and
25
+ * returns, `initializeAppCheck` returns normally, and the SDK then requests
26
+ * `https://www.google.com/recaptcha/api.js?render=undefined`. The failure is
27
+ * ASYNCHRONOUS, so the `try/catch` both call sites wrap this in never sees it.
28
+ * What the operator gets is a provider registered against an app it can never
29
+ * mint a token for, plus console errors on every page, and nothing anywhere
30
+ * that says the key is missing.
31
+ *
32
+ * Two configurations reach it:
33
+ *
34
+ * - **Self-host.** `.env.selfhost.example` ships the variable EMPTY, so the
35
+ * documented self-host path lands here by default. AGL-2049 named this and
36
+ * deliberately left it; this is that fix.
37
+ * - **A misconfigured deployment.** On the `aglyn-tenant` Vercel project this
38
+ * variable was misspelled `NEXT_PUBLIC_RECPATCHA_PUBLIC_KEY` for three
39
+ * years and eleven months, so `RECAPTCHA_API_KEY` was `undefined` in every
40
+ * tenant build ever made. Nothing in the repo read the misspelling, so no
41
+ * lint rule, schema or review could have found it — and nothing at runtime
42
+ * said so either, which is the part this changes.
43
+ *
44
+ * Skipping registration is strictly better than registering a broken one: an
45
+ * app with no App Check provider is a known, visible state (calls are
46
+ * unattested and enforcement refuses them with a clear code), whereas an app
47
+ * with a provider that cannot mint tokens looks configured and is not.
48
+ *
49
+ * ## Read at CALL time, not at module load
50
+ *
51
+ * `NEXT_PUBLIC_*` is inlined textually by webpack's DefinePlugin wherever the
52
+ * expression appears, so this is exactly as static in a production bundle as
53
+ * the module-level constant above. Reading it inside the function is what
54
+ * lets a test drive both directions — with a key and without — instead of
55
+ * asserting the guard exists and never running it.
56
+ */ export function appCheckSiteKey() {
57
+ var _process_env_NEXT_PUBLIC_RECAPTCHA_PUBLIC_KEY;
58
+ const key = String((_process_env_NEXT_PUBLIC_RECAPTCHA_PUBLIC_KEY = process.env.NEXT_PUBLIC_RECAPTCHA_PUBLIC_KEY) != null ? _process_env_NEXT_PUBLIC_RECAPTCHA_PUBLIC_KEY : '').trim();
59
+ // The literal string 'undefined' is included on purpose: an env var
60
+ // interpolated from an unset shell variable arrives that way, and it is the
61
+ // exact value the SDK would otherwise put in `?render=`.
62
+ return !key || key === 'undefined' ? null : key;
63
+ }
64
+ /** The one message both call sites log, so a search finds either. */ export const APP_CHECK_KEY_MISSING_MESSAGE = '[app-check] NEXT_PUBLIC_RECAPTCHA_PUBLIC_KEY is not set — App Check is ' + 'DISABLED for this app. Firebase client calls will be unattested, and ' + 'will be refused wherever App Check enforcement is on.';
65
+ /**
66
+ * On deployed workspace hosts the OAuth handshake is funnelled through one
67
+ * dedicated same-site auth origin — `auth.<workspaceDomain>` (e.g.
68
+ * auth.aglyn.com), which reverse-proxies the Firebase auth helpers under
69
+ * /__/* (console next.config rewrite, AGL-462). This keeps the handshake
70
+ * same-site (all *.aglyn.com share the aglyn.com eTLD+1, so browser storage
71
+ * partitioning — which severed the cross-origin *.firebaseapp.com
72
+ * authDomain and broke mobile Google sign-in — never applies), while
73
+ * every host, including dynamically-provisioned {org}.aglyn.com
74
+ * workspaces, presents the SAME redirect URI. Google OAuth forbids
75
+ * wildcard redirect URIs, so a per-host authDomain would need a new
76
+ * registration per org; the single auth host needs exactly one.
77
+ *
78
+ * **The auth origin is a property of the DEPLOYMENT, not of the page you
79
+ * happen to be on** (AGL-1919). This used to gate on
80
+ * `window.location.hostname` being on the workspace domain, which meant
81
+ * localhost and every preview deployment silently fell back to
82
+ * `aglyn-main.firebaseapp.com` — and so Google's account chooser said
83
+ * "continue to aglyn-main.firebaseapp.com" for the entire local
84
+ * development loop. Google renders the redirect_uri's host, and the
85
+ * redirect_uri is `https://<authDomain>/__/auth/handler`. Preview was the
86
+ * sharper version of the same bug: it *has* NEXT_PUBLIC_FIREBASE_AUTH_
87
+ * HANDLER_HOST set and could not use it, because a `*.vercel.app`
88
+ * hostname fails the `endsWith` test.
89
+ *
90
+ * Widening it is safe precisely because nothing about the branded host is
91
+ * new: `auth.aglyn.com` already serves `/__/auth/*`, is already a Firebase
92
+ * authorized domain, and `https://auth.aglyn.com/__/auth/handler` is
93
+ * already a registered redirect URI on the production OAuth client
94
+ * (AGL-1486 probed all three). This only widens which page hosts use a
95
+ * handler that already works.
96
+ *
97
+ * The precedence deliberately MIRRORS `ssoServiceMetadata()` in
98
+ * `sso-provisioning.ts`, which documents it as load-bearing — the SAML ACS
99
+ * URL and the OAuth redirect URI have to name the same origin or the two
100
+ * halves of a flow land on different ones:
101
+ *
102
+ * 1. NEXT_PUBLIC_FIREBASE_AUTH_HANDLER_HOST — an explicit override wins.
103
+ * 2. `auth.<NEXT_PUBLIC_WORKSPACE_DOMAIN>` — derived only when the
104
+ * variable is actually SET, never defaulted to `aglyn.com`: a
105
+ * self-hosted install with neither variable would otherwise be
106
+ * pointed at OUR auth origin.
107
+ * 3. NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN — the project's own
108
+ * *.firebaseapp.com, for self-host installs that never stood up an
109
+ * auth subdomain.
110
+ *
111
+ * The emulator keeps the configured domain outright: there is no branded
112
+ * host in front of a local Auth emulator.
113
+ */ function resolveFirebaseAuthDomain() {
114
+ const configured = process.env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN;
115
+ if (process.env['FIREBASE_AUTH_EMULATOR_ENABLED'] === 'true') {
116
+ return configured;
117
+ }
118
+ const workspaceDomain = process.env.NEXT_PUBLIC_WORKSPACE_DOMAIN;
119
+ // `||`, not `??`, and for the same reason `ssoServiceMetadata()` uses it:
120
+ // a variable declared-but-empty in a .env file (`NEXT_PUBLIC_FIREBASE_
121
+ // AUTH_HANDLER_HOST=`) is NOT an override — `??` would accept `''` and
122
+ // hand Firebase `https:///__/auth/handler`.
123
+ const branded = process.env.NEXT_PUBLIC_FIREBASE_AUTH_HANDLER_HOST || (workspaceDomain ? `auth.${workspaceDomain}` : '');
124
+ return branded || configured;
125
+ }
126
+ /**
127
+ * Firebase client-side configuration assembled directly from NEXT_PUBLIC_*
128
+ * environment variables so that Next.js webpack DefinePlugin substitutes
129
+ * them at build time and no intermediate constant indirection can carry a
130
+ * stale undefined value across a cached compilation.
131
+ */ export const fbClientAppOptions = {
132
+ apiKey: process.env.NEXT_PUBLIC_FIREBASE_PUBLIC_API_KEY,
133
+ authDomain: resolveFirebaseAuthDomain(),
134
+ databaseURL: process.env.NEXT_PUBLIC_FIREBASE_DATABASE_URL,
135
+ projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID,
136
+ storageBucket: process.env.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET,
137
+ messagingSenderId: process.env.NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID,
138
+ appId: process.env.NEXT_PUBLIC_FIREBASE_APP_ID,
139
+ measurementId: process.env.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID
140
+ } // export let fbClientApp: FirebaseApp
141
+ //
142
+ // try {
143
+ // fbClientApp = getApp(FIREBASE_CLIENT_APP_NAME)
144
+ // }
145
+ // catch {
146
+ // fbClientApp = initializeApp(fbClientAppOptions, {
147
+ // name: FIREBASE_CLIENT_APP_NAME,
148
+ // automaticDataCollectionEnabled: true,
149
+ // })
150
+ // }
151
+ //
152
+ // export default fbClientApp
153
+ ;
154
+
155
+ //# sourceMappingURL=firebase-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../libs/tenant/feature/instance/src/lib/constants/firebase-config.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\nimport { type FirebaseOptions } from 'firebase/app'\n\nexport const RECAPTCHA_API_KEY = process.env.NEXT_PUBLIC_RECAPTCHA_PUBLIC_KEY\nexport const FIREBASE_CLIENT_APP_NAME = 'DEFAULT_AGLYN'\n\n/**\n * The App Check reCAPTCHA site key, or `null` when it is unset or blank\n * (AGL-2049).\n *\n * ## Why a guard, when `new ReCaptchaV3Provider(undefined)` does not throw\n *\n * That is precisely the problem. It does not throw — it stores the value and\n * returns, `initializeAppCheck` returns normally, and the SDK then requests\n * `https://www.google.com/recaptcha/api.js?render=undefined`. The failure is\n * ASYNCHRONOUS, so the `try/catch` both call sites wrap this in never sees it.\n * What the operator gets is a provider registered against an app it can never\n * mint a token for, plus console errors on every page, and nothing anywhere\n * that says the key is missing.\n *\n * Two configurations reach it:\n *\n * - **Self-host.** `.env.selfhost.example` ships the variable EMPTY, so the\n * documented self-host path lands here by default. AGL-2049 named this and\n * deliberately left it; this is that fix.\n * - **A misconfigured deployment.** On the `aglyn-tenant` Vercel project this\n * variable was misspelled `NEXT_PUBLIC_RECPATCHA_PUBLIC_KEY` for three\n * years and eleven months, so `RECAPTCHA_API_KEY` was `undefined` in every\n * tenant build ever made. Nothing in the repo read the misspelling, so no\n * lint rule, schema or review could have found it — and nothing at runtime\n * said so either, which is the part this changes.\n *\n * Skipping registration is strictly better than registering a broken one: an\n * app with no App Check provider is a known, visible state (calls are\n * unattested and enforcement refuses them with a clear code), whereas an app\n * with a provider that cannot mint tokens looks configured and is not.\n *\n * ## Read at CALL time, not at module load\n *\n * `NEXT_PUBLIC_*` is inlined textually by webpack's DefinePlugin wherever the\n * expression appears, so this is exactly as static in a production bundle as\n * the module-level constant above. Reading it inside the function is what\n * lets a test drive both directions — with a key and without — instead of\n * asserting the guard exists and never running it.\n */\nexport function appCheckSiteKey(): string | null {\n const key = String(\n process.env.NEXT_PUBLIC_RECAPTCHA_PUBLIC_KEY ?? '',\n ).trim()\n // The literal string 'undefined' is included on purpose: an env var\n // interpolated from an unset shell variable arrives that way, and it is the\n // exact value the SDK would otherwise put in `?render=`.\n return !key || key === 'undefined' ? null : key\n}\n\n/** The one message both call sites log, so a search finds either. */\nexport const APP_CHECK_KEY_MISSING_MESSAGE =\n '[app-check] NEXT_PUBLIC_RECAPTCHA_PUBLIC_KEY is not set — App Check is ' +\n 'DISABLED for this app. Firebase client calls will be unattested, and ' +\n 'will be refused wherever App Check enforcement is on.'\n\n/**\n * On deployed workspace hosts the OAuth handshake is funnelled through one\n * dedicated same-site auth origin — `auth.<workspaceDomain>` (e.g.\n * auth.aglyn.com), which reverse-proxies the Firebase auth helpers under\n * /__/* (console next.config rewrite, AGL-462). This keeps the handshake\n * same-site (all *.aglyn.com share the aglyn.com eTLD+1, so browser storage\n * partitioning — which severed the cross-origin *.firebaseapp.com\n * authDomain and broke mobile Google sign-in — never applies), while\n * every host, including dynamically-provisioned {org}.aglyn.com\n * workspaces, presents the SAME redirect URI. Google OAuth forbids\n * wildcard redirect URIs, so a per-host authDomain would need a new\n * registration per org; the single auth host needs exactly one.\n *\n * **The auth origin is a property of the DEPLOYMENT, not of the page you\n * happen to be on** (AGL-1919). This used to gate on\n * `window.location.hostname` being on the workspace domain, which meant\n * localhost and every preview deployment silently fell back to\n * `aglyn-main.firebaseapp.com` — and so Google's account chooser said\n * \"continue to aglyn-main.firebaseapp.com\" for the entire local\n * development loop. Google renders the redirect_uri's host, and the\n * redirect_uri is `https://<authDomain>/__/auth/handler`. Preview was the\n * sharper version of the same bug: it *has* NEXT_PUBLIC_FIREBASE_AUTH_\n * HANDLER_HOST set and could not use it, because a `*.vercel.app`\n * hostname fails the `endsWith` test.\n *\n * Widening it is safe precisely because nothing about the branded host is\n * new: `auth.aglyn.com` already serves `/__/auth/*`, is already a Firebase\n * authorized domain, and `https://auth.aglyn.com/__/auth/handler` is\n * already a registered redirect URI on the production OAuth client\n * (AGL-1486 probed all three). This only widens which page hosts use a\n * handler that already works.\n *\n * The precedence deliberately MIRRORS `ssoServiceMetadata()` in\n * `sso-provisioning.ts`, which documents it as load-bearing — the SAML ACS\n * URL and the OAuth redirect URI have to name the same origin or the two\n * halves of a flow land on different ones:\n *\n * 1. NEXT_PUBLIC_FIREBASE_AUTH_HANDLER_HOST — an explicit override wins.\n * 2. `auth.<NEXT_PUBLIC_WORKSPACE_DOMAIN>` — derived only when the\n * variable is actually SET, never defaulted to `aglyn.com`: a\n * self-hosted install with neither variable would otherwise be\n * pointed at OUR auth origin.\n * 3. NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN — the project's own\n * *.firebaseapp.com, for self-host installs that never stood up an\n * auth subdomain.\n *\n * The emulator keeps the configured domain outright: there is no branded\n * host in front of a local Auth emulator.\n */\nfunction resolveFirebaseAuthDomain(): string | undefined {\n const configured = process.env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN\n if (process.env['FIREBASE_AUTH_EMULATOR_ENABLED'] === 'true') {\n return configured\n }\n const workspaceDomain = process.env.NEXT_PUBLIC_WORKSPACE_DOMAIN\n // `||`, not `??`, and for the same reason `ssoServiceMetadata()` uses it:\n // a variable declared-but-empty in a .env file (`NEXT_PUBLIC_FIREBASE_\n // AUTH_HANDLER_HOST=`) is NOT an override — `??` would accept `''` and\n // hand Firebase `https:///__/auth/handler`.\n const branded =\n process.env.NEXT_PUBLIC_FIREBASE_AUTH_HANDLER_HOST ||\n (workspaceDomain ? `auth.${workspaceDomain}` : '')\n return branded || configured\n}\n\n/**\n * Firebase client-side configuration assembled directly from NEXT_PUBLIC_*\n * environment variables so that Next.js webpack DefinePlugin substitutes\n * them at build time and no intermediate constant indirection can carry a\n * stale undefined value across a cached compilation.\n */\nexport const fbClientAppOptions: FirebaseOptions = {\n apiKey: process.env.NEXT_PUBLIC_FIREBASE_PUBLIC_API_KEY,\n authDomain: resolveFirebaseAuthDomain(),\n databaseURL: process.env.NEXT_PUBLIC_FIREBASE_DATABASE_URL,\n projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID,\n storageBucket: process.env.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET,\n messagingSenderId: process.env.NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID,\n appId: process.env.NEXT_PUBLIC_FIREBASE_APP_ID,\n measurementId: process.env.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID,\n}\n\n// export let fbClientApp: FirebaseApp\n//\n// try {\n// fbClientApp = getApp(FIREBASE_CLIENT_APP_NAME)\n// }\n// catch {\n// fbClientApp = initializeApp(fbClientAppOptions, {\n// name: FIREBASE_CLIENT_APP_NAME,\n// automaticDataCollectionEnabled: true,\n// })\n// }\n//\n// export default fbClientApp\n"],"names":["RECAPTCHA_API_KEY","process","env","NEXT_PUBLIC_RECAPTCHA_PUBLIC_KEY","FIREBASE_CLIENT_APP_NAME","appCheckSiteKey","key","String","trim","APP_CHECK_KEY_MISSING_MESSAGE","resolveFirebaseAuthDomain","configured","NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN","workspaceDomain","NEXT_PUBLIC_WORKSPACE_DOMAIN","branded","NEXT_PUBLIC_FIREBASE_AUTH_HANDLER_HOST","fbClientAppOptions","apiKey","NEXT_PUBLIC_FIREBASE_PUBLIC_API_KEY","authDomain","databaseURL","NEXT_PUBLIC_FIREBASE_DATABASE_URL","projectId","NEXT_PUBLIC_FIREBASE_PROJECT_ID","storageBucket","NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET","messagingSenderId","NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID","appId","NEXT_PUBLIC_FIREBASE_APP_ID","measurementId","NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAID,OAAO,MAAMA,oBAAoBC,QAAQC,GAAG,CAACC,gCAAgC,CAAA;AAC7E,OAAO,MAAMC,2BAA2B,gBAAe;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsCC,GACD,OAAO,SAASC;QAEZJ;IADF,MAAMK,MAAMC,QACVN,gDAAAA,QAAQC,GAAG,CAACC,gCAAgC,YAA5CF,gDAAgD,IAChDO,IAAI;IACN,oEAAoE;IACpE,4EAA4E;IAC5E,yDAAyD;IACzD,OAAO,CAACF,OAAOA,QAAQ,cAAc,OAAOA;AAC9C;AAEA,mEAAmE,GACnE,OAAO,MAAMG,gCACX,4EACA,0EACA,wDAAuD;AAEzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgDC,GACD,SAASC;IACP,MAAMC,aAAaV,QAAQC,GAAG,CAACU,gCAAgC;IAC/D,IAAIX,QAAQC,GAAG,CAAC,iCAAiC,KAAK,QAAQ;QAC5D,OAAOS;IACT;IACA,MAAME,kBAAkBZ,QAAQC,GAAG,CAACY,4BAA4B;IAChE,0EAA0E;IAC1E,uEAAuE;IACvE,uEAAuE;IACvE,4CAA4C;IAC5C,MAAMC,UACJd,QAAQC,GAAG,CAACc,sCAAsC,IACjDH,CAAAA,kBAAkB,CAAC,KAAK,EAAEA,iBAAiB,GAAG,EAAC;IAClD,OAAOE,WAAWJ;AACpB;AAEA;;;;;CAKC,GACD,OAAO,MAAMM,qBAAsC;IACjDC,QAAQjB,QAAQC,GAAG,CAACiB,mCAAmC;IACvDC,YAAYV;IACZW,aAAapB,QAAQC,GAAG,CAACoB,iCAAiC;IAC1DC,WAAWtB,QAAQC,GAAG,CAACsB,+BAA+B;IACtDC,eAAexB,QAAQC,GAAG,CAACwB,mCAAmC;IAC9DC,mBAAmB1B,QAAQC,GAAG,CAAC0B,wCAAwC;IACvEC,OAAO5B,QAAQC,GAAG,CAAC4B,2BAA2B;IAC9CC,eAAe9B,QAAQC,GAAG,CAAC8B,mCAAmC;AAChE,EAEA,sCAAsC;CACtC,EAAE;CACF,QAAQ;CACR,mDAAmD;CACnD,IAAI;CACJ,UAAU;CACV,sDAAsD;CACtD,sCAAsC;CACtC,4CAA4C;CAC5C,OAAO;CACP,IAAI;CACJ,EAAE;CACF,6BAA6B;CAd5B"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /**
18
+ * Where the browser's Firebase clients find the emulators (AGL-2834).
19
+ *
20
+ * A dev server and the Node half of every e2e suite find them through
21
+ * `FIRESTORE_EMULATOR_HOST`, `FIREBASE_AUTH_EMULATOR_HOST` and
22
+ * `FIREBASE_DATABASE_EMULATOR_HOST`. A page in the browser cannot read those:
23
+ * Next inlines `NEXT_PUBLIC_*` into client bundles and nothing else. So the
24
+ * `serve:*:emulated` scripts mirror each host into a `NEXT_PUBLIC_` twin, and
25
+ * the page connects where its server does.
26
+ *
27
+ * Without the twins, the page carried the default ports as literals, and an
28
+ * emulator stack on any other ports split in two: the server and the suite
29
+ * talked to that stack while the page in Chrome read and wrote whichever
30
+ * emulators held 8082 and 9099 — another session's, when one was running.
31
+ *
32
+ * Called only inside the emulator branches, which the
33
+ * `FIREBASE_*_EMULATOR_ENABLED` flags gate, so a build without those flags
34
+ * never reads a host. Every default is the port `cloud/firebase.json` and
35
+ * `cloud/firebase.e2e.json` pin, and the one the page used before.
36
+ *
37
+ * No Storage twin: no browser code talks to the Storage emulator. Uploads and
38
+ * media reads go through the servers, which already follow
39
+ * `FIREBASE_STORAGE_EMULATOR_HOST`.
40
+ */
41
+ /** One emulator's address, as the SDK's `connect*Emulator` calls take it. */
42
+ export interface EmulatorHost {
43
+ host: string;
44
+ port: number;
45
+ }
46
+ export declare const DEFAULT_FIRESTORE_EMULATOR: EmulatorHost;
47
+ export declare const DEFAULT_AUTH_EMULATOR: EmulatorHost;
48
+ export declare const DEFAULT_DATABASE_EMULATOR: EmulatorHost;
49
+ /**
50
+ * `host:port`, as the emulator variables spell it, or `fallback` for anything
51
+ * else: an unset variable, a bare host, a port that is not a TCP port, or an
52
+ * IPv6 address without the brackets that tell its colons from the port's.
53
+ */
54
+ export declare function parseEmulatorHost(value: string | null | undefined, fallback: EmulatorHost): EmulatorHost;
55
+ /** The Firestore emulator the page connects to. */
56
+ export declare function firestoreEmulatorHost(): EmulatorHost;
57
+ /** The Auth emulator's origin, the form `connectAuthEmulator` takes. */
58
+ export declare function authEmulatorUrl(): string;
59
+ /** The Realtime Database emulator the page's presence session connects to. */
60
+ export declare function databaseEmulatorHost(): EmulatorHost;
@@ -0,0 +1,81 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ /**
17
+ * Where the browser's Firebase clients find the emulators (AGL-2834).
18
+ *
19
+ * A dev server and the Node half of every e2e suite find them through
20
+ * `FIRESTORE_EMULATOR_HOST`, `FIREBASE_AUTH_EMULATOR_HOST` and
21
+ * `FIREBASE_DATABASE_EMULATOR_HOST`. A page in the browser cannot read those:
22
+ * Next inlines `NEXT_PUBLIC_*` into client bundles and nothing else. So the
23
+ * `serve:*:emulated` scripts mirror each host into a `NEXT_PUBLIC_` twin, and
24
+ * the page connects where its server does.
25
+ *
26
+ * Without the twins, the page carried the default ports as literals, and an
27
+ * emulator stack on any other ports split in two: the server and the suite
28
+ * talked to that stack while the page in Chrome read and wrote whichever
29
+ * emulators held 8082 and 9099 — another session's, when one was running.
30
+ *
31
+ * Called only inside the emulator branches, which the
32
+ * `FIREBASE_*_EMULATOR_ENABLED` flags gate, so a build without those flags
33
+ * never reads a host. Every default is the port `cloud/firebase.json` and
34
+ * `cloud/firebase.e2e.json` pin, and the one the page used before.
35
+ *
36
+ * No Storage twin: no browser code talks to the Storage emulator. Uploads and
37
+ * media reads go through the servers, which already follow
38
+ * `FIREBASE_STORAGE_EMULATOR_HOST`.
39
+ */ /** One emulator's address, as the SDK's `connect*Emulator` calls take it. */ export const DEFAULT_FIRESTORE_EMULATOR = {
40
+ host: 'localhost',
41
+ port: 8082
42
+ };
43
+ export const DEFAULT_AUTH_EMULATOR = {
44
+ host: 'localhost',
45
+ port: 9099
46
+ };
47
+ export const DEFAULT_DATABASE_EMULATOR = {
48
+ host: 'localhost',
49
+ port: 9000
50
+ };
51
+ /**
52
+ * `host:port`, as the emulator variables spell it, or `fallback` for anything
53
+ * else: an unset variable, a bare host, a port that is not a TCP port, or an
54
+ * IPv6 address without the brackets that tell its colons from the port's.
55
+ */ export function parseEmulatorHost(value, fallback) {
56
+ const text = String(value != null ? value : '').trim();
57
+ const colon = text.lastIndexOf(':');
58
+ if (colon <= 0) return fallback;
59
+ const host = text.slice(0, colon);
60
+ const portText = text.slice(colon + 1);
61
+ if (!/^\d{1,5}$/.test(portText)) return fallback;
62
+ const port = Number(portText);
63
+ if (port < 1 || port > 65535) return fallback;
64
+ if (host.includes(':') && !/^\[[^\]]+\]$/.test(host)) return fallback;
65
+ return {
66
+ host,
67
+ port
68
+ };
69
+ }
70
+ /** The Firestore emulator the page connects to. */ export function firestoreEmulatorHost() {
71
+ return parseEmulatorHost(process.env.NEXT_PUBLIC_FIRESTORE_EMULATOR_HOST, DEFAULT_FIRESTORE_EMULATOR);
72
+ }
73
+ /** The Auth emulator's origin, the form `connectAuthEmulator` takes. */ export function authEmulatorUrl() {
74
+ const { host, port } = parseEmulatorHost(process.env.NEXT_PUBLIC_FIREBASE_AUTH_EMULATOR_HOST, DEFAULT_AUTH_EMULATOR);
75
+ return `http://${host}:${port}`;
76
+ }
77
+ /** The Realtime Database emulator the page's presence session connects to. */ export function databaseEmulatorHost() {
78
+ return parseEmulatorHost(process.env.NEXT_PUBLIC_FIREBASE_DATABASE_EMULATOR_HOST, DEFAULT_DATABASE_EMULATOR);
79
+ }
80
+
81
+ //# sourceMappingURL=firebase-emulator-hosts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../libs/tenant/feature/instance/src/lib/constants/firebase-emulator-hosts.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 * Where the browser's Firebase clients find the emulators (AGL-2834).\n *\n * A dev server and the Node half of every e2e suite find them through\n * `FIRESTORE_EMULATOR_HOST`, `FIREBASE_AUTH_EMULATOR_HOST` and\n * `FIREBASE_DATABASE_EMULATOR_HOST`. A page in the browser cannot read those:\n * Next inlines `NEXT_PUBLIC_*` into client bundles and nothing else. So the\n * `serve:*:emulated` scripts mirror each host into a `NEXT_PUBLIC_` twin, and\n * the page connects where its server does.\n *\n * Without the twins, the page carried the default ports as literals, and an\n * emulator stack on any other ports split in two: the server and the suite\n * talked to that stack while the page in Chrome read and wrote whichever\n * emulators held 8082 and 9099 — another session's, when one was running.\n *\n * Called only inside the emulator branches, which the\n * `FIREBASE_*_EMULATOR_ENABLED` flags gate, so a build without those flags\n * never reads a host. Every default is the port `cloud/firebase.json` and\n * `cloud/firebase.e2e.json` pin, and the one the page used before.\n *\n * No Storage twin: no browser code talks to the Storage emulator. Uploads and\n * media reads go through the servers, which already follow\n * `FIREBASE_STORAGE_EMULATOR_HOST`.\n */\n\n/** One emulator's address, as the SDK's `connect*Emulator` calls take it. */\nexport interface EmulatorHost {\n host: string\n port: number\n}\n\nexport const DEFAULT_FIRESTORE_EMULATOR: EmulatorHost = {\n host: 'localhost',\n port: 8082,\n}\n\nexport const DEFAULT_AUTH_EMULATOR: EmulatorHost = {\n host: 'localhost',\n port: 9099,\n}\n\nexport const DEFAULT_DATABASE_EMULATOR: EmulatorHost = {\n host: 'localhost',\n port: 9000,\n}\n\n/**\n * `host:port`, as the emulator variables spell it, or `fallback` for anything\n * else: an unset variable, a bare host, a port that is not a TCP port, or an\n * IPv6 address without the brackets that tell its colons from the port's.\n */\nexport function parseEmulatorHost(\n value: string | null | undefined,\n fallback: EmulatorHost,\n): EmulatorHost {\n const text = String(value ?? '').trim()\n const colon = text.lastIndexOf(':')\n if (colon <= 0) return fallback\n const host = text.slice(0, colon)\n const portText = text.slice(colon + 1)\n if (!/^\\d{1,5}$/.test(portText)) return fallback\n const port = Number(portText)\n if (port < 1 || port > 65535) return fallback\n if (host.includes(':') && !/^\\[[^\\]]+\\]$/.test(host)) return fallback\n return { host, port }\n}\n\n/** The Firestore emulator the page connects to. */\nexport function firestoreEmulatorHost(): EmulatorHost {\n return parseEmulatorHost(\n process.env.NEXT_PUBLIC_FIRESTORE_EMULATOR_HOST,\n DEFAULT_FIRESTORE_EMULATOR,\n )\n}\n\n/** The Auth emulator's origin, the form `connectAuthEmulator` takes. */\nexport function authEmulatorUrl(): string {\n const { host, port } = parseEmulatorHost(\n process.env.NEXT_PUBLIC_FIREBASE_AUTH_EMULATOR_HOST,\n DEFAULT_AUTH_EMULATOR,\n )\n return `http://${host}:${port}`\n}\n\n/** The Realtime Database emulator the page's presence session connects to. */\nexport function databaseEmulatorHost(): EmulatorHost {\n return parseEmulatorHost(\n process.env.NEXT_PUBLIC_FIREBASE_DATABASE_EMULATOR_HOST,\n DEFAULT_DATABASE_EMULATOR,\n )\n}\n"],"names":["DEFAULT_FIRESTORE_EMULATOR","host","port","DEFAULT_AUTH_EMULATOR","DEFAULT_DATABASE_EMULATOR","parseEmulatorHost","value","fallback","text","String","trim","colon","lastIndexOf","slice","portText","test","Number","includes","firestoreEmulatorHost","process","env","NEXT_PUBLIC_FIRESTORE_EMULATOR_HOST","authEmulatorUrl","NEXT_PUBLIC_FIREBASE_AUTH_EMULATOR_HOST","databaseEmulatorHost","NEXT_PUBLIC_FIREBASE_DATABASE_EMULATOR_HOST"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;CAuBC,GAED,2EAA2E,GAM3E,OAAO,MAAMA,6BAA2C;IACtDC,MAAM;IACNC,MAAM;AACR,EAAC;AAED,OAAO,MAAMC,wBAAsC;IACjDF,MAAM;IACNC,MAAM;AACR,EAAC;AAED,OAAO,MAAME,4BAA0C;IACrDH,MAAM;IACNC,MAAM;AACR,EAAC;AAED;;;;CAIC,GACD,OAAO,SAASG,kBACdC,KAAgC,EAChCC,QAAsB;IAEtB,MAAMC,OAAOC,OAAOH,gBAAAA,QAAS,IAAII,IAAI;IACrC,MAAMC,QAAQH,KAAKI,WAAW,CAAC;IAC/B,IAAID,SAAS,GAAG,OAAOJ;IACvB,MAAMN,OAAOO,KAAKK,KAAK,CAAC,GAAGF;IAC3B,MAAMG,WAAWN,KAAKK,KAAK,CAACF,QAAQ;IACpC,IAAI,CAAC,YAAYI,IAAI,CAACD,WAAW,OAAOP;IACxC,MAAML,OAAOc,OAAOF;IACpB,IAAIZ,OAAO,KAAKA,OAAO,OAAO,OAAOK;IACrC,IAAIN,KAAKgB,QAAQ,CAAC,QAAQ,CAAC,eAAeF,IAAI,CAACd,OAAO,OAAOM;IAC7D,OAAO;QAAEN;QAAMC;IAAK;AACtB;AAEA,iDAAiD,GACjD,OAAO,SAASgB;IACd,OAAOb,kBACLc,QAAQC,GAAG,CAACC,mCAAmC,EAC/CrB;AAEJ;AAEA,sEAAsE,GACtE,OAAO,SAASsB;IACd,MAAM,EAAErB,IAAI,EAAEC,IAAI,EAAE,GAAGG,kBACrBc,QAAQC,GAAG,CAACG,uCAAuC,EACnDpB;IAEF,OAAO,CAAC,OAAO,EAAEF,KAAK,CAAC,EAAEC,MAAM;AACjC;AAEA,4EAA4E,GAC5E,OAAO,SAASsB;IACd,OAAOnB,kBACLc,QAAQC,GAAG,CAACK,2CAA2C,EACvDrB;AAEJ"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ export type TenantSite = {
18
+ name: string;
19
+ description: string;
20
+ subdomain: string;
21
+ cname?: string;
22
+ paths: string[];
23
+ };
24
+ export declare const mockDB: TenantSite[];
@@ -0,0 +1,49 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ export const mockDB = [
17
+ {
18
+ name: 'Site 1',
19
+ description: 'Subdomain + custom domain',
20
+ subdomain: 'myhost-1',
21
+ cname: 'custom-domain-1.com',
22
+ paths: [
23
+ '/index',
24
+ '/aa'
25
+ ]
26
+ },
27
+ {
28
+ name: 'Site 2',
29
+ description: 'Subdomain only',
30
+ subdomain: 'myhost-2',
31
+ cname: null,
32
+ paths: [
33
+ '/index',
34
+ '/aa'
35
+ ]
36
+ },
37
+ {
38
+ name: 'Site 3',
39
+ description: 'Subdomain only',
40
+ subdomain: 'myhost-3',
41
+ cname: null,
42
+ paths: [
43
+ '/index',
44
+ '/aa'
45
+ ]
46
+ }
47
+ ];
48
+
49
+ //# sourceMappingURL=mock-data.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../libs/tenant/feature/instance/src/lib/constants/mock-data.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 type TenantSite = {\n name: string\n description: string\n subdomain: string\n cname?: string\n paths: string[]\n}\nexport const mockDB: TenantSite[] = [\n {\n name: 'Site 1',\n description: 'Subdomain + custom domain',\n subdomain: 'myhost-1',\n cname: 'custom-domain-1.com',\n paths: ['/index', '/aa'],\n },\n {\n name: 'Site 2',\n description: 'Subdomain only',\n subdomain: 'myhost-2',\n cname: null,\n paths: ['/index', '/aa'],\n },\n {\n name: 'Site 3',\n description: 'Subdomain only',\n subdomain: 'myhost-3',\n cname: null,\n paths: ['/index', '/aa'],\n },\n]\n"],"names":["mockDB","name","description","subdomain","cname","paths"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GASD,OAAO,MAAMA,SAAuB;IAClC;QACEC,MAAM;QACNC,aAAa;QACbC,WAAW;QACXC,OAAO;QACPC,OAAO;YAAC;YAAU;SAAM;IAC1B;IACA;QACEJ,MAAM;QACNC,aAAa;QACbC,WAAW;QACXC,OAAO;QACPC,OAAO;YAAC;YAAU;SAAM;IAC1B;IACA;QACEJ,MAAM;QACNC,aAAa;QACbC,WAAW;QACXC,OAAO;QACPC,OAAO;YAAC;YAAU;SAAM;IAC1B;CACD,CAAA"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ export declare const API_DIR = "/api";
18
+ export declare const STATIC_DIR = "/_static";
19
+ export declare const NEXT_DIR = "/_next";
20
+ export declare const NEXT_IMAGE_DIR = "/_next/image";
21
+ export declare const STATIC_IMAGE_DIR = "/_static/image";
22
+ export declare const STATIC_PWA_DIR = "/_static/_pwa";
23
+ export declare const STATIC_PWA_ICON_DIR = "/_static/_pwa/icons";
24
+ export declare const STATIC_FAVICON_PATH = "/_static/favicon.ico";
25
+ export declare const STATIC_ROBOTS_PATH = "/_static/robots.txt";
26
+ export declare const STATIC_PWA_MANIFEST_PATH = "/_static/_pwa/manifest.json";
27
+ export declare const IMPLICIT_DIRS: string[];
28
+ export declare const STATIC_PATHS: string[];
29
+ export declare const NEXT_PATHS: string[];
30
+ export declare const IMPLICIT_PATHS: string[];
31
+ declare const _default: {
32
+ IMPLICIT_DIRS: string[];
33
+ API_DIR: string;
34
+ STATIC_DIR: string;
35
+ STATIC_IMAGE_DIR: string;
36
+ STATIC_PWA_DIR: string;
37
+ STATIC_PWA_ICON_DIR: string;
38
+ NEXT_DIR: string;
39
+ NEXT_IMAGE_DIR: string;
40
+ STATIC_PATHS: string[];
41
+ NEXT_PATHS: string[];
42
+ IMPLICIT_PATHS: string[];
43
+ STATIC_FAVICON_PATH: string;
44
+ STATIC_ROBOTS_PATH: string;
45
+ STATIC_PWA_MANIFEST_PATH: string;
46
+ };
47
+ export default _default;
@@ -0,0 +1,66 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022 Aglyn LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */ export const API_DIR = `/api`;
17
+ export const STATIC_DIR = '/_static';
18
+ export const NEXT_DIR = '/_next';
19
+ export const NEXT_IMAGE_DIR = `/_next/image`;
20
+ export const STATIC_IMAGE_DIR = `${STATIC_DIR}/image`;
21
+ export const STATIC_PWA_DIR = `${STATIC_DIR}/_pwa`;
22
+ export const STATIC_PWA_ICON_DIR = `${STATIC_PWA_DIR}/icons`;
23
+ export const STATIC_FAVICON_PATH = `${STATIC_DIR}/favicon.ico`;
24
+ export const STATIC_ROBOTS_PATH = `${STATIC_DIR}/robots.txt`;
25
+ export const STATIC_PWA_MANIFEST_PATH = `${STATIC_PWA_DIR}/manifest.json`;
26
+ export const IMPLICIT_DIRS = [
27
+ STATIC_DIR,
28
+ API_DIR,
29
+ NEXT_DIR
30
+ ];
31
+ export const STATIC_PATHS = [
32
+ STATIC_DIR,
33
+ STATIC_IMAGE_DIR,
34
+ STATIC_PWA_DIR,
35
+ STATIC_PWA_ICON_DIR,
36
+ STATIC_FAVICON_PATH,
37
+ STATIC_ROBOTS_PATH,
38
+ STATIC_PWA_MANIFEST_PATH
39
+ ];
40
+ export const NEXT_PATHS = [
41
+ NEXT_IMAGE_DIR,
42
+ NEXT_DIR
43
+ ];
44
+ export const IMPLICIT_PATHS = [
45
+ API_DIR,
46
+ ...STATIC_PATHS,
47
+ ...NEXT_PATHS
48
+ ];
49
+ export default {
50
+ IMPLICIT_DIRS,
51
+ API_DIR,
52
+ STATIC_DIR,
53
+ STATIC_IMAGE_DIR,
54
+ STATIC_PWA_DIR,
55
+ STATIC_PWA_ICON_DIR,
56
+ NEXT_DIR,
57
+ NEXT_IMAGE_DIR,
58
+ STATIC_PATHS,
59
+ NEXT_PATHS,
60
+ IMPLICIT_PATHS,
61
+ STATIC_FAVICON_PATH,
62
+ STATIC_ROBOTS_PATH,
63
+ STATIC_PWA_MANIFEST_PATH
64
+ };
65
+
66
+ //# sourceMappingURL=site-paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../../../../libs/tenant/feature/instance/src/lib/constants/site-paths.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 const API_DIR = `/api`\nexport const STATIC_DIR = '/_static'\nexport const NEXT_DIR = '/_next'\nexport const NEXT_IMAGE_DIR = `/_next/image`\nexport const STATIC_IMAGE_DIR = `${STATIC_DIR}/image`\nexport const STATIC_PWA_DIR = `${STATIC_DIR}/_pwa`\nexport const STATIC_PWA_ICON_DIR = `${STATIC_PWA_DIR}/icons`\n\nexport const STATIC_FAVICON_PATH = `${STATIC_DIR}/favicon.ico`\nexport const STATIC_ROBOTS_PATH = `${STATIC_DIR}/robots.txt`\nexport const STATIC_PWA_MANIFEST_PATH = `${STATIC_PWA_DIR}/manifest.json`\n\nexport const IMPLICIT_DIRS = [STATIC_DIR, API_DIR, NEXT_DIR]\n\nexport const STATIC_PATHS = [\n STATIC_DIR,\n STATIC_IMAGE_DIR,\n STATIC_PWA_DIR,\n STATIC_PWA_ICON_DIR,\n STATIC_FAVICON_PATH,\n STATIC_ROBOTS_PATH,\n STATIC_PWA_MANIFEST_PATH,\n]\n\nexport const NEXT_PATHS = [NEXT_IMAGE_DIR, NEXT_DIR]\n\nexport const IMPLICIT_PATHS = [API_DIR, ...STATIC_PATHS, ...NEXT_PATHS]\n\nexport default {\n IMPLICIT_DIRS,\n API_DIR,\n STATIC_DIR,\n STATIC_IMAGE_DIR,\n STATIC_PWA_DIR,\n STATIC_PWA_ICON_DIR,\n NEXT_DIR,\n NEXT_IMAGE_DIR,\n STATIC_PATHS,\n NEXT_PATHS,\n IMPLICIT_PATHS,\n STATIC_FAVICON_PATH,\n STATIC_ROBOTS_PATH,\n STATIC_PWA_MANIFEST_PATH,\n}\n"],"names":["API_DIR","STATIC_DIR","NEXT_DIR","NEXT_IMAGE_DIR","STATIC_IMAGE_DIR","STATIC_PWA_DIR","STATIC_PWA_ICON_DIR","STATIC_FAVICON_PATH","STATIC_ROBOTS_PATH","STATIC_PWA_MANIFEST_PATH","IMPLICIT_DIRS","STATIC_PATHS","NEXT_PATHS","IMPLICIT_PATHS"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,OAAO,MAAMA,UAAU,CAAC,IAAI,CAAC,CAAA;AAC7B,OAAO,MAAMC,aAAa,WAAU;AACpC,OAAO,MAAMC,WAAW,SAAQ;AAChC,OAAO,MAAMC,iBAAiB,CAAC,YAAY,CAAC,CAAA;AAC5C,OAAO,MAAMC,mBAAmB,GAAGH,WAAW,MAAM,CAAC,CAAA;AACrD,OAAO,MAAMI,iBAAiB,GAAGJ,WAAW,KAAK,CAAC,CAAA;AAClD,OAAO,MAAMK,sBAAsB,GAAGD,eAAe,MAAM,CAAC,CAAA;AAE5D,OAAO,MAAME,sBAAsB,GAAGN,WAAW,YAAY,CAAC,CAAA;AAC9D,OAAO,MAAMO,qBAAqB,GAAGP,WAAW,WAAW,CAAC,CAAA;AAC5D,OAAO,MAAMQ,2BAA2B,GAAGJ,eAAe,cAAc,CAAC,CAAA;AAEzE,OAAO,MAAMK,gBAAgB;IAACT;IAAYD;IAASE;CAAS,CAAA;AAE5D,OAAO,MAAMS,eAAe;IAC1BV;IACAG;IACAC;IACAC;IACAC;IACAC;IACAC;CACD,CAAA;AAED,OAAO,MAAMG,aAAa;IAACT;IAAgBD;CAAS,CAAA;AAEpD,OAAO,MAAMW,iBAAiB;IAACb;OAAYW;OAAiBC;CAAW,CAAA;AAEvE,eAAe;IACbF;IACAV;IACAC;IACAG;IACAC;IACAC;IACAJ;IACAC;IACAQ;IACAC;IACAC;IACAN;IACAC;IACAC;AACF,EAAC"}