@firebase/rules-unit-testing 2.0.4 → 2.0.5-canary.457fc2eeb

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @firebase/rules-unit-testing
2
2
 
3
+ ## 2.0.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [`4af28c1a4`](https://github.com/firebase/firebase-js-sdk/commit/4af28c1a42bd25ce2353f694ca1724c6101cbce5) [#6682](https://github.com/firebase/firebase-js-sdk/pull/6682) - Upgrade TypeScript to 4.7.4.
8
+
3
9
  ## 2.0.4
4
10
 
5
11
  ### Patch Changes
package/dist/index.cjs.js CHANGED
@@ -120,13 +120,13 @@ function makeUrl(hostAndPort, path) {
120
120
  if (typeof hostAndPort === 'object') {
121
121
  var host = hostAndPort.host, port = hostAndPort.port;
122
122
  if (host.includes(':')) {
123
- hostAndPort = "[" + host + "]:" + port;
123
+ hostAndPort = "[".concat(host, "]:").concat(port);
124
124
  }
125
125
  else {
126
- hostAndPort = host + ":" + port;
126
+ hostAndPort = "".concat(host, ":").concat(port);
127
127
  }
128
128
  }
129
- var url = new URL("http://" + hostAndPort + "/");
129
+ var url = new URL("http://".concat(hostAndPort, "/"));
130
130
  url.pathname = path;
131
131
  return url;
132
132
  }
