firebase-admin 9.12.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 (84) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +90 -0
  3. package/lib/app-check/app-check-api-client-internal.js +197 -0
  4. package/lib/app-check/app-check.js +79 -0
  5. package/lib/app-check/index.d.ts +160 -0
  6. package/lib/app-check/index.js +19 -0
  7. package/lib/app-check/token-generator.js +161 -0
  8. package/lib/app-check/token-verifier.js +152 -0
  9. package/lib/auth/action-code-settings-builder.js +118 -0
  10. package/lib/auth/auth-api-request.js +1856 -0
  11. package/lib/auth/auth-config.js +636 -0
  12. package/lib/auth/auth.js +836 -0
  13. package/lib/auth/identifier.js +40 -0
  14. package/lib/auth/index.d.ts +1927 -0
  15. package/lib/auth/index.js +18 -0
  16. package/lib/auth/tenant-manager.js +140 -0
  17. package/lib/auth/tenant.js +171 -0
  18. package/lib/auth/token-generator.js +200 -0
  19. package/lib/auth/token-verifier.js +259 -0
  20. package/lib/auth/user-import-builder.js +387 -0
  21. package/lib/auth/user-record.js +346 -0
  22. package/lib/credential/credential-internal.js +391 -0
  23. package/lib/credential/credential.js +44 -0
  24. package/lib/credential/index.d.ts +169 -0
  25. package/lib/credential/index.js +23 -0
  26. package/lib/database/database-internal.js +266 -0
  27. package/lib/database/index.d.ts +89 -0
  28. package/lib/database/index.js +31 -0
  29. package/lib/default-namespace.js +31 -0
  30. package/lib/firebase-app.js +349 -0
  31. package/lib/firebase-namespace-api.d.ts +243 -0
  32. package/lib/firebase-namespace-api.js +18 -0
  33. package/lib/firebase-namespace.d.ts +31 -0
  34. package/lib/firebase-namespace.js +417 -0
  35. package/lib/firestore/firestore-internal.js +105 -0
  36. package/lib/firestore/index.d.ts +50 -0
  37. package/lib/firestore/index.js +47 -0
  38. package/lib/index.d.ts +24 -0
  39. package/lib/index.js +27 -0
  40. package/lib/installations/index.d.ts +81 -0
  41. package/lib/installations/index.js +18 -0
  42. package/lib/installations/installations-request-handler.js +117 -0
  43. package/lib/installations/installations.js +62 -0
  44. package/lib/instance-id/index.d.ts +83 -0
  45. package/lib/instance-id/index.js +18 -0
  46. package/lib/instance-id/instance-id.js +87 -0
  47. package/lib/machine-learning/index.d.ts +249 -0
  48. package/lib/machine-learning/index.js +18 -0
  49. package/lib/machine-learning/machine-learning-api-client.js +304 -0
  50. package/lib/machine-learning/machine-learning-utils.js +62 -0
  51. package/lib/machine-learning/machine-learning.js +364 -0
  52. package/lib/messaging/batch-request-internal.js +129 -0
  53. package/lib/messaging/index.d.ts +1174 -0
  54. package/lib/messaging/index.js +18 -0
  55. package/lib/messaging/messaging-api-request-internal.js +128 -0
  56. package/lib/messaging/messaging-errors-internal.js +106 -0
  57. package/lib/messaging/messaging-internal.js +484 -0
  58. package/lib/messaging/messaging.js +846 -0
  59. package/lib/project-management/android-app.js +176 -0
  60. package/lib/project-management/index.d.ts +363 -0
  61. package/lib/project-management/index.js +41 -0
  62. package/lib/project-management/ios-app.js +88 -0
  63. package/lib/project-management/project-management-api-request-internal.js +273 -0
  64. package/lib/project-management/project-management.js +254 -0
  65. package/lib/remote-config/index.d.ts +369 -0
  66. package/lib/remote-config/index.js +18 -0
  67. package/lib/remote-config/remote-config-api-client-internal.js +407 -0
  68. package/lib/remote-config/remote-config.js +304 -0
  69. package/lib/security-rules/index.d.ts +216 -0
  70. package/lib/security-rules/index.js +18 -0
  71. package/lib/security-rules/security-rules-api-client-internal.js +237 -0
  72. package/lib/security-rules/security-rules-internal.js +41 -0
  73. package/lib/security-rules/security-rules.js +310 -0
  74. package/lib/storage/index.d.ts +60 -0
  75. package/lib/storage/index.js +18 -0
  76. package/lib/storage/storage.js +123 -0
  77. package/lib/utils/api-request.js +845 -0
  78. package/lib/utils/crypto-signer.js +237 -0
  79. package/lib/utils/deep-copy.js +78 -0
  80. package/lib/utils/error.js +1063 -0
  81. package/lib/utils/index.js +217 -0
  82. package/lib/utils/jwt.js +355 -0
  83. package/lib/utils/validator.js +271 -0
  84. package/package.json +122 -0
