index.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*! firebase-admin v12.1.1 */
  2. "use strict";
  3. /*!
  4. * Copyright 2020 Google Inc.
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the "License");
  7. * you may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. Object.defineProperty(exports, "__esModule", { value: true });
  19. exports.getSecurityRules = exports.SecurityRules = exports.RulesetMetadataList = exports.Ruleset = void 0;
  20. /**
  21. * Security Rules for Cloud Firestore and Cloud Storage.
  22. *
  23. * @packageDocumentation
  24. */
  25. const app_1 = require("../app");
  26. const security_rules_1 = require("./security-rules");
  27. var security_rules_2 = require("./security-rules");
  28. Object.defineProperty(exports, "Ruleset", { enumerable: true, get: function () { return security_rules_2.Ruleset; } });
  29. Object.defineProperty(exports, "RulesetMetadataList", { enumerable: true, get: function () { return security_rules_2.RulesetMetadataList; } });
  30. Object.defineProperty(exports, "SecurityRules", { enumerable: true, get: function () { return security_rules_2.SecurityRules; } });
  31. /**
  32. * Gets the {@link SecurityRules} service for the default app or a given app.
  33. *
  34. * `admin.securityRules()` can be called with no arguments to access the
  35. * default app's `SecurityRules` service, or as `admin.securityRules(app)` to access
  36. * the `SecurityRules` service associated with a specific app.
  37. *
  38. * @example
  39. * ```javascript
  40. * // Get the SecurityRules service for the default app
  41. * const defaultSecurityRules = getSecurityRules();
  42. * ```
  43. *
  44. * @example
  45. * ```javascript
  46. * // Get the SecurityRules service for a given app
  47. * const otherSecurityRules = getSecurityRules(otherApp);
  48. * ```
  49. *
  50. * @param app - Optional app to return the `SecurityRules` service
  51. * for. If not provided, the default `SecurityRules` service
  52. * is returned.
  53. * @returns The default `SecurityRules` service if no app is provided, or the
  54. * `SecurityRules` service associated with the provided app.
  55. */
  56. function getSecurityRules(app) {
  57. if (typeof app === 'undefined') {
  58. app = (0, app_1.getApp)();
  59. }
  60. const firebaseApp = app;
  61. return firebaseApp.getOrInitService('securityRules', (app) => new security_rules_1.SecurityRules(app));
  62. }
  63. exports.getSecurityRules = getSecurityRules;