@@ -163,7 +163,7 @@ function discoverEmulators(hub, fetch) {
163
163
  case 1:
164
164
  res = _a.sent();
165
165
  if (!res.ok) {
166
- throw new Error("HTTP Error " + res.status + " when attempting to reach Emulator Hub at " + res.url + ", are you sure it is running?");
166
+ throw new Error("HTTP Error ".concat(res.status, " when attempting to reach Emulator Hub at ").concat(res.url, ", are you sure it is running?"));
167
167
  }
168
168
  emulators = {};
169
169
  return [4 /*yield*/, res.json()];
@@ -207,11 +207,11 @@ function getEmulatorHostAndPort(emulator, conf, discovered) {
207
207
  var host = conf.host, port = conf.port;
208
208
  if (host || port) {
209
209
  if (!host || !port) {
210
- throw new Error("Invalid configuration " + emulator + ".host=" + host + " and " + emulator + ".port=" + port + ". " +
210
+ throw new Error("Invalid configuration ".concat(emulator, ".host=").concat(host, " and ").concat(emulator, ".port=").concat(port, ". ") +
211
211
  'If either parameter is supplied, both must be defined.');
212
212
  }
213
213
  if (discovered && !discovered[emulator]) {
214
- console.warn("Warning: config for the " + emulator + " emulator is specified, but the Emulator hub " +
214
+ console.warn("Warning: config for the ".concat(emulator, " emulator is specified, but the Emulator hub ") +
215
215
  'reports it as not running. This may lead to errors such as connection refused.');
216
216
  }
217
217
  return {
@@ -224,8 +224,8 @@ function getEmulatorHostAndPort(emulator, conf, discovered) {
224
224
  var fallback = (discovered === null || discovered === void 0 ? void 0 : discovered[emulator]) || emulatorFromEnvVar(envVar);
225
225
  if (fallback) {
226
226
  if (discovered && !discovered[emulator]) {
227
- console.warn("Warning: the environment variable " + envVar + " is set, but the Emulator hub reports the " +
228
- (emulator + " emulator as not running. This may lead to errors such as connection refused."));
227
+ console.warn("Warning: the environment variable ".concat(envVar, " is set, but the Emulator hub reports the ") +
228
+ "".concat(emulator, " emulator as not running. This may lead to errors such as connection refused."));
229
229
  }
230
230
  return {
231
231
  host: fixHostname(fallback.host, (_b = discovered === null || discovered === void 0 ? void 0 : discovered.hub) === null || _b === void 0 ? void 0 : _b.host),
@@ -247,15 +247,15 @@ function emulatorFromEnvVar(envVar) {
247
247
  }
248
248
  var parsed;
249
249
  try {
250
- parsed = new URL("http://" + hostAndPort);
250
+ parsed = new URL("http://".concat(hostAndPort));
251
251
  }
252
252
  catch (_a) {
253
- throw new Error("Invalid format in environment variable " + envVar + "=" + hostAndPort + " (expected host:port)");
253
+ throw new Error("Invalid format in environment variable ".concat(envVar, "=").concat(hostAndPort, " (expected host:port)"));
254
254
  }
255
255
  var host = parsed.hostname;
256
256
  var port = Number(parsed.port || '80');
257
257
  if (!Number.isInteger(port)) {
258
- throw new Error("Invalid port in environment variable " + envVar + "=" + hostAndPort);
258
+ throw new Error("Invalid port in environment variable ".concat(envVar, "=").concat(hostAndPort));
259
259
  }
260
260
  return { host: host, port: port };
261
261
  }
@@ -341,7 +341,7 @@ var RulesTestEnvironmentImpl = /** @class */ (function () {
341
341
  case 0:
342
342
  this.checkNotDestroyed();
343
343
  assertEmulatorRunning(this.emulators, 'firestore');
344
- return [4 /*yield*/, fetch__default["default"](makeUrl(this.emulators.firestore, "/emulator/v1/projects/" + this.projectId + "/databases/(default)/documents"), {
344
+ return [4 /*yield*/, fetch__default["default"](makeUrl(this.emulators.firestore, "/emulator/v1/projects/".concat(this.projectId, "/databases/(default)/documents")), {
345
345
  method: 'DELETE'
346
346
  })];
347
347
  case 1:
@@ -440,7 +440,7 @@ var RulesTestContextImpl = /** @class */ (function () {
440
440
  return database;
441
441
  };
442
442
  RulesTestContextImpl.prototype.storage = function (bucketUrl) {
443
- if (bucketUrl === void 0) { bucketUrl = "gs://" + this.projectId; }
443
+ if (bucketUrl === void 0) { bucketUrl = "gs://".concat(this.projectId); }
444
444
  assertEmulatorRunning(this.emulators, 'storage');
445
445
  var storage = this.getApp().storage(bucketUrl);
446
446
  storage.useEmulator(this.emulators.storage.host, this.emulators.storage.port, { mockUserToken: this.authToken });
@@ -457,7 +457,7 @@ var RulesTestContextImpl = /** @class */ (function () {
457
457
  'return a Promise that resolves when the operations are done.');
458
458
  }
459
459
  if (!this.app) {
460
- this.app = firebase__default["default"].initializeApp({ projectId: this.projectId }, "_Firebase_RulesUnitTesting_" + Date.now() + "_" + Math.random());
460
+ this.app = firebase__default["default"].initializeApp({ projectId: this.projectId }, "_Firebase_RulesUnitTesting_".concat(Date.now(), "_").concat(Math.random()));
461
461
  }
462
462
  return this.app;
463
463
  };
@@ -466,13 +466,13 @@ var RulesTestContextImpl = /** @class */ (function () {
466
466
  function assertEmulatorRunning(emulators, emulator) {
467
467
  if (!emulators[emulator]) {
468
468
  if (emulators.hub) {
469
- throw new Error("The " + emulator + " emulator is not running (according to Emulator hub). To force " +
469
+ throw new Error("The ".concat(emulator, " emulator is not running (according to Emulator hub). To force ") +
470
470
  'connecting anyway, please specify its host and port in initializeTestEnvironment({...}).');
471
471
  }
472
472
  else {
473
- throw new Error("The host and port of the " + emulator + " emulator must be specified. (You may wrap the test " +
473
+ throw new Error("The host and port of the ".concat(emulator, " emulator must be specified. (You may wrap the test ") +
474
474
  "script with `firebase emulators:exec './your-test-script'` to enable automatic " +
475
- ("discovery, or specify manually via initializeTestEnvironment({" + emulator + ": {host, port}})."));
475
+ "discovery, or specify manually via initializeTestEnvironment({".concat(emulator, ": {host, port}})."));
476
476
  }
477
477
  }
478
478
  }
@@ -528,7 +528,7 @@ function loadFirestoreRules(hostAndPort, projectId, rules) {
528
528
  var resp, _a;
529
529
  return __generator(this, function (_b) {
530
530
  switch (_b.label) {
531
- case 0: return [4 /*yield*/, fetch__default["default"](makeUrl(hostAndPort, "/emulator/v1/projects/" + projectId + ":securityRules"), {
531
+ case 0: return [4 /*yield*/, fetch__default["default"](makeUrl(hostAndPort, "/emulator/v1/projects/".concat(projectId, ":securityRules")), {
532
532
  method: 'PUT',
533
533
  body: JSON.stringify({
534
534
  rules: {
@@ -711,7 +711,7 @@ function withFunctionTriggersDisabled(fnOrHub, maybeFn) {
711
711
  }
712
712
  if (!hub) {
713
713
  throw new Error('Please specify the Emulator Hub host and port via arguments or set the environment ' +
714
- ("varible " + EMULATOR_HOST_ENV_VARS.hub + "!"));
714
+ "varible ".concat(EMULATOR_HOST_ENV_VARS.hub, "!"));
715
715
  }
716
716
  hub.host = fixHostname(hub.host);
717
717
  makeUrl(hub, '/functions/disableBackgroundTriggers');
@@ -721,7 +721,7 @@ function withFunctionTriggersDisabled(fnOrHub, maybeFn) {
721
721
  case 1:
722
722
  disableRes = _a.sent();
723
723
  if (!disableRes.ok) {
724
- throw new Error("HTTP Error " + disableRes.status + " when disabling functions triggers, are you using firebase-tools 8.13.0 or higher?");
724
+ throw new Error("HTTP Error ".concat(disableRes.status, " when disabling functions triggers, are you using firebase-tools 8.13.0 or higher?"));
725
725
  }
726
726
  result = undefined;
727
727
  _a.label = 2;
@@ -737,7 +737,7 @@ function withFunctionTriggersDisabled(fnOrHub, maybeFn) {
737
737
  case 5:
738
738
  enableRes = _a.sent();
739
739
  if (!enableRes.ok) {
740
- throw new Error("HTTP Error " + enableRes.status + " when enabling functions triggers, are you using firebase-tools 8.13.0 or higher?");
740
+ throw new Error("HTTP Error ".concat(enableRes.status, " when enabling functions triggers, are you using firebase-tools 8.13.0 or higher?"));
741
741
  }
742
742
  return [7 /*endfinally*/];
743
743
  case 6:
@@ -777,7 +777,7 @@ function assertFails(pr) {
777
777
  // Storage permission errors contain message: (storage/unauthorized)
778
778
  errMessage.indexOf('unauthorized') >= 0;
779
779
  if (!isPermissionDenied) {
780
- return Promise.reject(new Error("Expected PERMISSION_DENIED but got unexpected error: " + err));
780
+ return Promise.reject(new Error("Expected PERMISSION_DENIED but got unexpected error: ".concat(err)));
781
781
  }
782
782
  return err;
783
783
  });
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../src/impl/url.ts","../src/impl/discovery.ts","../src/impl/test_environment.ts","../src/impl/rules.ts","../src/initialize.ts","../src/util.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2021 Google 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 { HostAndPort } from '../public_types';\n\n/**\n * Return a connectable hostname, replacing wildcard 0.0.0.0 or :: with loopback\n * addresses 127.0.0.1 / ::1 correspondingly. See below for why this is needed:\n * https://github.com/firebase/firebase-tools-ui/issues/286\n *\n * This assumes emulators are running on the same device as fallbackHost (e.g.\n * hub), which should hold if both are started from the same CLI command.\n * @private\n */\nexport function fixHostname(host: string, fallbackHost?: string): string {\n host = host.replace('[', '').replace(']', ''); // Remove IPv6 brackets\n if (host === '0.0.0.0') {\n host = fallbackHost || '127.0.0.1';\n } else if (host === '::') {\n host = fallbackHost || '::1';\n }\n return host;\n}\n\n/**\n * Create a URL with host, port, and path. Handles IPv6 bracketing correctly.\n * @private\n */\nexport function makeUrl(hostAndPort: HostAndPort | string, path: string): URL {\n if (typeof hostAndPort === 'object') {\n const { host, port } = hostAndPort;\n if (host.includes(':')) {\n hostAndPort = `[${host}]:${port}`;\n } else {\n hostAndPort = `${host}:${port}`;\n }\n }\n const url = new URL(`http://${hostAndPort}/`);\n url.pathname = path;\n return url;\n}\n","/**\n * @license\n * Copyright 2021 Google 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 { EmulatorConfig, HostAndPort } from '../public_types';\nimport nodeFetch from 'node-fetch';\nimport { makeUrl, fixHostname } from './url';\n\n/**\n * Use the Firebase Emulator hub to discover other running emulators.\n *\n * @param hub the host and port where the Emulator Hub is running\n * @private\n */\nexport async function discoverEmulators(\n hub: HostAndPort,\n fetch: typeof nodeFetch = nodeFetch\n): Promise<DiscoveredEmulators> {\n const res = await fetch(makeUrl(hub, '/emulators'));\n if (!res.ok) {\n throw new Error(\n `HTTP Error ${res.status} when attempting to reach Emulator Hub at ${res.url}, are you sure it is running?`\n );\n }\n\n const emulators: DiscoveredEmulators = {};\n\n const data = await res.json();\n\n if (data.database) {\n emulators.database = {\n host: data.database.host,\n port: data.database.port\n };\n }\n\n if (data.firestore) {\n emulators.firestore = {\n host: data.firestore.host,\n port: data.firestore.port\n };\n }\n\n if (data.storage) {\n emulators.storage = {\n host: data.storage.host,\n port: data.storage.port\n };\n }\n\n if (data.hub) {\n emulators.hub = {\n host: data.hub.host,\n port: data.hub.port\n };\n }\n return emulators;\n}\n\n/**\n * @private\n */\nexport interface DiscoveredEmulators {\n database?: HostAndPort;\n firestore?: HostAndPort;\n storage?: HostAndPort;\n hub?: HostAndPort;\n}\n\n/**\n * @private\n */\nexport function getEmulatorHostAndPort(\n emulator: keyof DiscoveredEmulators,\n conf?: EmulatorConfig,\n discovered?: DiscoveredEmulators\n) {\n if (conf && ('host' in conf || 'port' in conf)) {\n const { host, port } = conf;\n if (host || port) {\n if (!host || !port) {\n throw new Error(\n `Invalid configuration ${emulator}.host=${host} and ${emulator}.port=${port}. ` +\n 'If either parameter is supplied, both must be defined.'\n );\n }\n if (discovered && !discovered[emulator]) {\n console.warn(\n `Warning: config for the ${emulator} emulator is specified, but the Emulator hub ` +\n 'reports it as not running. This may lead to errors such as connection refused.'\n );\n }\n return {\n host: fixHostname(conf.host, discovered?.hub?.host),\n port: conf.port\n };\n }\n }\n const envVar = EMULATOR_HOST_ENV_VARS[emulator];\n const fallback = discovered?.[emulator] || emulatorFromEnvVar(envVar);\n if (fallback) {\n if (discovered && !discovered[emulator]) {\n console.warn(\n `Warning: the environment variable ${envVar} is set, but the Emulator hub reports the ` +\n `${emulator} emulator as not running. This may lead to errors such as connection refused.`\n );\n }\n return {\n host: fixHostname(fallback.host, discovered?.hub?.host),\n port: fallback.port\n };\n }\n}\n\n// Visible for testing.\nexport const EMULATOR_HOST_ENV_VARS = {\n 'database': 'FIREBASE_DATABASE_EMULATOR_HOST',\n 'firestore': 'FIRESTORE_EMULATOR_HOST',\n 'hub': 'FIREBASE_EMULATOR_HUB',\n 'storage': 'FIREBASE_STORAGE_EMULATOR_HOST'\n};\n\nfunction emulatorFromEnvVar(envVar: string): HostAndPort | undefined {\n const hostAndPort = process.env[envVar];\n if (!hostAndPort) {\n return undefined;\n }\n\n let parsed: URL;\n try {\n parsed = new URL(`http://${hostAndPort}`);\n } catch {\n throw new Error(\n `Invalid format in environment variable ${envVar}=${hostAndPort} (expected host:port)`\n );\n }\n let host = parsed.hostname;\n const port = Number(parsed.port || '80');\n if (!Number.isInteger(port)) {\n throw new Error(\n `Invalid port in environment variable ${envVar}=${hostAndPort}`\n );\n }\n return { host, port };\n}\n","/**\n * @license\n * Copyright 2021 Google 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 fetch from 'node-fetch';\nimport firebase from 'firebase/compat/app';\nimport 'firebase/compat/firestore';\nimport 'firebase/compat/database';\nimport 'firebase/compat/storage';\n\nimport {\n HostAndPort,\n RulesTestContext,\n RulesTestEnvironment,\n TokenOptions\n} from '../public_types';\n\nimport { DiscoveredEmulators } from './discovery';\nimport { makeUrl } from './url';\n\n/**\n * An implementation of {@code RulesTestEnvironment}. This is private to hide the constructor,\n * which should never be directly called by the developer.\n * @private\n */\nexport class RulesTestEnvironmentImpl implements RulesTestEnvironment {\n private contexts = new Set<RulesTestContextImpl>();\n private destroyed = false;\n\n constructor(\n readonly projectId: string,\n readonly emulators: DiscoveredEmulators\n ) {}\n\n authenticatedContext(\n user_id: string,\n tokenOptions?: TokenOptions\n ): RulesTestContext {\n this.checkNotDestroyed();\n return this.createContext({\n ...tokenOptions,\n sub: user_id,\n user_id: user_id\n });\n }\n\n unauthenticatedContext(): RulesTestContext {\n this.checkNotDestroyed();\n return this.createContext(/* authToken = */ undefined);\n }\n\n async withSecurityRulesDisabled(\n callback: (context: RulesTestContext) => Promise<void>\n ): Promise<void> {\n this.checkNotDestroyed();\n // The \"owner\" token is recognized by the emulators as a special value that bypasses Security\n // Rules. This should only ever be used in withSecurityRulesDisabled.\n // If you're reading this and thinking about doing this in your own app / tests / scripts, think\n // twice. Instead, just use withSecurityRulesDisabled for unit testing OR connect your Firebase\n // Admin SDKs to the emulators for integration testing via environment variables.\n // See: https://firebase.google.com/docs/emulator-suite/connect_firestore#admin_sdks\n const context = this.createContext('owner');\n try {\n await callback(context);\n } finally {\n // We eagarly clean up this context to actively prevent misuse outside of the callback, e.g.\n // storing the context in a variable.\n context.cleanup();\n this.contexts.delete(context);\n }\n }\n\n private createContext(\n authToken: string | firebase.EmulatorMockTokenOptions | undefined\n ): RulesTestContextImpl {\n const context = new RulesTestContextImpl(\n this.projectId,\n this.emulators,\n authToken\n );\n this.contexts.add(context);\n return context;\n }\n\n clearDatabase(): Promise<void> {\n this.checkNotDestroyed();\n return this.withSecurityRulesDisabled(context => {\n return context.database().ref('/').set(null);\n });\n }\n\n async clearFirestore(): Promise<void> {\n this.checkNotDestroyed();\n assertEmulatorRunning(this.emulators, 'firestore');\n\n const resp = await fetch(\n makeUrl(\n this.emulators.firestore,\n `/emulator/v1/projects/${this.projectId}/databases/(default)/documents`\n ),\n {\n method: 'DELETE'\n }\n );\n\n if (!resp.ok) {\n throw new Error(await resp.text());\n }\n }\n\n clearStorage(): Promise<void> {\n this.checkNotDestroyed();\n return this.withSecurityRulesDisabled(async context => {\n const { items } = await context.storage().ref().listAll();\n await Promise.all(\n items.map(item => {\n return item.delete();\n })\n );\n });\n }\n\n async cleanup(): Promise<void> {\n this.destroyed = true;\n this.contexts.forEach(context => {\n context.envDestroyed = true;\n context.cleanup();\n });\n this.contexts.clear();\n }\n\n private checkNotDestroyed() {\n if (this.destroyed) {\n throw new Error(\n 'This RulesTestEnvironment has already been cleaned up. ' +\n '(This may indicate a leak or missing `await` in your test cases. If you do intend to ' +\n 'perform more tests, please call cleanup() later or create another RulesTestEnvironment.)'\n );\n }\n }\n}\n/**\n * An implementation of {@code RulesTestContext}. This is private to hide the constructor,\n * which should never be directly called by the developer.\n * @private\n */\nclass RulesTestContextImpl implements RulesTestContext {\n private app?: firebase.app.App;\n private destroyed = false;\n envDestroyed = false;\n\n constructor(\n readonly projectId: string,\n readonly emulators: DiscoveredEmulators,\n readonly authToken: firebase.EmulatorMockTokenOptions | string | undefined\n ) {}\n\n cleanup() {\n this.destroyed = true;\n this.app?.delete();\n\n this.app = undefined;\n }\n\n firestore(\n settings?: firebase.firestore.Settings\n ): firebase.firestore.Firestore {\n assertEmulatorRunning(this.emulators, 'firestore');\n const firestore = this.getApp().firestore();\n if (settings) {\n firestore.settings(settings);\n }\n firestore.useEmulator(\n this.emulators.firestore.host,\n this.emulators.firestore.port,\n { mockUserToken: this.authToken }\n );\n return firestore;\n }\n database(databaseURL?: string): firebase.database.Database {\n assertEmulatorRunning(this.emulators, 'database');\n if (!databaseURL) {\n const url = makeUrl(this.emulators.database, '');\n // Make sure to set the namespace equal to projectId -- otherwise the RTDB SDK will by default\n // use `${projectId}-default-rtdb`, which is treated as a different DB by the RTDB emulator\n // (and thus WON'T apply any rules set for the `projectId` DB during initialization).\n url.searchParams.append('ns', this.projectId);\n databaseURL = url.toString();\n }\n const database = this.getApp().database(databaseURL);\n database.useEmulator(\n this.emulators.database.host,\n this.emulators.database.port,\n { mockUserToken: this.authToken }\n );\n return database;\n }\n storage(bucketUrl = `gs://${this.projectId}`): firebase.storage.Storage {\n assertEmulatorRunning(this.emulators, 'storage');\n const storage = this.getApp().storage(bucketUrl);\n storage.useEmulator(\n this.emulators.storage.host,\n this.emulators.storage.port,\n { mockUserToken: this.authToken }\n );\n return storage;\n }\n\n private getApp(): firebase.app.App {\n if (this.envDestroyed) {\n throw new Error(\n 'This RulesTestContext is no longer valid because its RulesTestEnvironment has been ' +\n 'cleaned up. (This may indicate a leak or missing `await` in your test cases.)'\n );\n }\n if (this.destroyed) {\n throw new Error(\n 'This RulesTestContext is no longer valid. When using withSecurityRulesDisabled, ' +\n 'make sure to perform all operations on the context within the callback function and ' +\n 'return a Promise that resolves when the operations are done.'\n );\n }\n if (!this.app) {\n this.app = firebase.initializeApp(\n { projectId: this.projectId },\n `_Firebase_RulesUnitTesting_${Date.now()}_${Math.random()}`\n );\n }\n return this.app;\n }\n}\n\nexport function assertEmulatorRunning<E extends keyof DiscoveredEmulators>(\n emulators: DiscoveredEmulators,\n emulator: E\n): asserts emulators is Record<E, HostAndPort> {\n if (!emulators[emulator]) {\n if (emulators.hub) {\n throw new Error(\n `The ${emulator} emulator is not running (according to Emulator hub). To force ` +\n 'connecting anyway, please specify its host and port in initializeTestEnvironment({...}).'\n );\n } else {\n throw new Error(\n `The host and port of the ${emulator} emulator must be specified. (You may wrap the test ` +\n \"script with `firebase emulators:exec './your-test-script'` to enable automatic \" +\n `discovery, or specify manually via initializeTestEnvironment({${emulator}: {host, port}}).`\n );\n }\n }\n}\n","/**\n * @license\n * Copyright 2021 Google 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 { HostAndPort } from '../public_types';\nimport { makeUrl } from './url';\nimport fetch from 'node-fetch';\n\n/**\n * @private\n */\nexport async function loadDatabaseRules(\n hostAndPort: HostAndPort,\n databaseName: string,\n rules: string\n): Promise<void> {\n const url = makeUrl(hostAndPort, '/.settings/rules.json');\n url.searchParams.append('ns', databaseName);\n const resp = await fetch(url, {\n method: 'PUT',\n headers: { Authorization: 'Bearer owner' },\n body: rules\n });\n\n if (!resp.ok) {\n throw new Error(await resp.text());\n }\n}\n\n/**\n * @private\n */\nexport async function loadFirestoreRules(\n hostAndPort: HostAndPort,\n projectId: string,\n rules: string\n): Promise<void> {\n const resp = await fetch(\n makeUrl(hostAndPort, `/emulator/v1/projects/${projectId}:securityRules`),\n {\n method: 'PUT',\n body: JSON.stringify({\n rules: {\n files: [{ content: rules }]\n }\n })\n }\n );\n\n if (!resp.ok) {\n throw new Error(await resp.text());\n }\n}\n\n/**\n * @private\n */\nexport async function loadStorageRules(\n hostAndPort: HostAndPort,\n rules: string\n): Promise<void> {\n const resp = await fetch(makeUrl(hostAndPort, '/internal/setRules'), {\n method: 'PUT',\n headers: {\n 'Content-Type': 'application/json'\n },\n body: JSON.stringify({\n rules: {\n files: [{ name: 'storage.rules', content: rules }]\n }\n })\n });\n if (!resp.ok) {\n throw new Error(await resp.text());\n }\n}\n","/**\n * @license\n * Copyright 2021 Google 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 { RulesTestEnvironment, TestEnvironmentConfig } from './public_types';\nimport {\n DiscoveredEmulators,\n discoverEmulators,\n getEmulatorHostAndPort\n} from './impl/discovery';\nimport {\n assertEmulatorRunning,\n RulesTestEnvironmentImpl\n} from './impl/test_environment';\nimport {\n loadDatabaseRules,\n loadFirestoreRules,\n loadStorageRules\n} from './impl/rules';\n\n/**\n * Initializes a test environment for rules unit testing. Call this function first for test setup.\n *\n * Requires emulators to be running. This function tries to discover those emulators via environment\n * variables or through the Firebase Emulator hub if hosts and ports are unspecified. It is strongly\n * recommended to specify security rules for emulators used for testing. See minimal example below.\n *\n * @param config - the configuration for emulators. Most fields are optional if they can be discovered\n * @returns a promise that resolves with an environment ready for testing, or rejects on error.\n * @public\n * @example\n * ```javascript\n * const testEnv = await initializeTestEnvironment({\n * firestore: {\n * rules: fs.readFileSync(\"/path/to/firestore.rules\", \"utf8\"), // Load rules from file\n * // host and port can be omitted if they can be discovered from the hub.\n * },\n * // ...\n * });\n * ```\n */\nexport async function initializeTestEnvironment(\n config: TestEnvironmentConfig\n): Promise<RulesTestEnvironment> {\n const projectId = config.projectId || process.env.GCLOUD_PROJECT;\n if (!projectId) {\n throw new Error(\n 'Missing projectId option or env var GCLOUD_PROJECT! Please specify the projectId either ' +\n 'way.\\n(A demo-* projectId is strongly recommended for unit tests, such as \"demo-test\".)'\n );\n }\n const hub = getEmulatorHostAndPort('hub', config.hub);\n let discovered = hub ? { ...(await discoverEmulators(hub)), hub } : undefined;\n\n const emulators: DiscoveredEmulators = {};\n if (hub) {\n emulators.hub = hub;\n }\n\n for (const emulator of SUPPORTED_EMULATORS) {\n const hostAndPort = getEmulatorHostAndPort(\n emulator,\n config[emulator],\n discovered\n );\n if (hostAndPort) {\n emulators[emulator] = hostAndPort;\n }\n }\n\n if (config.database?.rules) {\n assertEmulatorRunning(emulators, 'database');\n await loadDatabaseRules(\n emulators.database,\n projectId,\n config.database.rules\n );\n }\n if (config.firestore?.rules) {\n assertEmulatorRunning(emulators, 'firestore');\n await loadFirestoreRules(\n emulators.firestore,\n projectId,\n config.firestore.rules\n );\n }\n if (config.storage?.rules) {\n assertEmulatorRunning(emulators, 'storage');\n await loadStorageRules(emulators.storage, config.storage.rules);\n }\n\n return new RulesTestEnvironmentImpl(projectId, emulators);\n}\n\nconst SUPPORTED_EMULATORS = ['database', 'firestore', 'storage'] as const;\n","/**\n * @license\n * Copyright 2021 Google 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 {\n EMULATOR_HOST_ENV_VARS,\n getEmulatorHostAndPort\n} from './impl/discovery';\nimport { fixHostname, makeUrl } from './impl/url';\nimport { HostAndPort } from './public_types';\nimport fetch from 'node-fetch';\n\n/**\n * Run a setup function with background Cloud Functions triggers disabled. This can be used to\n * import data into the Realtime Database or Cloud Firestore emulator without triggering locally\n * emulated Cloud Functions.\n *\n * This method only works with Firebase CLI version 8.13.0 or higher. This overload works only if\n * the Emulator hub host:port is specified by the environment variable FIREBASE_EMULATOR_HUB.\n *\n * @param fn - a function which may be sync or async (returns a promise)\n * @public\n */\nexport async function withFunctionTriggersDisabled<TResult>(\n fn: () => TResult | Promise<TResult>\n): Promise<TResult>;\n\n/**\n * Run a setup function with background Cloud Functions triggers disabled. This can be used to\n * import data into the Realtime Database or Cloud Firestore emulator without triggering locally\n * emulated Cloud Functions.\n *\n * This method only works with Firebase CLI version 8.13.0 or higher. The Emulator hub must be\n * running, which host and port are specified in this overload.\n *\n * @param fn - a function which may be sync or async (returns a promise)\n * @param hub - the host and port of the Emulator Hub (ex: `{host: 'localhost', port: 4400}`)\n * @public\n */\nexport async function withFunctionTriggersDisabled<TResult>(\n hub: { host: string; port: number },\n fn: () => TResult | Promise<TResult>\n): Promise<TResult>;\n\nexport async function withFunctionTriggersDisabled<TResult>(\n fnOrHub: { host: string; port: number } | (() => TResult | Promise<TResult>),\n maybeFn?: () => TResult | Promise<TResult>\n): Promise<TResult> {\n let hub: HostAndPort | undefined;\n if (typeof fnOrHub === 'function') {\n maybeFn = fnOrHub;\n hub = getEmulatorHostAndPort('hub');\n } else {\n hub = getEmulatorHostAndPort('hub', fnOrHub);\n if (!maybeFn) {\n throw new Error('The callback function must be specified!');\n }\n }\n if (!hub) {\n throw new Error(\n 'Please specify the Emulator Hub host and port via arguments or set the environment ' +\n `varible ${EMULATOR_HOST_ENV_VARS.hub}!`\n );\n }\n\n hub.host = fixHostname(hub.host);\n makeUrl(hub, '/functions/disableBackgroundTriggers');\n // Disable background triggers\n const disableRes = await fetch(\n makeUrl(hub, '/functions/disableBackgroundTriggers'),\n {\n method: 'PUT'\n }\n );\n if (!disableRes.ok) {\n throw new Error(\n `HTTP Error ${disableRes.status} when disabling functions triggers, are you using firebase-tools 8.13.0 or higher?`\n );\n }\n\n // Run the user's function\n let result: TResult | undefined = undefined;\n try {\n result = await maybeFn();\n } finally {\n // Re-enable background triggers\n const enableRes = await fetch(\n makeUrl(hub, '/functions/enableBackgroundTriggers'),\n {\n method: 'PUT'\n }\n );\n\n if (!enableRes.ok) {\n throw new Error(\n `HTTP Error ${enableRes.status} when enabling functions triggers, are you using firebase-tools 8.13.0 or higher?`\n );\n }\n }\n\n // Return the user's function result\n return result;\n}\n\n/**\n * Assert the promise to be rejected with a \"permission denied\" error.\n *\n * Useful to assert a certain request to be denied by Security Rules. See example below.\n * This function recognizes permission-denied errors from Database, Firestore, and Storage JS SDKs.\n *\n * @param pr - the promise to be asserted\n * @returns a Promise that is fulfilled if pr is rejected with \"permission denied\". If pr is\n * rejected with any other error or resolved, the returned promise rejects.\n * @public\n * @example\n * ```javascript\n * const unauthed = testEnv.unauthenticatedContext();\n * await assertFails(get(doc(unauthed.firestore(), '/private/doc'), { ... });\n * ```\n */\nexport function assertFails(pr: Promise<any>): Promise<any> {\n return pr.then(\n () => {\n return Promise.reject(\n new Error('Expected request to fail, but it succeeded.')\n );\n },\n (err: any) => {\n const errCode = err?.code?.toLowerCase() || '';\n const errMessage = err?.message?.toLowerCase() || '';\n const isPermissionDenied =\n errCode === 'permission-denied' ||\n errCode === 'permission_denied' ||\n errMessage.indexOf('permission_denied') >= 0 ||\n errMessage.indexOf('permission denied') >= 0 ||\n // Storage permission errors contain message: (storage/unauthorized)\n errMessage.indexOf('unauthorized') >= 0;\n\n if (!isPermissionDenied) {\n return Promise.reject(\n new Error(\n `Expected PERMISSION_DENIED but got unexpected error: ${err}`\n )\n );\n }\n return err;\n }\n );\n}\n\n/**\n * Assert the promise to be successful.\n *\n * This is a no-op function returning the passed promise as-is, but can be used for documentational\n * purposes in test code to emphasize that a certain request should succeed (e.g. allowed by rules).\n *\n * @public\n * @example\n * ```javascript\n * const alice = testEnv.authenticatedContext('alice');\n * await assertSucceeds(get(doc(alice.firestore(), '/doc/readable/by/alice'), { ... });\n * ```\n */\nexport function assertSucceeds<T>(pr: Promise<T>): Promise<T> {\n return pr;\n}\n"],"names":["nodeFetch","fetch","firebase"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;AAeG;AAIH;;;;;;;;AAQG;AACa,SAAA,WAAW,CAAC,IAAY,EAAE,YAAqB,EAAA;AAC7D,IAAA,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IAC9C,IAAI,IAAI,KAAK,SAAS,EAAE;AACtB,QAAA,IAAI,GAAG,YAAY,IAAI,WAAW,CAAC;AACpC,KAAA;SAAM,IAAI,IAAI,KAAK,IAAI,EAAE;AACxB,QAAA,IAAI,GAAG,YAAY,IAAI,KAAK,CAAC;AAC9B,KAAA;AACD,IAAA,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;AAGG;AACa,SAAA,OAAO,CAAC,WAAiC,EAAE,IAAY,EAAA;AACrE,IAAA,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE;QAC3B,IAAA,IAAI,GAAW,WAAW,CAAA,IAAtB,EAAE,IAAI,GAAK,WAAW,CAAA,IAAhB,CAAiB;AACnC,QAAA,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;AACtB,YAAA,WAAW,GAAG,GAAA,GAAI,IAAI,GAAA,IAAA,GAAK,IAAM,CAAC;AACnC,SAAA;AAAM,aAAA;AACL,YAAA,WAAW,GAAM,IAAI,GAAI,GAAA,GAAA,IAAM,CAAC;AACjC,SAAA;AACF,KA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AAW,EAAE,KAAI,EAAE,CAAC;AACrD,QAAA,IAAM,kBAAkB,GACtB,OAAO,KAAK,mBAAmB;AAC/B,YAAA,OAAO,KAAK,mBAAmB;AAC/B,YAAA,UAAU,CAAC,OAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC;AAC5C,YAAA,UAAU,CAAC,OAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC;;AAE5C,YAAA,UAAU,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAE1C,IAAI,CAAC,kBAAkB,EAAE;YACvB,OAAO,OAAO,CAAC,MAAM,CACnB,IAAI,KAAK,CACP,uDAAwD,GAAA,GAAK,CAC9D,CACF,CAAC;AACH,SAAA;AACD,QAAA,OAAO,GAAG,CAAC;AACb,KAAC,CACF,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;AAYG;AACG,SAAU,cAAc,CAAI,EAAc,EAAA;AAC9C,IAAA,OAAO,EAAE,CAAC;AACZ;;;;;;;"}
1
+ {"version":3,"file":"index.cjs.js","sources":["../src/impl/url.ts","../src/impl/discovery.ts","../src/impl/test_environment.ts","../src/impl/rules.ts","../src/initialize.ts","../src/util.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2021 Google 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 { HostAndPort } from '../public_types';\n\n/**\n * Return a connectable hostname, replacing wildcard 0.0.0.0 or :: with loopback\n * addresses 127.0.0.1 / ::1 correspondingly. See below for why this is needed:\n * https://github.com/firebase/firebase-tools-ui/issues/286\n *\n * This assumes emulators are running on the same device as fallbackHost (e.g.\n * hub), which should hold if both are started from the same CLI command.\n * @private\n */\nexport function fixHostname(host: string, fallbackHost?: string): string {\n host = host.replace('[', '').replace(']', ''); // Remove IPv6 brackets\n if (host === '0.0.0.0') {\n host = fallbackHost || '127.0.0.1';\n } else if (host === '::') {\n host = fallbackHost || '::1';\n }\n return host;\n}\n\n/**\n * Create a URL with host, port, and path. Handles IPv6 bracketing correctly.\n * @private\n */\nexport function makeUrl(hostAndPort: HostAndPort | string, path: string): URL {\n if (typeof hostAndPort === 'object') {\n const { host, port } = hostAndPort;\n if (host.includes(':')) {\n hostAndPort = `[${host}]:${port}`;\n } else {\n hostAndPort = `${host}:${port}`;\n }\n }\n const url = new URL(`http://${hostAndPort}/`);\n url.pathname = path;\n return url;\n}\n","/**\n * @license\n * Copyright 2021 Google 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 { EmulatorConfig, HostAndPort } from '../public_types';\nimport nodeFetch from 'node-fetch';\nimport { makeUrl, fixHostname } from './url';\n\n/**\n * Use the Firebase Emulator hub to discover other running emulators.\n *\n * @param hub the host and port where the Emulator Hub is running\n * @private\n */\nexport async function discoverEmulators(\n hub: HostAndPort,\n fetch: typeof nodeFetch = nodeFetch\n): Promise<DiscoveredEmulators> {\n const res = await fetch(makeUrl(hub, '/emulators'));\n if (!res.ok) {\n throw new Error(\n `HTTP Error ${res.status} when attempting to reach Emulator Hub at ${res.url}, are you sure it is running?`\n );\n }\n\n const emulators: DiscoveredEmulators = {};\n\n const data = await res.json();\n\n if (data.database) {\n emulators.database = {\n host: data.database.host,\n port: data.database.port\n };\n }\n\n if (data.firestore) {\n emulators.firestore = {\n host: data.firestore.host,\n port: data.firestore.port\n };\n }\n\n if (data.storage) {\n emulators.storage = {\n host: data.storage.host,\n port: data.storage.port\n };\n }\n\n if (data.hub) {\n emulators.hub = {\n host: data.hub.host,\n port: data.hub.port\n };\n }\n return emulators;\n}\n\n/**\n * @private\n */\nexport interface DiscoveredEmulators {\n database?: HostAndPort;\n firestore?: HostAndPort;\n storage?: HostAndPort;\n hub?: HostAndPort;\n}\n\n/**\n * @private\n */\nexport function getEmulatorHostAndPort(\n emulator: keyof DiscoveredEmulators,\n conf?: EmulatorConfig,\n discovered?: DiscoveredEmulators\n) {\n if (conf && ('host' in conf || 'port' in conf)) {\n const { host, port } = conf;\n if (host || port) {\n if (!host || !port) {\n throw new Error(\n `Invalid configuration ${emulator}.host=${host} and ${emulator}.port=${port}. ` +\n 'If either parameter is supplied, both must be defined.'\n );\n }\n if (discovered && !discovered[emulator]) {\n console.warn(\n `Warning: config for the ${emulator} emulator is specified, but the Emulator hub ` +\n 'reports it as not running. This may lead to errors such as connection refused.'\n );\n }\n return {\n host: fixHostname(conf.host, discovered?.hub?.host),\n port: conf.port\n };\n }\n }\n const envVar = EMULATOR_HOST_ENV_VARS[emulator];\n const fallback = discovered?.[emulator] || emulatorFromEnvVar(envVar);\n if (fallback) {\n if (discovered && !discovered[emulator]) {\n console.warn(\n `Warning: the environment variable ${envVar} is set, but the Emulator hub reports the ` +\n `${emulator} emulator as not running. This may lead to errors such as connection refused.`\n );\n }\n return {\n host: fixHostname(fallback.host, discovered?.hub?.host),\n port: fallback.port\n };\n }\n}\n\n// Visible for testing.\nexport const EMULATOR_HOST_ENV_VARS = {\n 'database': 'FIREBASE_DATABASE_EMULATOR_HOST',\n 'firestore': 'FIRESTORE_EMULATOR_HOST',\n 'hub': 'FIREBASE_EMULATOR_HUB',\n 'storage': 'FIREBASE_STORAGE_EMULATOR_HOST'\n};\n\nfunction emulatorFromEnvVar(envVar: string): HostAndPort | undefined {\n const hostAndPort = process.env[envVar];\n if (!hostAndPort) {\n return undefined;\n }\n\n let parsed: URL;\n try {\n parsed = new URL(`http://${hostAndPort}`);\n } catch {\n throw new Error(\n `Invalid format in environment variable ${envVar}=${hostAndPort} (expected host:port)`\n );\n }\n let host = parsed.hostname;\n const port = Number(parsed.port || '80');\n if (!Number.isInteger(port)) {\n throw new Error(\n `Invalid port in environment variable ${envVar}=${hostAndPort}`\n );\n }\n return { host, port };\n}\n","/**\n * @license\n * Copyright 2021 Google 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 fetch from 'node-fetch';\nimport firebase from 'firebase/compat/app';\nimport 'firebase/compat/firestore';\nimport 'firebase/compat/database';\nimport 'firebase/compat/storage';\n\nimport {\n HostAndPort,\n RulesTestContext,\n RulesTestEnvironment,\n TokenOptions\n} from '../public_types';\n\nimport { DiscoveredEmulators } from './discovery';\nimport { makeUrl } from './url';\n\n/**\n * An implementation of {@code RulesTestEnvironment}. This is private to hide the constructor,\n * which should never be directly called by the developer.\n * @private\n */\nexport class RulesTestEnvironmentImpl implements RulesTestEnvironment {\n private contexts = new Set<RulesTestContextImpl>();\n private destroyed = false;\n\n constructor(\n readonly projectId: string,\n readonly emulators: DiscoveredEmulators\n ) {}\n\n authenticatedContext(\n user_id: string,\n tokenOptions?: TokenOptions\n ): RulesTestContext {\n this.checkNotDestroyed();\n return this.createContext({\n ...tokenOptions,\n sub: user_id,\n user_id: user_id\n });\n }\n\n unauthenticatedContext(): RulesTestContext {\n this.checkNotDestroyed();\n return this.createContext(/* authToken = */ undefined);\n }\n\n async withSecurityRulesDisabled(\n callback: (context: RulesTestContext) => Promise<void>\n ): Promise<void> {\n this.checkNotDestroyed();\n // The \"owner\" token is recognized by the emulators as a special value that bypasses Security\n // Rules. This should only ever be used in withSecurityRulesDisabled.\n // If you're reading this and thinking about doing this in your own app / tests / scripts, think\n // twice. Instead, just use withSecurityRulesDisabled for unit testing OR connect your Firebase\n // Admin SDKs to the emulators for integration testing via environment variables.\n // See: https://firebase.google.com/docs/emulator-suite/connect_firestore#admin_sdks\n const context = this.createContext('owner');\n try {\n await callback(context);\n } finally {\n // We eagarly clean up this context to actively prevent misuse outside of the callback, e.g.\n // storing the context in a variable.\n context.cleanup();\n this.contexts.delete(context);\n }\n }\n\n private createContext(\n authToken: string | firebase.EmulatorMockTokenOptions | undefined\n ): RulesTestContextImpl {\n const context = new RulesTestContextImpl(\n this.projectId,\n this.emulators,\n authToken\n );\n this.contexts.add(context);\n return context;\n }\n\n clearDatabase(): Promise<void> {\n this.checkNotDestroyed();\n return this.withSecurityRulesDisabled(context => {\n return context.database().ref('/').set(null);\n });\n }\n\n async clearFirestore(): Promise<void> {\n this.checkNotDestroyed();\n assertEmulatorRunning(this.emulators, 'firestore');\n\n const resp = await fetch(\n makeUrl(\n this.emulators.firestore,\n `/emulator/v1/projects/${this.projectId}/databases/(default)/documents`\n ),\n {\n method: 'DELETE'\n }\n );\n\n if (!resp.ok) {\n throw new Error(await resp.text());\n }\n }\n\n clearStorage(): Promise<void> {\n this.checkNotDestroyed();\n return this.withSecurityRulesDisabled(async context => {\n const { items } = await context.storage().ref().listAll();\n await Promise.all(\n items.map(item => {\n return item.delete();\n })\n );\n });\n }\n\n async cleanup(): Promise<void> {\n this.destroyed = true;\n this.contexts.forEach(context => {\n context.envDestroyed = true;\n context.cleanup();\n });\n this.contexts.clear();\n }\n\n private checkNotDestroyed() {\n if (this.destroyed) {\n throw new Error(\n 'This RulesTestEnvironment has already been cleaned up. ' +\n '(This may indicate a leak or missing `await` in your test cases. If you do intend to ' +\n 'perform more tests, please call cleanup() later or create another RulesTestEnvironment.)'\n );\n }\n }\n}\n/**\n * An implementation of {@code RulesTestContext}. This is private to hide the constructor,\n * which should never be directly called by the developer.\n * @private\n */\nclass RulesTestContextImpl implements RulesTestContext {\n private app?: firebase.app.App;\n private destroyed = false;\n envDestroyed = false;\n\n constructor(\n readonly projectId: string,\n readonly emulators: DiscoveredEmulators,\n readonly authToken: firebase.EmulatorMockTokenOptions | string | undefined\n ) {}\n\n cleanup() {\n this.destroyed = true;\n this.app?.delete();\n\n this.app = undefined;\n }\n\n firestore(\n settings?: firebase.firestore.Settings\n ): firebase.firestore.Firestore {\n assertEmulatorRunning(this.emulators, 'firestore');\n const firestore = this.getApp().firestore();\n if (settings) {\n firestore.settings(settings);\n }\n firestore.useEmulator(\n this.emulators.firestore.host,\n this.emulators.firestore.port,\n { mockUserToken: this.authToken }\n );\n return firestore;\n }\n database(databaseURL?: string): firebase.database.Database {\n assertEmulatorRunning(this.emulators, 'database');\n if (!databaseURL) {\n const url = makeUrl(this.emulators.database, '');\n // Make sure to set the namespace equal to projectId -- otherwise the RTDB SDK will by default\n // use `${projectId}-default-rtdb`, which is treated as a different DB by the RTDB emulator\n // (and thus WON'T apply any rules set for the `projectId` DB during initialization).\n url.searchParams.append('ns', this.projectId);\n databaseURL = url.toString();\n }\n const database = this.getApp().database(databaseURL);\n database.useEmulator(\n this.emulators.database.host,\n this.emulators.database.port,\n { mockUserToken: this.authToken }\n );\n return database;\n }\n storage(bucketUrl = `gs://${this.projectId}`): firebase.storage.Storage {\n assertEmulatorRunning(this.emulators, 'storage');\n const storage = this.getApp().storage(bucketUrl);\n storage.useEmulator(\n this.emulators.storage.host,\n this.emulators.storage.port,\n { mockUserToken: this.authToken }\n );\n return storage;\n }\n\n private getApp(): firebase.app.App {\n if (this.envDestroyed) {\n throw new Error(\n 'This RulesTestContext is no longer valid because its RulesTestEnvironment has been ' +\n 'cleaned up. (This may indicate a leak or missing `await` in your test cases.)'\n );\n }\n if (this.destroyed) {\n throw new Error(\n 'This RulesTestContext is no longer valid. When using withSecurityRulesDisabled, ' +\n 'make sure to perform all operations on the context within the callback function and ' +\n 'return a Promise that resolves when the operations are done.'\n );\n }\n if (!this.app) {\n this.app = firebase.initializeApp(\n { projectId: this.projectId },\n `_Firebase_RulesUnitTesting_${Date.now()}_${Math.random()}`\n );\n }\n return this.app;\n }\n}\n\nexport function assertEmulatorRunning<E extends keyof DiscoveredEmulators>(\n emulators: DiscoveredEmulators,\n emulator: E\n): asserts emulators is Record<E, HostAndPort> {\n if (!emulators[emulator]) {\n if (emulators.hub) {\n throw new Error(\n `The ${emulator} emulator is not running (according to Emulator hub). To force ` +\n 'connecting anyway, please specify its host and port in initializeTestEnvironment({...}).'\n );\n } else {\n throw new Error(\n `The host and port of the ${emulator} emulator must be specified. (You may wrap the test ` +\n \"script with `firebase emulators:exec './your-test-script'` to enable automatic \" +\n `discovery, or specify manually via initializeTestEnvironment({${emulator}: {host, port}}).`\n );\n }\n }\n}\n","/**\n * @license\n * Copyright 2021 Google 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 { HostAndPort } from '../public_types';\nimport { makeUrl } from './url';\nimport fetch from 'node-fetch';\n\n/**\n * @private\n */\nexport async function loadDatabaseRules(\n hostAndPort: HostAndPort,\n databaseName: string,\n rules: string\n): Promise<void> {\n const url = makeUrl(hostAndPort, '/.settings/rules.json');\n url.searchParams.append('ns', databaseName);\n const resp = await fetch(url, {\n method: 'PUT',\n headers: { Authorization: 'Bearer owner' },\n body: rules\n });\n\n if (!resp.ok) {\n throw new Error(await resp.text());\n }\n}\n\n/**\n * @private\n */\nexport async function loadFirestoreRules(\n hostAndPort: HostAndPort,\n projectId: string,\n rules: string\n): Promise<void> {\n const resp = await fetch(\n makeUrl(hostAndPort, `/emulator/v1/projects/${projectId}:securityRules`),\n {\n method: 'PUT',\n body: JSON.stringify({\n rules: {\n files: [{ content: rules }]\n }\n })\n }\n );\n\n if (!resp.ok) {\n throw new Error(await resp.text());\n }\n}\n\n/**\n * @private\n */\nexport async function loadStorageRules(\n hostAndPort: HostAndPort,\n rules: string\n): Promise<void> {\n const resp = await fetch(makeUrl(hostAndPort, '/internal/setRules'), {\n method: 'PUT',\n headers: {\n 'Content-Type': 'application/json'\n },\n body: JSON.stringify({\n rules: {\n files: [{ name: 'storage.rules', content: rules }]\n }\n })\n });\n if (!resp.ok) {\n throw new Error(await resp.text());\n }\n}\n","/**\n * @license\n * Copyright 2021 Google 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 { RulesTestEnvironment, TestEnvironmentConfig } from './public_types';\nimport {\n DiscoveredEmulators,\n discoverEmulators,\n getEmulatorHostAndPort\n} from './impl/discovery';\nimport {\n assertEmulatorRunning,\n RulesTestEnvironmentImpl\n} from './impl/test_environment';\nimport {\n loadDatabaseRules,\n loadFirestoreRules,\n loadStorageRules\n} from './impl/rules';\n\n/**\n * Initializes a test environment for rules unit testing. Call this function first for test setup.\n *\n * Requires emulators to be running. This function tries to discover those emulators via environment\n * variables or through the Firebase Emulator hub if hosts and ports are unspecified. It is strongly\n * recommended to specify security rules for emulators used for testing. See minimal example below.\n *\n * @param config - the configuration for emulators. Most fields are optional if they can be discovered\n * @returns a promise that resolves with an environment ready for testing, or rejects on error.\n * @public\n * @example\n * ```javascript\n * const testEnv = await initializeTestEnvironment({\n * firestore: {\n * rules: fs.readFileSync(\"/path/to/firestore.rules\", \"utf8\"), // Load rules from file\n * // host and port can be omitted if they can be discovered from the hub.\n * },\n * // ...\n * });\n * ```\n */\nexport async function initializeTestEnvironment(\n config: TestEnvironmentConfig\n): Promise<RulesTestEnvironment> {\n const projectId = config.projectId || process.env.GCLOUD_PROJECT;\n if (!projectId) {\n throw new Error(\n 'Missing projectId option or env var GCLOUD_PROJECT! Please specify the projectId either ' +\n 'way.\\n(A demo-* projectId is strongly recommended for unit tests, such as \"demo-test\".)'\n );\n }\n const hub = getEmulatorHostAndPort('hub', config.hub);\n let discovered = hub ? { ...(await discoverEmulators(hub)), hub } : undefined;\n\n const emulators: DiscoveredEmulators = {};\n if (hub) {\n emulators.hub = hub;\n }\n\n for (const emulator of SUPPORTED_EMULATORS) {\n const hostAndPort = getEmulatorHostAndPort(\n emulator,\n config[emulator],\n discovered\n );\n if (hostAndPort) {\n emulators[emulator] = hostAndPort;\n }\n }\n\n if (config.database?.rules) {\n assertEmulatorRunning(emulators, 'database');\n await loadDatabaseRules(\n emulators.database,\n projectId,\n config.database.rules\n );\n }\n if (config.firestore?.rules) {\n assertEmulatorRunning(emulators, 'firestore');\n await loadFirestoreRules(\n emulators.firestore,\n projectId,\n config.firestore.rules\n );\n }\n if (config.storage?.rules) {\n assertEmulatorRunning(emulators, 'storage');\n await loadStorageRules(emulators.storage, config.storage.rules);\n }\n\n return new RulesTestEnvironmentImpl(projectId, emulators);\n}\n\nconst SUPPORTED_EMULATORS = ['database', 'firestore', 'storage'] as const;\n","/**\n * @license\n * Copyright 2021 Google 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 {\n EMULATOR_HOST_ENV_VARS,\n getEmulatorHostAndPort\n} from './impl/discovery';\nimport { fixHostname, makeUrl } from './impl/url';\nimport { HostAndPort } from './public_types';\nimport fetch from 'node-fetch';\n\n/**\n * Run a setup function with background Cloud Functions triggers disabled. This can be used to\n * import data into the Realtime Database or Cloud Firestore emulator without triggering locally\n * emulated Cloud Functions.\n *\n * This method only works with Firebase CLI version 8.13.0 or higher. This overload works only if\n * the Emulator hub host:port is specified by the environment variable FIREBASE_EMULATOR_HUB.\n *\n * @param fn - a function which may be sync or async (returns a promise)\n * @public\n */\nexport async function withFunctionTriggersDisabled<TResult>(\n fn: () => TResult | Promise<TResult>\n): Promise<TResult>;\n\n/**\n * Run a setup function with background Cloud Functions triggers disabled. This can be used to\n * import data into the Realtime Database or Cloud Firestore emulator without triggering locally\n * emulated Cloud Functions.\n *\n * This method only works with Firebase CLI version 8.13.0 or higher. The Emulator hub must be\n * running, which host and port are specified in this overload.\n *\n * @param fn - a function which may be sync or async (returns a promise)\n * @param hub - the host and port of the Emulator Hub (ex: `{host: 'localhost', port: 4400}`)\n * @public\n */\nexport async function withFunctionTriggersDisabled<TResult>(\n hub: { host: string; port: number },\n fn: () => TResult | Promise<TResult>\n): Promise<TResult>;\n\nexport async function withFunctionTriggersDisabled<TResult>(\n fnOrHub: { host: string; port: number } | (() => TResult | Promise<TResult>),\n maybeFn?: () => TResult | Promise<TResult>\n): Promise<TResult> {\n let hub: HostAndPort | undefined;\n if (typeof fnOrHub === 'function') {\n maybeFn = fnOrHub;\n hub = getEmulatorHostAndPort('hub');\n } else {\n hub = getEmulatorHostAndPort('hub', fnOrHub);\n if (!maybeFn) {\n throw new Error('The callback function must be specified!');\n }\n }\n if (!hub) {\n throw new Error(\n 'Please specify the Emulator Hub host and port via arguments or set the environment ' +\n `varible ${EMULATOR_HOST_ENV_VARS.hub}!`\n );\n }\n\n hub.host = fixHostname(hub.host);\n makeUrl(hub, '/functions/disableBackgroundTriggers');\n // Disable background triggers\n const disableRes = await fetch(\n makeUrl(hub, '/functions/disableBackgroundTriggers'),\n {\n method: 'PUT'\n }\n );\n if (!disableRes.ok) {\n throw new Error(\n `HTTP Error ${disableRes.status} when disabling functions triggers, are you using firebase-tools 8.13.0 or higher?`\n );\n }\n\n // Run the user's function\n let result: TResult | undefined = undefined;\n try {\n result = await maybeFn();\n } finally {\n // Re-enable background triggers\n const enableRes = await fetch(\n makeUrl(hub, '/functions/enableBackgroundTriggers'),\n {\n method: 'PUT'\n }\n );\n\n if (!enableRes.ok) {\n throw new Error(\n `HTTP Error ${enableRes.status} when enabling functions triggers, are you using firebase-tools 8.13.0 or higher?`\n );\n }\n }\n\n // Return the user's function result\n return result;\n}\n\n/**\n * Assert the promise to be rejected with a \"permission denied\" error.\n *\n * Useful to assert a certain request to be denied by Security Rules. See example below.\n * This function recognizes permission-denied errors from Database, Firestore, and Storage JS SDKs.\n *\n * @param pr - the promise to be asserted\n * @returns a Promise that is fulfilled if pr is rejected with \"permission denied\". If pr is\n * rejected with any other error or resolved, the returned promise rejects.\n * @public\n * @example\n * ```javascript\n * const unauthed = testEnv.unauthenticatedContext();\n * await assertFails(get(doc(unauthed.firestore(), '/private/doc'), { ... });\n * ```\n */\nexport function assertFails(pr: Promise<any>): Promise<any> {\n return pr.then(\n () => {\n return Promise.reject(\n new Error('Expected request to fail, but it succeeded.')\n );\n },\n (err: any) => {\n const errCode = err?.code?.toLowerCase() || '';\n const errMessage = err?.message?.toLowerCase() || '';\n const isPermissionDenied =\n errCode === 'permission-denied' ||\n errCode === 'permission_denied' ||\n errMessage.indexOf('permission_denied') >= 0 ||\n errMessage.indexOf('permission denied') >= 0 ||\n // Storage permission errors contain message: (storage/unauthorized)\n errMessage.indexOf('unauthorized') >= 0;\n\n if (!isPermissionDenied) {\n return Promise.reject(\n new Error(\n `Expected PERMISSION_DENIED but got unexpected error: ${err}`\n )\n );\n }\n return err;\n }\n );\n}\n\n/**\n * Assert the promise to be successful.\n *\n * This is a no-op function returning the passed promise as-is, but can be used for documentational\n * purposes in test code to emphasize that a certain request should succeed (e.g. allowed by rules).\n *\n * @public\n * @example\n * ```javascript\n * const alice = testEnv.authenticatedContext('alice');\n * await assertSucceeds(get(doc(alice.firestore(), '/doc/readable/by/alice'), { ... });\n * ```\n */\nexport function assertSucceeds<T>(pr: Promise<T>): Promise<T> {\n return pr;\n}\n"],"names":["nodeFetch","fetch","firebase"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;AAeG;AAIH;;;;;;;;AAQG;AACa,SAAA,WAAW,CAAC,IAAY,EAAE,YAAqB,EAAA;AAC7D,IAAA,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IAC9C,IAAI,IAAI,KAAK,SAAS,EAAE;AACtB,QAAA,IAAI,GAAG,YAAY,IAAI,WAAW,CAAC;AACpC,KAAA;SAAM,IAAI,IAAI,KAAK,IAAI,EAAE;AACxB,QAAA,IAAI,GAAG,YAAY,IAAI,KAAK,CAAC;AAC9B,KAAA;AACD,IAAA,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;AAGG;AACa,SAAA,OAAO,CAAC,WAAiC,EAAE,IAAY,EAAA;AACrE,IAAA,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE;QAC3B,IAAA,IAAI,GAAW,WAAW,CAAA,IAAtB,EAAE,IAAI,GAAK,WAAW,CAAA,IAAhB,CAAiB;AACnC,QAAA,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;AACtB,YAAA,WAAW,GAAG,GAAI,CAAA,MAAA,CAAA,IAAI,EAAK,IAAA,CAAA,CAAA,MAAA,CAAA,IAAI,CAAE,CAAC;AACnC,SAAA;AAAM,aAAA;AACL,YAAA,WAAW,GAAG,EAAG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3
- "version": "2.0.4",
3
+ "version": "2.0.5-canary.457fc2eeb",
4
4
  "description": "",
5
5
  "author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)",
6
6
  "main": "dist/index.cjs.js",
@@ -34,11 +34,11 @@
34
34
  },
35
35
  "license": "Apache-2.0",
36
36
  "devDependencies": {
37
- "rollup": "2.72.1",
37
+ "rollup": "2.79.1",
38
38
  "rollup-plugin-typescript2": "0.31.2"
39
39
  },
40
40
  "peerDependencies": {
41
- "firebase": "^9.0.0"
41
+ "firebase": "9.13.0-canary.457fc2eeb"
42
42
  },
43
43
  "repository": {
44
44
  "directory": "packages/rules-unit-testing",