index.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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.credential = void 0;
  20. const index_1 = require("../app/index");
  21. /* eslint-disable @typescript-eslint/no-namespace */
  22. var credential;
  23. (function (credential) {
  24. /**
  25. * Returns a credential created from the
  26. * {@link https://developers.google.com/identity/protocols/application-default-credentials |
  27. * Google Application Default Credentials}
  28. * that grants admin access to Firebase services. This credential can be used
  29. * in the call to {@link firebase-admin.app#initializeApp}.
  30. *
  31. * Google Application Default Credentials are available on any Google
  32. * infrastructure, such as Google App Engine and Google Compute Engine.
  33. *
  34. * See
  35. * {@link https://firebase.google.com/docs/admin/setup#initialize_the_sdk | Initialize the SDK}
  36. * for more details.
  37. *
  38. * @example
  39. * ```javascript
  40. * admin.initializeApp({
  41. * credential: admin.credential.applicationDefault(),
  42. * databaseURL: "https://<DATABASE_NAME>.firebaseio.com"
  43. * });
  44. * ```
  45. *
  46. * @param httpAgent - Optional {@link https://nodejs.org/api/http.html#http_class_http_agent | HTTP Agent}
  47. * to be used when retrieving access tokens from Google token servers.
  48. *
  49. * @returns A credential authenticated via Google
  50. * Application Default Credentials that can be used to initialize an app.
  51. */
  52. credential.applicationDefault = index_1.applicationDefault;
  53. /**
  54. * Returns a credential created from the provided service account that grants
  55. * admin access to Firebase services. This credential can be used in the call
  56. * to {@link firebase-admin.app#initializeApp}.
  57. *
  58. * See
  59. * {@link https://firebase.google.com/docs/admin/setup#initialize_the_sdk | Initialize the SDK}
  60. * for more details.
  61. *
  62. * @example
  63. * ```javascript
  64. * // Providing a path to a service account key JSON file
  65. * var serviceAccount = require("path/to/serviceAccountKey.json");
  66. * admin.initializeApp({
  67. * credential: admin.credential.cert(serviceAccount),
  68. * databaseURL: "https://<DATABASE_NAME>.firebaseio.com"
  69. * });
  70. * ```
  71. *
  72. * @example
  73. * ```javascript
  74. * // Providing a service account object inline
  75. * admin.initializeApp({
  76. * credential: admin.credential.cert({
  77. * projectId: "<PROJECT_ID>",
  78. * clientEmail: "foo@<PROJECT_ID>.iam.gserviceaccount.com",
  79. * privateKey: "-----BEGIN PRIVATE KEY-----<KEY>-----END PRIVATE KEY-----\n"
  80. * }),
  81. * databaseURL: "https://<DATABASE_NAME>.firebaseio.com"
  82. * });
  83. * ```
  84. *
  85. * @param serviceAccountPathOrObject - The path to a service
  86. * account key JSON file or an object representing a service account key.
  87. * @param httpAgent - Optional {@link https://nodejs.org/api/http.html#http_class_http_agent | HTTP Agent}
  88. * to be used when retrieving access tokens from Google token servers.
  89. *
  90. * @returns A credential authenticated via the
  91. * provided service account that can be used to initialize an app.
  92. */
  93. credential.cert = index_1.cert;
  94. /**
  95. * Returns a credential created from the provided refresh token that grants
  96. * admin access to Firebase services. This credential can be used in the call
  97. * to {@link firebase-admin.app#initializeApp}.
  98. *
  99. * See
  100. * {@link https://firebase.google.com/docs/admin/setup#initialize_the_sdk | Initialize the SDK}
  101. * for more details.
  102. *
  103. * @example
  104. * ```javascript
  105. * // Providing a path to a refresh token JSON file
  106. * var refreshToken = require("path/to/refreshToken.json");
  107. * admin.initializeApp({
  108. * credential: admin.credential.refreshToken(refreshToken),
  109. * databaseURL: "https://<DATABASE_NAME>.firebaseio.com"
  110. * });
  111. * ```
  112. *
  113. * @param refreshTokenPathOrObject - The path to a Google
  114. * OAuth2 refresh token JSON file or an object representing a Google OAuth2
  115. * refresh token.
  116. * @param httpAgent - Optional {@link https://nodejs.org/api/http.html#http_class_http_agent | HTTP Agent}
  117. * to be used when retrieving access tokens from Google token servers.
  118. *
  119. * @returns A credential authenticated via the
  120. * provided service account that can be used to initialize an app.
  121. */
  122. credential.refreshToken = index_1.refreshToken;
  123. })(credential || (exports.credential = credential = {}));