@@ -0,0 +1,123 @@
1
+ /*! firebase-admin v9.12.0 */
2
+ "use strict";
3
+ /*!
4
+ * @license
5
+ * Copyright 2017 Google Inc.
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.Storage = void 0;
21
+ var error_1 = require("../utils/error");
22
+ var credential_internal_1 = require("../credential/credential-internal");
23
+ var utils = require("../utils/index");
24
+ var validator = require("../utils/validator");
25
+ /**
26
+ * The default `Storage` service if no
27
+ * app is provided or the `Storage` service associated with the provided
28
+ * app.
29
+ */
30
+ var Storage = /** @class */ (function () {
31
+ /**
32
+ * @param {FirebaseApp} app The app for this Storage service.
33
+ * @constructor
34
+ * @internal
35
+ */
36
+ function Storage(app) {
37
+ if (!validator.isNonNullObject(app) || !('options' in app)) {
38
+ throw new error_1.FirebaseError({
39
+ code: 'storage/invalid-argument',
40
+ message: 'First argument passed to admin.storage() must be a valid Firebase app instance.',
41
+ });
42
+ }
43
+ if (!process.env.STORAGE_EMULATOR_HOST && process.env.FIREBASE_STORAGE_EMULATOR_HOST) {
44
+ var firebaseStorageEmulatorHost = process.env.FIREBASE_STORAGE_EMULATOR_HOST;
45
+ if (firebaseStorageEmulatorHost.match(/https?:\/\//)) {
46
+ throw new error_1.FirebaseError({
47
+ code: 'storage/invalid-emulator-host',
48
+ message: 'FIREBASE_STORAGE_EMULATOR_HOST should not contain a protocol (http or https).',
49
+ });
50
+ }
51
+ process.env.STORAGE_EMULATOR_HOST = "http://" + process.env.FIREBASE_STORAGE_EMULATOR_HOST;
52
+ }
53
+ var storage;
54
+ try {
55
+ storage = require('@google-cloud/storage').Storage;
56
+ }
57
+ catch (err) {
58
+ throw new error_1.FirebaseError({
59
+ code: 'storage/missing-dependencies',
60
+ message: 'Failed to import the Cloud Storage client library for Node.js. '
61
+ + 'Make sure to install the "@google-cloud/storage" npm package. '
62
+ + ("Original error: " + err),
63
+ });
64
+ }
65
+ var projectId = utils.getExplicitProjectId(app);
66
+ var credential = app.options.credential;
67
+ if (credential instanceof credential_internal_1.ServiceAccountCredential) {
68
+ this.storageClient = new storage({
69
+ // When the SDK is initialized with ServiceAccountCredentials an explicit projectId is
70
+ // guaranteed to be available.
71
+ projectId: projectId,
72
+ credentials: {
73
+ private_key: credential.privateKey,
74
+ client_email: credential.clientEmail,
75
+ },
76
+ });
77
+ }
78
+ else if (credential_internal_1.isApplicationDefault(app.options.credential)) {
79
+ // Try to use the Google application default credentials.
80
+ this.storageClient = new storage();
81
+ }
82
+ else {
83
+ throw new error_1.FirebaseError({
84
+ code: 'storage/invalid-credential',
85
+ message: 'Failed to initialize Google Cloud Storage client with the available credential. ' +
86
+ 'Must initialize the SDK with a certificate credential or application default credentials ' +
87
+ 'to use Cloud Storage API.',
88
+ });
89
+ }
90
+ this.appInternal = app;
91
+ }
92
+ /**
93
+ * @param name Optional name of the bucket to be retrieved. If name is not specified,
94
+ * retrieves a reference to the default bucket.
95
+ * @returns A [Bucket](https://cloud.google.com/nodejs/docs/reference/storage/latest/Bucket)
96
+ * instance as defined in the `@google-cloud/storage` package.
97
+ */
98
+ Storage.prototype.bucket = function (name) {
99
+ var bucketName = (typeof name !== 'undefined')
100
+ ? name : this.appInternal.options.storageBucket;
101
+ if (validator.isNonEmptyString(bucketName)) {
102
+ return this.storageClient.bucket(bucketName);
103
+ }
104
+ throw new error_1.FirebaseError({
105
+ code: 'storage/invalid-argument',
106
+ message: 'Bucket name not specified or invalid. Specify a valid bucket name via the ' +
107
+ 'storageBucket option when initializing the app, or specify the bucket name ' +
108
+ 'explicitly when calling the getBucket() method.',
109
+ });
110
+ };
111
+ Object.defineProperty(Storage.prototype, "app", {
112
+ /**
113
+ * @return The app associated with this Storage instance.
114
+ */
115
+ get: function () {
116
+ return this.appInternal;
117
+ },
118
+ enumerable: false,
119
+ configurable: true
120
+ });
121
+ return Storage;
122
+ }());
123
+ exports.Storage = Storage;