fireemu 0.16.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +152 -21
  2. package/package.json +6 -6
package/README.md CHANGED
@@ -14,7 +14,7 @@ Fireemu is being developed to close these gaps. For example, it provides:
14
14
 
15
15
  Fireemu is still in development and does not yet reproduce every feature and behavior of production Firebase. Before relying on Fireemu’s test results in CI or other automated workflows, we recommend differential testing against production Firebase services for the features and critical workflows your application uses. Run the same tests against Fireemu and a dedicated Firebase test project, and check for differences in results and behavior that could affect your application. Use a dedicated test project, not your live production project.
16
16
 
17
- See the [capability manifest](https://github.com/t-k/fireemu/blob/v0.16.0/crates/fireemu/src/capabilities.json) and [compatibility documentation](https://github.com/t-k/fireemu/blob/v0.16.0/docs/compatibility-contract.md) for supported features, known differences, and the status of compatibility verification.
17
+ See the [capability manifest](https://github.com/t-k/fireemu/blob/v0.18.0/crates/fireemu/src/capabilities.json) and [compatibility documentation](https://github.com/t-k/fireemu/blob/v0.18.0/docs/compatibility-contract.md) for supported features, known differences, and the status of compatibility verification.
18
18
 
19
19
  ## Quick start
20
20
 
@@ -41,6 +41,10 @@ npx fireemu exec -- <command>
41
41
  npx fireemu exec -- npm test
42
42
  ```
43
43
 
44
+ `up` and `exec` read `fireemu.json` from the current directory, or, when there is none, the nearest `firebase.json` (see [Which configuration files are loaded](#which-configuration-files-are-loaded)). The first lines of the startup output name the files that were loaded and say, for Firestore and Storage, whether Security Rules are loaded.
45
+
46
+ Every command documents its options: run `npx fireemu --help` for the commands and `npx fireemu <command> --help` (or `npx fireemu help <command>`) for the options of one, for example `npx fireemu exec --help`. After `--`, `exec` passes `--help` to your command.
47
+
44
48
  ### Supported platforms
45
49
 
46
50
  | OS | Architecture |
@@ -66,13 +70,13 @@ Fireemu supports Cloud Firestore, Firebase Authentication (Identity Platform), C
66
70
  | Cloud Pub/Sub | Schemas, BigQuery and Cloud Storage subscription delivery, and some APIs such as `UpdateTopic` are not supported. |
67
71
  | Firebase App Check | Local testing with debug tokens is supported. Real attestation through Play Integrity, App Attest, DeviceCheck, or reCAPTCHA, and replay protection using limited-use tokens, are not supported. |
68
72
 
69
- This table highlights key limitations; it is not exhaustive. Check individual API support and conditions with the following command or the [capability manifest](https://github.com/t-k/fireemu/blob/v0.16.0/crates/fireemu/src/capabilities.json).
73
+ This table highlights key limitations; it is not exhaustive. Check individual API support and conditions with the following command or the [capability manifest](https://github.com/t-k/fireemu/blob/v0.18.0/crates/fireemu/src/capabilities.json).
70
74
 
71
75
  ```sh
72
76
  npx fireemu capabilities
73
77
  ```
74
78
 
75
- See the [Functions support inventory](https://github.com/t-k/fireemu/blob/v0.16.0/docs/functions-export-inventory.md) for support by trigger type.
79
+ See the [Functions support inventory](https://github.com/t-k/fireemu/blob/v0.18.0/docs/functions-export-inventory.md) for support by trigger type.
76
80
 
77
81
  ### Unsupported products
78
82
 
@@ -131,7 +135,7 @@ Use `--ui-port 0` to disable the UI. When automatic UI startup cannot bind the d
131
135
 
132
136
  When a Functions codebase is loaded, the Functions page shows registered functions, triggers, invocation results, and logs. You can run scheduled functions immediately or advance the virtual clock to their next scheduled execution.
133
137
 
134
- For clock-sensitive and parallel integration tests, [test clocks and independent worlds](https://github.com/t-k/fireemu/blob/v0.16.0/docs/test-worlds.md) describes explicit Node Date/timer/Cloud Tasks policies and the `fireemu/testing` helper. Separate worlds isolate their clocks, Rules, Functions and service state, including when they use the same project ID.
138
+ For clock-sensitive and parallel integration tests, [test clocks and independent worlds](https://github.com/t-k/fireemu/blob/v0.18.0/docs/test-worlds.md) describes explicit Node Date/timer/Cloud Tasks policies and the `fireemu/testing` helper. Separate worlds isolate their clocks, Rules, Functions and service state, including when they use the same project ID.
135
139
 
136
140
  ### Export data
137
141
 
@@ -147,6 +151,18 @@ On Unix-like systems, the destination and its ancestor directories are subject t
147
151
 
148
152
  On macOS, an ancestor directory with an ACL is refused when the ACL has an `allow` entry for anyone but the owner, root or the user running the export, whatever permissions the entry shows (the kernel grants rights that `ls -le` does not list). `deny` entries are accepted, so a standard home directory (which carries `group:everyone deny delete`) and the folders below it work. When an export is refused for an ACL, the message names the entry; remove it (`chmod -a`) or export to another directory, for example one under `$TMPDIR`. Check an ancestor with `/bin/ls -led <directory>`. A destination on a volume that ignores ownership (exFAT and FAT sticks and cards, or an external APFS volume with "Ignore ownership on this volume" turned on) is refused, because the owner and the mode of its directories do not show who can change them; export to a volume that enforces ownership. A volume without atomic directory rename (exFAT, FAT, some network filesystems) cannot publish an export either: use a directory on an APFS volume.
149
153
 
154
+ ### Keep data between runs
155
+
156
+ `--import <dir>` loads an export at startup, and `--export-on-exit` (without a directory of its own) writes the state back to the same directory when the run ends:
157
+
158
+ ```sh
159
+ npx fireemu exec --import ./emulator-data --export-on-exit -- npm test
160
+ ```
161
+
162
+ - An empty `--import` directory starts with no data, so the first run of a new volume needs no separate command. A missing directory is refused (a mistyped path must not start an empty suite), unless it is also where `--export-on-exit` writes. A directory that holds anything but no `firebase-export-metadata.json` is refused.
163
+ - A failed `--export-on-exit` is printed as an `error:` line, and the run exits 1 when the command succeeded (a failing command keeps its own exit code). The official CLI only warns and exits 0; Fireemu differs so that a CI job that depends on the saved data cannot pass without it.
164
+ - The export directory may be a volume mount point, for example a container volume mounted at `/data`. A mount point cannot be replaced by an atomic rename, so the export is staged inside it and moved into place, the old `firebase-export-metadata.json` leaving first and the new one arriving last. That replacement is not atomic: an interrupted export leaves a directory without the manifest, which `--import` refuses instead of loading part of it. Any other directory is still replaced atomically.
165
+
150
166
  ### Troubleshooting
151
167
 
152
168
  For startup or installation problems, inspect the environment and bundled files with:
@@ -173,17 +189,106 @@ npx fireemu init --yes
173
189
 
174
190
  An existing `fireemu.json` is not overwritten unless `--force` is supplied.
175
191
 
192
+ ### Which configuration files are loaded
193
+
194
+ `up`, `exec`, `emulators:start` and `emulators:exec` choose their configuration files as follows.
195
+
196
+ 1. `--config <file>` and `--firebase-json <file>` load exactly the files they name, and nothing is searched for.
197
+ 2. Otherwise, `fireemu.json` in the current directory is loaded as if it were passed with `--config`. Its `firebaseJson` entry, resolved relative to `fireemu.json`, names the `firebase.json` to load. A `firebase.json` beside a `fireemu.json` without a `firebaseJson` entry is not loaded, and the startup output says so. A `fireemu.json` in a parent directory is not used, because the paths it contains are relative to the current directory.
198
+ 3. Otherwise, the nearest `firebase.json` is loaded as if it were passed with `--firebase-json`: the one in the current directory, else the first one found in a parent directory, as the Firebase CLI finds it. Its paths and the `.firebaserc` beside it are read from its directory.
199
+ 4. Otherwise, the built-in defaults apply, and no Security Rules are loaded.
200
+
201
+ `--no-config-discovery` skips steps 2 and 3. The `config:` line of the startup output names the files that were loaded.
202
+
203
+ A discovered file can name Functions code to run and the rules to enforce, so on Unix the search checks who owns what it finds, as git checks repository ownership. The Firebase CLI does not check this. The trusted owners are you (the effective user), root, and, when you run as root through `sudo`, the user in `SUDO_UID`.
204
+
205
+ - A `fireemu.json` or `firebase.json` whose owner is not trusted, or that any user can write, is skipped. Group write is allowed, so files created under a user-private-group umask (002, the Debian and Ubuntu default) are loaded.
206
+ - A `.firebaserc` names only project and target aliases, never code or rules, so its owner is not checked. It is skipped only when it, or its directory, can be written by any user.
207
+ - The search stops before a parent directory whose owner is not trusted or that any user can write, such as `/tmp`. It also stops, without a warning, at a parent it cannot inspect, such as one you may not enter.
208
+ - The owner of the current directory is not checked, because you chose to run there. A current directory that any user can write is not searched at all.
209
+ - A symbolic link is judged by the file it points to. The directory that holds the target is not checked.
210
+ - Each candidate is opened once. Its owner and mode are checked on the open file before anything is read, and its text is then read from the same file. A discovered file larger than 16 MiB is refused with an error.
211
+
212
+ A skipped file or directory is named in a warning, and the run continues as if nothing had been found. To load a file anyway, name it with `--config` or `--firebase-json`. To silence the warning, pass `--no-config-discovery`. Errors in a discovered file say that the search found the file.
213
+
214
+ Two common setups run into this rule:
215
+
216
+ - A root container with a bind-mounted checkout. Examples are GitHub Actions `container:` jobs and `docker run -v "$PWD":/app` as root. The `fireemu.json` and `firebase.json` there are owned by a host user that the container's root does not trust, so they are skipped. Use the explicit flags, or `chown` the checkout. The `.firebaserc` still names the project. Rootless Podman maps your user to the container's root, so it is not affected.
217
+ - `sudo`. Files owned by the user that `sudo` names in `SUDO_UID` are trusted.
218
+
219
+ On Windows, ownership is not checked.
220
+
221
+ If you relied on the old behavior, where a `firebase.json` next to your tests was ignored, pass `--no-config-discovery`. Discovery means that the project ID comes from the `.firebaserc` beside the discovered `firebase.json`, that its emulator ports, Hub, UI and single-project settings apply, and that a `functions` entry starts the Functions runtime. `fireemu capabilities` also reports the profile of a discovered `fireemu.json`.
222
+
223
+ ### Security Rules that are not loaded
224
+
225
+ Under the `strict` profile, a project without Security Rules behaves as a production project without a rules release: every client request to Firestore is refused with `PERMISSION_DENIED`, and every end-user request to Storage is refused with production's 400 "bucket has not been set up" answer. The Admin SDK and other owner credentials are not affected. The `emulator` profile allows every Firestore request, and every Storage request for a `demo-*` project, as the official emulator does.
226
+
227
+ The answers keep production's wording, which does not mention Fireemu. The startup output therefore has a `firestore rules:` and a `storage rules:` line that say when no rules are loaded and how to load them, and the first refused request for each database and bucket (up to 32 of each) prints a warning to standard error. Name the rules files in `firebase.json` (`firestore.rules`, `storage.rules`) or in `fireemu.json` (`rules.source`, `storage.rules`).
228
+
229
+ ### Why a request was denied
230
+
231
+ A Security Rules denial is answered with production's wording (Firestore's `PERMISSION_DENIED` "Missing or insufficient permissions.", Storage's 403), which does not say which rule refused. Fireemu therefore prints each denial of an end-user request to standard error, with every `allow` condition the request evaluated and what it evaluated to:
232
+
233
+ ```text
234
+ note: firestore: Security Rules denied get on "notes/n1" in "database (default)" (request.auth.uid "bob"): no allow statement evaluated to true; line 5:22 `request.auth.uid == resource.data.owner` was false
235
+ ```
236
+
237
+ - Set `rules.denialLog` to `"off"` in `fireemu.json` to silence these lines (for example in a suite that asserts many denials). The answer to the client is the same either way.
238
+ - When the UI is running, its Rules page lists the decided requests from the start of the run, with what every expression evaluated to. The same trace is served by `GET /v1/sessions/default/rules/requests` on the control API.
239
+
176
240
  ### Compatibility profiles
177
241
 
178
242
  | Profile | Behavior |
179
243
  |---|---|
180
- | `strict` | Matches production Firebase behavior and constraints as closely as possible within the supported scope. This is the default profile |
181
- | `emulator` | Targets the behavior of a pinned version of the official emulator. Known differences are documented in the compatibility documentation |
244
+ | `strict` | Matches production Firebase behavior and constraints as closely as possible within the supported scope. This is the default profile. Recommended, including when migrating from the official emulator |
245
+ | `emulator` | Targets the behavior of a pinned version of the official emulator. Known differences are documented in the compatibility documentation. Use it only to check alignment with the pinned official emulator (for example as an extra test target); it is not needed for a migration |
246
+
247
+ Use `strict` for your tests, also when you are moving a project over from the Firebase Local Emulator Suite. `strict` is recommended; `emulator` is only for checking alignment with the pinned official emulator (for example as an extra test target). It accepts behavior that production refuses, so a test can pass there and fail against production.
182
248
 
183
- Use `strict` when testing against production Firebase behavior. Add `emulator` to your test targets when you also need to check alignment with the official emulator.
249
+ #### Development defaults and `productionExact`
250
+
251
+ Fireemu is mostly run by tests, in CI and on a developer's machine. Where production needs setup that a test should not have to do (signed tokens, signing keys, enabling a feature through an Admin API call), the default in both profiles is the development behavior, and each such behavior has its own configuration key. To get production's behavior for all of them at once, set `productionExact` to `true` (strict profile only); an explicit key still decides over it:
252
+
253
+ ```json
254
+ {
255
+ "schemaVersion": 1,
256
+ "profile": "strict",
257
+ "productionExact": true,
258
+ "auth": { "allowUnsignedCustomTokens": true }
259
+ }
260
+ ```
261
+
262
+ | Development default | Key | With `productionExact` |
263
+ |---|---|---|
264
+ | Unsigned emulator custom tokens are accepted | `auth.allowUnsignedCustomTokens` | refused |
265
+ | Firestore and Storage Security Rules accept `@firebase/rules-unit-testing`'s unsigned mock ID token (`authenticatedContext()`, the client SDK's `mockUserToken`) | `auth.allowUnsignedIdTokens` | refused, as production refuses an unsigned token |
266
+ | Identity-provider sign-in accepts the fixture assertions and the sign-in widget (`/emulator/auth/handler`), for built-in, `oidc.*` and `saml.*` providers | `auth.idpAssertions` (`"fixture"`) | `"signed"`: OIDC ID tokens must verify with an `auth.idpSigners` key, SAML responses with the provider's certificates, and the fixture and built-in providers are refused |
267
+ | The strict Eventarc listener admits any credential or none, so the Admin SDK publishes with a fake credential (see [Eventarc authentication](https://github.com/t-k/fireemu/blob/v0.18.0/docs/eventarc-authentication.md)) | `eventarc.authentication` (`"permissive"`) | `"production"`: a missing, malformed or JWT-shaped bearer is refused with production's 401 |
268
+ | A query whose composite index is not defined (or is still building, or was deleted) runs, and each missing index is reported once per database on stderr with production's refusal text and the `firestore.indexes.json` entry | `firestore.missingIndexes` (`"report"`) | refused with `FAILED_PRECONDITION` and the console link (`"refuse"`) |
269
+ | A tenant of `auth.tenants` can have any readable id, such as `tenant-a` | `auth.tenantIdFormat` (`"readable"`) | the id must have production's generated form, the display name, a hyphen and five characters of `a-z0-9` (`"generated"`) |
270
+ | An end user's native gRPC `Listen` stream stays open however long it is held. `POST /v1/firestore/listen:expire` on the control API ends every held end-user stream at once, with production's status, to test a client's reconnect | `firestore.listenStreamLifetime` (`"unlimited"`) | ended with `INTERNAL` an hour after it opened, as production ends it (`"oneHour"`) |
271
+
272
+ The start banner and `fireemu capabilities` report whether `productionExact` is set.
184
273
 
185
274
  Under the `emulator` profile, a request that names a tenant the project does not have creates that tenant, and the number of tenants is not limited, as in the official emulator. The `strict` profile refuses such a request, as production does. A request that Fireemu refuses (a wrong credential, a browser page without the control token on the emulator routes, App Check, an unknown API key) creates nothing. As in the official emulator, a plain `GET` without an `Origin` header to a tenant route of `127.0.0.1` creates the tenant, so any web page you visit while the emulator runs can add tenants to it (not read them); use the `strict` profile where that matters.
186
275
 
276
+ ### Migrating from the Firebase Local Emulator Suite
277
+
278
+ Keep `"profile": "strict"` (the default of `fireemu init`), and point fireemu at your existing `firebase.json` with `npx fireemu init --firebase-json firebase.json` or `--firebase-json` on the command line. Replace `firebase emulators:exec` with `fireemu exec` and `firebase emulators:start` with `fireemu up`; the official command names `emulators:exec` and `emulators:start` also work.
279
+
280
+ When a test fails under `strict` but passed on the official emulator, it is usually behavior the application would also meet in production. Fix the test or the application, or relax only the specific setting below instead of switching the whole profile.
281
+
282
+ - **Unsigned emulator ID tokens** (`@firebase/rules-unit-testing` `authenticatedContext()`, the client SDK's `mockUserToken`) work under `strict` by default. Set `auth.allowUnsignedIdTokens` to `false` to test production's refusal of them on the Security Rules surfaces.
283
+ - **Composite indexes** are validated as production does, and no setting changes that. Declare the index a query needs in `firestore.indexes.json`, referenced from `firebase.json`.
284
+ - **Settings that mirror your production project.** Set them to match it instead of switching the profile:
285
+
286
+ | Setting | What it does under `strict` |
287
+ |---|---|
288
+ | `auth.improvedEmailPrivacy` | Email enumeration protection, on for a new production project. Set `false` only if your production project turned it off; sign-ins then answer `EMAIL_NOT_FOUND` and `INVALID_PASSWORD` as the official Auth emulator does |
289
+ | `auth.mfa` | Your project's multi-factor configuration (an object, see [Enable multi-factor authentication at start](#enable-multi-factor-authentication-at-start)). `strict` starts with multi-factor off, as a new production project does, and the official emulator has no TOTP at all |
290
+ | `firestore.enforceLimits` | Production always enforces the Standard edition query limits. `false` lets queries pass that production refuses, so leave it on unless you have a specific reason |
291
+
187
292
  ### Basic configuration
188
293
 
189
294
  The initial configuration selects Standard edition Firestore with the Native API.
@@ -200,13 +305,13 @@ The initial configuration selects Standard edition Firestore with the Native API
200
305
  }
201
306
  ```
202
307
 
203
- You can specify the configuration file with `--config`.
308
+ You can also name the configuration file with `--config`.
204
309
 
205
310
  ```sh
206
311
  npx fireemu up --config ./fireemu.json
207
312
  ```
208
313
 
209
- Keep Fireemu-specific settings in a Fireemu configuration file containing `"schemaVersion": 1`, rather than in `firebase.json`. See the [configuration schema](https://github.com/t-k/fireemu/blob/v0.16.0/spec/config/fireemu.schema.json) for all available settings.
314
+ Keep Fireemu-specific settings in a Fireemu configuration file containing `"schemaVersion": 1`, rather than in `firebase.json`. See the [configuration schema](https://github.com/t-k/fireemu/blob/v0.18.0/spec/config/fireemu.schema.json) for all available settings.
210
315
 
211
316
  ### Firebase Authentication (Identity Platform) configuration
212
317
 
@@ -227,16 +332,23 @@ The `auth` section of `fireemu.json` lets you configure sign-in methods, passwor
227
332
  | Project- and tenant-specific password policies and account permissions | `auth.passwordPolicyOverrides`, `auth.configOverrides` |
228
333
  | Blocking functions before account creation or sign-in, and credential forwarding to those functions | `auth.blockingFunctions` |
229
334
  | Initial custom OIDC and SAML provider resources | `auth.providers.oidc`, `auth.providers.saml` |
335
+ | Accept unsigned emulator custom tokens (default `true` in both profiles, `false` with `productionExact`) | `auth.allowUnsignedCustomTokens` |
336
+ | Accept `@firebase/rules-unit-testing`'s unsigned mock ID token in Firestore and Storage Security Rules (default `true` in both profiles, `false` with `productionExact`) | `auth.allowUnsignedIdTokens` |
337
+ | Accept the fixture identity-provider assertions and sign-in widget (`"fixture"`, the default in both profiles), or verify signed assertions as production does (`"signed"`, `strict` only; the default with `productionExact` or `auth.idpSigners`) | `auth.idpAssertions` |
230
338
  | Public keys for verifying custom tokens and OIDC ID tokens | `auth.customTokenSigners`, `auth.idpSigners` |
231
339
  | Sign-up quota configuration and local quota-exceeded simulation | `auth.quota`, `auth.quotaSimulation` |
232
340
 
233
- See the [configuration schema](https://github.com/t-k/fireemu/blob/v0.16.0/spec/config/fireemu.schema.json) for the format and accepted values of each setting.
341
+ Unsigned custom tokens minted by the Firebase Admin SDK in emulator mode are accepted by default, including with the recommended `strict` profile and with `auth.customTokenSigners` configured. To require signed custom tokens, set `auth.allowUnsignedCustomTokens` to `false` and configure `auth.customTokenSigners` with the service accounts' public JWK sets. The setting applies only to custom-token sign-in; strict claim checks and signed-token verification still apply. In the `emulator` profile, setting it to `false` also disables JSON fake custom tokens.
342
+
343
+ The unsigned mock ID token of `@firebase/rules-unit-testing` is accepted by default when Firestore and Storage Security Rules are evaluated, including with the `strict` profile. This is the token `authenticatedContext()` and the client SDKs' `mockUserToken` option send (`createMockUserToken` in `@firebase/util`). Under `strict` only that exact shape is accepted: a JWT whose header is exactly `{"alg":"none","type":"JWT"}` and whose signature is empty. `request.auth` is built from the token's claims, as the official emulator builds it, when the token names a subject (`sub`) and its audience (`aud`) is the project the request goes to. Its `exp` is not checked, because the SDK sets `iat: 0` and `exp: 3600` by default. Every other token is verified as before, expiry included. That covers the unsigned ID tokens fireemu itself issues (their header carries `typ`, not `type`), and a token that claims a signature that does not verify is still refused. The `emulator` profile accepts any unsigned token, as the official emulator does, and its Storage also accepts another project's token. To refuse the mock token as production does, set `auth.allowUnsignedIdTokens` to `false` (in either profile) or set `productionExact`. A session with `auth.idTokenSigning: "session-rsa"` accepts no unsigned token. The setting does not affect callable Functions, Identity Toolkit or App Check.
344
+
345
+ See the [configuration schema](https://github.com/t-k/fireemu/blob/v0.18.0/spec/config/fireemu.schema.json) for the format and accepted values of each setting.
234
346
 
235
- Declare `auth.authorizedDomains`, for example `["localhost", "app.test"]`, to set the initial project-wide list in either profile. The list replaces the defaults, so include `localhost` if your tests use it. An empty list authorizes no host under `strict`; an absent or `null` setting keeps the existing defaults (`localhost` and the project's `firebaseapp.com` and `web.app` domains). Validation uses the Admin API's rules for the selected profile, including its conversion of numeric and boolean entries to strings and omission of `null` entries; use strings when writing the list. Fireemu intentionally keeps `localhost` in its defaults for development. The [recorded production sandbox baseline](https://github.com/t-k/fireemu/blob/v0.16.0/conformance/auth-action-production.json) does not include it; new production projects may also omit it. This default is a Fireemu-only convenience, and declaring the list replaces it. Tenant-scoped strict action links currently check the tenant's default domains rather than this project declaration; support for the parent project's live list is pending.
347
+ Declare `auth.authorizedDomains`, for example `["localhost", "app.test"]`, to set the initial project-wide list in either profile. The list replaces the defaults, so include `localhost` if your tests use it. An empty list authorizes no host under `strict`; an absent or `null` setting keeps the existing defaults (`localhost` and the project's `firebaseapp.com` and `web.app` domains). Validation uses the Admin API's rules for the selected profile, including its conversion of numeric and boolean entries to strings and omission of `null` entries; use strings when writing the list. Fireemu intentionally keeps `localhost` in its defaults for development. The [recorded production sandbox baseline](https://github.com/t-k/fireemu/blob/v0.18.0/conformance/auth-action-production.json) does not include it; new production projects may also omit it. This default is a Fireemu-only convenience, and declaring the list replaces it. Tenant-scoped strict action links currently check the tenant's default domains rather than this project declaration; support for the parent project's live list is pending.
236
348
 
237
349
  An Admin update changes the live list. A session reset restores the declared list, when present, and preserves an Admin-written list when no initial list was declared. Projects created later receive the declaration word for word, independently of the default project's live list; listing a particular project's `firebaseapp.com` or `web.app` domain therefore gives later projects that same domain. Clearing accounts leaves the live list alone. Auth export/import carries accounts without the domain list or its declaration. The `emulator` profile accepts the setting and exposes the list, while continuing to allow action-link continue URLs outside it.
238
350
 
239
- Declare project OIDC and SAML resources with `auth.providers.oidc` and `auth.providers.saml`, using the Admin v2 resource fields and an ID-only `name` such as `oidc.fixture` or `saml.fixture`. Full resource names are refused. For example, `"providers": {"oidc": [{"name": "oidc.fixture", "enabled": true, "clientId": "local-client", "issuer": "https://issuer.test", "responseType": {"idToken": true}}]}` initializes that provider in both profiles. Strict OIDC sign-in also needs matching public issuer keys in `auth.idpSigners`; no key is fetched. Strict SAML uses the declared provider certificates and retains its existing assertion checks.
351
+ Declare project OIDC and SAML resources with `auth.providers.oidc` and `auth.providers.saml`, using the Admin v2 resource fields and an ID-only `name` such as `oidc.fixture` or `saml.fixture`. Full resource names are refused. For example, `"providers": {"oidc": [{"name": "oidc.fixture", "enabled": true, "clientId": "local-client", "issuer": "https://issuer.test", "responseType": {"idToken": true}}]}` initializes that provider in both profiles. By default both profiles accept the fixture assertions the official emulator accepts (a JSON or unsigned ID token, a JSON SAML response, the sign-in widget), whether or not the provider is declared. With `auth.idpAssertions` set to `"signed"` (or `productionExact`, or `auth.idpSigners` present), strict OIDC sign-in needs matching public issuer keys in `auth.idpSigners`; no key is fetched. Strict SAML then uses the declared provider certificates and retains its existing assertion checks.
240
352
 
241
353
  Each declared array replaces that provider kind; `[]` explicitly starts it empty, while an absent or `null` kind declares no initial resources. Admin operations change live resources until a session reset restores the declared kinds. Later session and routed projects inherit the declaration independently of the default project's live changes. Tenant resources and built-in providers remain separate. Clearing accounts preserves live resources; snapshots and Auth export/import transfer no provider resources or declarations. The emulator profile continues to accept its unsigned fixture credentials without requiring configured or enabled provider resources. These declarations require a canonical document with `"schemaVersion": 1`; a Firebase deployment `auth.providers` section without that version remains deployment data and installs no provider seeds.
242
354
 
@@ -326,11 +438,11 @@ Under the `strict` profile, TOTP is enabled only through the project's MFA confi
326
438
 
327
439
  #### Enable multi-tenancy
328
440
 
329
- Under the `strict` profile, enable `multiTenant.allowTenants` before using multi-tenancy: through the Admin API, or with `auth.multiTenant` in the file (see "Start with tenants" below). See the [compatibility documentation](https://github.com/t-k/fireemu/blob/v0.16.0/docs/compatibility-contract.md) for the supported Admin API scope.
441
+ Under the `strict` profile, enable `multiTenant.allowTenants` before using multi-tenancy: through the Admin API, or with `auth.multiTenant` in the file (see "Start with tenants" below). See the [compatibility documentation](https://github.com/t-k/fireemu/blob/v0.18.0/docs/compatibility-contract.md) for the supported Admin API scope.
330
442
 
331
443
  #### Start with tenants
332
444
 
333
- Instead of creating tenants through the Admin API in every session, declare the default project's tenants and the multi-tenancy switch in the file. Each entry of `auth.tenants` is an Admin v2 `Tenant` document plus its `tenantId`, which has the form production generates, the display name, a hyphen, and five characters of `a-z0-9`:
445
+ Instead of creating tenants through the Admin API in every session, declare the default project's tenants and the multi-tenancy switch in the file. Each entry of `auth.tenants` is an Admin v2 `Tenant` document plus its `tenantId`. By default the id can be any readable name that starts with a letter and holds letters, digits and hyphens (up to 63 characters), such as `tenant-a`. With `productionExact` or `auth.tenantIdFormat: "generated"` it must have the form production generates, the display name, a hyphen, and five characters of `a-z0-9`, such as `acme-x7k2q`:
334
446
 
335
447
  ```json
336
448
  {
@@ -340,7 +452,7 @@ Instead of creating tenants through the Admin API in every session, declare the
340
452
  "multiTenant": { "allowTenants": true },
341
453
  "tenants": [
342
454
  {
343
- "tenantId": "acme-x7k2q",
455
+ "tenantId": "tenant-a",
344
456
  "displayName": "acme",
345
457
  "allowPasswordSignup": true,
346
458
  "mfaConfig": { "state": "ENABLED", "enabledProviders": ["PHONE_SMS"] }
@@ -377,7 +489,7 @@ A schedule is driven by the virtual clock alone: real time passing runs nothing.
377
489
 
378
490
  A manual run (`POST /v1/sessions/{session}/functions/{name}:run`) enqueues one run of a scheduled function stamped with the current virtual time. It does not consume the next occurrence, which still comes due and is subject to `scheduler.overlap` like any run. It answers `400 INVALID_ARGUMENT` for an unknown function, a function that is not scheduled, an overlap policy refusal, or a runtime that is shutting down, and `429 RESOURCE_EXHAUSTED` when the event queue is full. This is fireemu's own control, not a claim about production's run-now.
379
491
 
380
- See the [configuration schema](https://github.com/t-k/fireemu/blob/v0.16.0/spec/config/fireemu.schema.json) for available settings and values.
492
+ See the [configuration schema](https://github.com/t-k/fireemu/blob/v0.18.0/spec/config/fireemu.schema.json) for available settings and values.
381
493
 
382
494
  ### Firestore history limits
383
495
 
@@ -455,15 +567,34 @@ Fireemu is compatible with the listed Local Emulator Suite products as shipped b
455
567
 
456
568
  The `strict` and `emulator` profiles differ in some behaviors to serve their respective purposes. Where the official emulator and production Firebase disagree, Fireemu also adopts production behavior in some cases and records the difference.
457
569
 
458
- Check support for the specific APIs and conditions your application uses, rather than relying on product names alone. The [compatibility contract](https://github.com/t-k/fireemu/blob/v0.16.0/spec/compatibility/contract.json) records scope and known differences. The [compatibility documentation](https://github.com/t-k/fireemu/blob/v0.16.0/docs/compatibility-contract.md) explains the verification process and how to interpret its records.
570
+ Check support for the specific APIs and conditions your application uses, rather than relying on product names alone. The [compatibility contract](https://github.com/t-k/fireemu/blob/v0.18.0/spec/compatibility/contract.json) records scope and known differences. The [compatibility documentation](https://github.com/t-k/fireemu/blob/v0.18.0/docs/compatibility-contract.md) explains the verification process and how to interpret its records.
459
571
 
460
572
  ### Network exposure of the Storage port
461
573
 
462
574
  Like the official emulator, the Storage port reflects the requested object name in the HTML body of its 404 for a missing media read (`text/html`, as production answers). A web page opened on the developer's machine could therefore run script on that origin. Keep the emulator bound to localhost, which is the default, and do not expose the Storage port to other hosts or networks. The strict profile sends no `X-Content-Type-Options: nosniff` on the JSON API answers where production sends none, so it does not add that defence in depth; the emulator profile keeps the official emulator's header.
463
575
 
576
+ ### Run in a container
577
+
578
+ By default every listener is on loopback, which a published container port cannot reach. To serve the emulators to the host or to other containers, opt in with `network.allowNonLoopbackHosts` in `fireemu.json` and give the product emulators a host in `firebase.json`:
579
+
580
+ ```json
581
+ { "schemaVersion": 1, "firebaseJson": "firebase.json", "network": { "allowNonLoopbackHosts": true } }
582
+ ```
583
+
584
+ ```json
585
+ { "emulators": { "firestore": { "host": "0.0.0.0", "port": 8080 }, "auth": { "host": "0.0.0.0", "port": 9099 } } }
586
+ ```
587
+
588
+ - Only Firestore, Auth, Storage, Functions, Eventarc, Cloud Tasks and Pub/Sub may listen off loopback. The Hub, the UI and the Logging emulator stay on loopback. Auth, whose port also serves the control API, listens on loopback or on every interface (`0.0.0.0` or `::`), not on one other address.
589
+ - The emulators serve without a credential, so the start prints a `warning:` line for each listener off loopback. Any client that reaches a published port can do what a local client can on the product APIs, including the Admin SDK's `Bearer owner` credential and the Auth emulator's own routes. Publish the ports only to a network you trust.
590
+ - Fireemu's own controls answer loopback peers only and return 403 to any other peer: the control API (`/v1/` and `/health/` on the Auth port), App Check debug-token management, and the routes that load Security Rules or clear Firestore data (what `@firebase/rules-unit-testing`'s `loadFirestoreRules`, `loadStorageRules` and `clearFirestore` call). Run the code that uses them in the emulator's network namespace: inside the container, or in a container that shares it (a Podman pod, `--network container:<name>`).
591
+ - Because a forwarder inside that namespace (`kubectl port-forward`, a sidecar proxy) connects from loopback, every control API request also needs `Authorization: Bearer <control token>` once the option is on, from a process as from a page; only `/health/` is exempt. The routes that load Security Rules or clear Firestore data are not held to the token, so `@firebase/rules-unit-testing` keeps working; a client that reaches the emulator through such a forwarder can call them, as it could on the official emulator. `fireemu exec` gives its command the token in `FIREEMU_CONTROL_TOKEN`, and `fireemu/testing` and the UI send it.
592
+ - Browser pages must still come from a loopback origin (`http://localhost:...`), so a page served from another host cannot use the exposed ports.
593
+ - A listener on `0.0.0.0` or `::` is advertised as `127.0.0.1` or `::1` in the environment and the Hub, as the official CLI does.
594
+
464
595
  ### Changes between versions
465
596
 
466
- Configuration and behavior may change between releases. See the [CHANGELOG](https://github.com/t-k/fireemu/blob/v0.16.0/CHANGELOG.md) for release changes.
597
+ Configuration and behavior may change between releases. See the [CHANGELOG](https://github.com/t-k/fireemu/blob/v0.18.0/CHANGELOG.md) for release changes.
467
598
 
468
599
  ## Performance
469
600
 
@@ -480,7 +611,7 @@ The following results come from one `standard` run at commit `f3b942c`. Ratios a
480
611
 
481
612
  The 95% confidence interval for the startup-time ratio is `[21.4, 21.8]`. For the peak-memory ratio, calculated as official emulator divided by Fireemu, it is `[10.2, 11.1]`.
482
613
 
483
- See [benchmark.yml](https://github.com/t-k/fireemu/blob/v0.16.0/.github/workflows/benchmark.yml) for the workflow and [`tools/bench/`](https://github.com/t-k/fireemu/tree/v0.16.0/tools/bench/) for the benchmark implementation.
614
+ See [benchmark.yml](https://github.com/t-k/fireemu/blob/v0.18.0/.github/workflows/benchmark.yml) for the workflow and [`tools/bench/`](https://github.com/t-k/fireemu/tree/v0.18.0/tools/bench/) for the benchmark implementation.
484
615
 
485
616
  ## Reporting issues and contributing
486
617
 
@@ -488,8 +619,8 @@ When reporting an issue, include the Fireemu and Firebase SDK versions, the prof
488
619
 
489
620
  For compatibility issues, also state whether you are comparing against the actual Firebase service or the official emulator, along with the expected and actual results. Remove credentials and personal information before sharing configuration files or logs.
490
621
 
491
- See the [development guide](https://github.com/t-k/fireemu/blob/v0.16.0/docs/development.md) for build and test instructions.
622
+ See the [development guide](https://github.com/t-k/fireemu/blob/v0.18.0/docs/development.md) for build and test instructions.
492
623
 
493
624
  ## License
494
625
 
495
- Fireemu is licensed under the [Apache License 2.0](https://github.com/t-k/fireemu/blob/v0.16.0/LICENSE). Third-party notices are listed in [THIRD_PARTY_LICENSES.txt](https://github.com/t-k/fireemu/blob/v0.16.0/THIRD_PARTY_LICENSES.txt).
626
+ Fireemu is licensed under the [Apache License 2.0](https://github.com/t-k/fireemu/blob/v0.18.0/LICENSE). Third-party notices are listed in [THIRD_PARTY_LICENSES.txt](https://github.com/t-k/fireemu/blob/v0.18.0/THIRD_PARTY_LICENSES.txt).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fireemu",
3
- "version": "0.16.0",
3
+ "version": "0.18.0",
4
4
  "description": "A local runtime for testing Firebase SDK and Functions code, checked against production Firebase behavior",
5
5
  "keywords": [
6
6
  "emulator",
@@ -31,11 +31,11 @@
31
31
  ],
32
32
  "type": "module",
33
33
  "optionalDependencies": {
34
- "@fireemu/darwin-arm64": "0.16.0",
35
- "@fireemu/darwin-x64": "0.16.0",
36
- "@fireemu/linux-x64": "0.16.0",
37
- "@fireemu/linux-arm64": "0.16.0",
38
- "@fireemu/win32-x64": "0.16.0"
34
+ "@fireemu/darwin-arm64": "0.18.0",
35
+ "@fireemu/darwin-x64": "0.18.0",
36
+ "@fireemu/linux-x64": "0.18.0",
37
+ "@fireemu/linux-arm64": "0.18.0",
38
+ "@fireemu/win32-x64": "0.18.0"
39
39
  },
40
40
  "engines": {
41
41
  "node": ">=20"