firebase-functions 3.21.0 → 3.22.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 (66) hide show
  1. package/lib/bin/firebase-functions.js +21 -0
  2. package/lib/cloud-functions.d.ts +54 -88
  3. package/lib/cloud-functions.js +2 -59
  4. package/lib/common/change.d.ts +46 -0
  5. package/lib/common/change.js +82 -0
  6. package/lib/common/encoding.js +21 -1
  7. package/lib/common/providers/database.d.ts +145 -0
  8. package/lib/common/providers/database.js +271 -0
  9. package/lib/common/providers/https.d.ts +37 -17
  10. package/lib/common/providers/https.js +3 -0
  11. package/lib/common/providers/identity.d.ts +5 -1
  12. package/lib/common/providers/identity.js +12 -4
  13. package/lib/common/providers/tasks.d.ts +9 -0
  14. package/lib/common/providers/tasks.js +13 -12
  15. package/lib/function-builder.d.ts +3 -3
  16. package/lib/function-builder.js +2 -2
  17. package/lib/logger/common.js +21 -0
  18. package/lib/logger/compat.js +21 -0
  19. package/lib/logger/index.d.ts +14 -6
  20. package/lib/logger/index.js +33 -6
  21. package/lib/providers/auth.d.ts +26 -5
  22. package/lib/providers/auth.js +18 -4
  23. package/lib/providers/database.d.ts +4 -146
  24. package/lib/providers/database.js +7 -251
  25. package/lib/providers/firestore.d.ts +2 -1
  26. package/lib/providers/firestore.js +2 -1
  27. package/lib/providers/pubsub.d.ts +6 -6
  28. package/lib/providers/pubsub.js +6 -6
  29. package/lib/providers/tasks.d.ts +29 -14
  30. package/lib/providers/tasks.js +10 -3
  31. package/lib/utilities/path-pattern.d.ts +1 -0
  32. package/lib/utilities/path-pattern.js +142 -0
  33. package/lib/v2/core.d.ts +25 -1
  34. package/lib/v2/core.js +7 -0
  35. package/lib/v2/index.d.ts +11 -3
  36. package/lib/v2/index.js +12 -3
  37. package/lib/v2/options.d.ts +13 -34
  38. package/lib/v2/options.js +6 -58
  39. package/lib/v2/params/index.d.ts +4 -1
  40. package/lib/v2/params/index.js +25 -1
  41. package/lib/v2/params/types.js +21 -0
  42. package/lib/v2/providers/alerts/alerts.d.ts +94 -3
  43. package/lib/v2/providers/alerts/alerts.js +23 -7
  44. package/lib/v2/providers/alerts/appDistribution.d.ts +101 -1
  45. package/lib/v2/providers/alerts/appDistribution.js +28 -1
  46. package/lib/v2/providers/alerts/billing.d.ts +23 -2
  47. package/lib/v2/providers/alerts/billing.js +37 -0
  48. package/lib/v2/providers/alerts/crashlytics.d.ts +193 -18
  49. package/lib/v2/providers/alerts/crashlytics.js +62 -1
  50. package/lib/v2/providers/alerts/index.d.ts +6 -0
  51. package/lib/v2/providers/alerts/index.js +27 -0
  52. package/lib/v2/providers/database.d.ts +182 -0
  53. package/lib/v2/providers/database.js +204 -0
  54. package/lib/v2/providers/eventarc.d.ts +89 -5
  55. package/lib/v2/providers/eventarc.js +4 -0
  56. package/lib/v2/providers/https.d.ts +123 -2
  57. package/lib/v2/providers/https.js +13 -3
  58. package/lib/v2/providers/identity.d.ts +108 -4
  59. package/lib/v2/providers/identity.js +33 -2
  60. package/lib/v2/providers/pubsub.d.ts +122 -5
  61. package/lib/v2/providers/pubsub.js +58 -2
  62. package/lib/v2/providers/storage.d.ts +192 -4
  63. package/lib/v2/providers/storage.js +52 -9
  64. package/lib/v2/providers/tasks.d.ts +106 -6
  65. package/lib/v2/providers/tasks.js +4 -0
  66. package/package.json +12 -6
@@ -0,0 +1,271 @@
1
+ "use strict";
2
+ // The MIT License (MIT)
3
+ //
4
+ // Copyright (c) 2022 Firebase
5
+ //
6
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ // of this software and associated documentation files (the "Software"), to deal
8
+ // in the Software without restriction, including without limitation the rights
9
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ // copies of the Software, and to permit persons to whom the Software is
11
+ // furnished to do so, subject to the following conditions:
12
+ //
13
+ // The above copyright notice and this permission notice shall be included in all
14
+ // copies or substantial portions of the Software.
15
+ //
16
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ // SOFTWARE.
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.DataSnapshot = void 0;
25
+ const _ = require("lodash");
26
+ const path_1 = require("../../utilities/path");
27
+ /**
28
+ * Interface representing a Firebase Realtime Database data snapshot.
29
+ */
30
+ class DataSnapshot {
31
+ constructor(data, path, // path will be undefined for the database root
32
+ app, instance) {
33
+ var _a, _b;
34
+ this.app = app;
35
+ if ((_b = (_a = app === null || app === void 0 ? void 0 : app.options) === null || _a === void 0 ? void 0 : _a.databaseURL) === null || _b === void 0 ? void 0 : _b.startsWith('http:')) {
36
+ // In this case we're dealing with an emulator
37
+ this.instance = app.options.databaseURL;
38
+ }
39
+ else if (instance) {
40
+ // SDK always supplies instance, but user's unit tests may not
41
+ this.instance = instance;
42
+ }
43
+ else if (app) {
44
+ this.instance = app.options.databaseURL;
45
+ }
46
+ else if (process.env.GCLOUD_PROJECT) {
47
+ this.instance =
48
+ 'https://' + process.env.GCLOUD_PROJECT + '.firebaseio.com';
49
+ }
50
+ this._path = path;
51
+ this._data = data;
52
+ }
53
+ /**
54
+ * Returns a [`Reference`](/docs/reference/admin/node/admin.database.Reference)
55
+ * to the Database location where the triggering write occurred. Has
56
+ * full read and write access.
57
+ */
58
+ get ref() {
59
+ if (!this.app) {
60
+ // may be unpopulated in user's unit tests
61
+ throw new Error('Please supply a Firebase app in the constructor for DataSnapshot' +
62
+ ' in order to use the .ref method.');
63
+ }
64
+ if (!this._ref) {
65
+ this._ref = this.app.database(this.instance).ref(this._fullPath());
66
+ }
67
+ return this._ref;
68
+ }
69
+ /**
70
+ * The key (last part of the path) of the location of this `DataSnapshot`.
71
+ *
72
+ * The last token in a Database location is considered its key. For example,
73
+ * "ada" is the key for the `/users/ada/` node. Accessing the key on any
74
+ * `DataSnapshot` will return the key for the location that generated it.
75
+ * However, accessing the key on the root URL of a Database will return `null`.
76
+ */
77
+ get key() {
78
+ const last = _.last((0, path_1.pathParts)(this._fullPath()));
79
+ return !last || last === '' ? null : last;
80
+ }
81
+ /**
82
+ * Extracts a JavaScript value from a `DataSnapshot`.
83
+ *
84
+ * Depending on the data in a `DataSnapshot`, the `val()` method may return a
85
+ * scalar type (string, number, or boolean), an array, or an object. It may also
86
+ * return `null`, indicating that the `DataSnapshot` is empty (contains no
87
+ * data).
88
+ *
89
+ * @return The DataSnapshot's contents as a JavaScript value (Object,
90
+ * Array, string, number, boolean, or `null`).
91
+ */
92
+ val() {
93
+ const parts = (0, path_1.pathParts)(this._childPath);
94
+ const source = this._data;
95
+ const node = _.cloneDeep(parts.length ? _.get(source, parts, null) : source);
96
+ return this._checkAndConvertToArray(node);
97
+ }
98
+ /**
99
+ * Exports the entire contents of the `DataSnapshot` as a JavaScript object.
100
+ *
101
+ * The `exportVal()` method is similar to `val()`, except priority information
102
+ * is included (if available), making it suitable for backing up your data.
103
+ *
104
+ * @return The contents of the `DataSnapshot` as a JavaScript value
105
+ * (Object, Array, string, number, boolean, or `null`).
106
+ */
107
+ exportVal() {
108
+ return this.val();
109
+ }
110
+ /**
111
+ * Gets the priority value of the data in this `DataSnapshot`.
112
+ *
113
+ * As an alternative to using priority, applications can order collections by
114
+ * ordinary properties. See [Sorting and filtering
115
+ * data](/docs/database/web/lists-of-data#sorting_and_filtering_data).
116
+ *
117
+ * @return The priority value of the data.
118
+ */
119
+ getPriority() {
120
+ return 0;
121
+ }
122
+ /**
123
+ * Returns `true` if this `DataSnapshot` contains any data. It is slightly more
124
+ * efficient than using `snapshot.val() !== null`.
125
+ *
126
+ * @return `true` if this `DataSnapshot` contains any data; otherwise, `false`.
127
+ */
128
+ exists() {
129
+ return !_.isNull(this.val());
130
+ }
131
+ /**
132
+ * Gets a `DataSnapshot` for the location at the specified relative path.
133
+ *
134
+ * The relative path can either be a simple child name (for example, "ada") or
135
+ * a deeper slash-separated path (for example, "ada/name/first").
136
+ *
137
+ * @param path A relative path from this location to the desired child
138
+ * location.
139
+ * @return The specified child location.
140
+ */
141
+ child(childPath) {
142
+ if (!childPath) {
143
+ return this;
144
+ }
145
+ return this._dup(childPath);
146
+ }
147
+ /**
148
+ * Enumerates the `DataSnapshot`s of the children items.
149
+ *
150
+ * Because of the way JavaScript objects work, the ordering of data in the
151
+ * JavaScript object returned by `val()` is not guaranteed to match the ordering
152
+ * on the server nor the ordering of `child_added` events. That is where
153
+ * `forEach()` comes in handy. It guarantees the children of a `DataSnapshot`
154
+ * will be iterated in their query order.
155
+ *
156
+ * If no explicit `orderBy*()` method is used, results are returned
157
+ * ordered by key (unless priorities are used, in which case, results are
158
+ * returned by priority).
159
+ *
160
+ * @param action A function that will be called for each child `DataSnapshot`.
161
+ * The callback can return `true` to cancel further enumeration.
162
+ *
163
+ * @return `true` if enumeration was canceled due to your callback
164
+ * returning `true`.
165
+ */
166
+ forEach(action) {
167
+ const val = this.val();
168
+ if (_.isPlainObject(val)) {
169
+ return _.some(val, (value, key) => action(this.child(key)) === true);
170
+ }
171
+ return false;
172
+ }
173
+ /**
174
+ * Returns `true` if the specified child path has (non-`null`) data.
175
+ *
176
+ * @param path A relative path to the location of a potential child.
177
+ * @return `true` if data exists at the specified child path; otherwise,
178
+ * `false`.
179
+ */
180
+ hasChild(childPath) {
181
+ return this.child(childPath).exists();
182
+ }
183
+ /**
184
+ * Returns whether or not the `DataSnapshot` has any non-`null` child
185
+ * properties.
186
+ *
187
+ * You can use `hasChildren()` to determine if a `DataSnapshot` has any
188
+ * children. If it does, you can enumerate them using `forEach()`. If it
189
+ * doesn't, then either this snapshot contains a primitive value (which can be
190
+ * retrieved with `val()`) or it is empty (in which case, `val()` will return
191
+ * `null`).
192
+ *
193
+ * @return `true` if this snapshot has any children; else `false`.
194
+ */
195
+ hasChildren() {
196
+ const val = this.val();
197
+ return _.isPlainObject(val) && _.keys(val).length > 0;
198
+ }
199
+ /**
200
+ * Returns the number of child properties of this `DataSnapshot`.
201
+ *
202
+ * @return Number of child properties of this `DataSnapshot`.
203
+ */
204
+ numChildren() {
205
+ const val = this.val();
206
+ return _.isPlainObject(val) ? Object.keys(val).length : 0;
207
+ }
208
+ /**
209
+ * Returns a JSON-serializable representation of this object.
210
+ *
211
+ * @return A JSON-serializable representation of this object.
212
+ */
213
+ toJSON() {
214
+ return this.val();
215
+ }
216
+ /** Recursive function to check if keys are numeric & convert node object to array if they are
217
+ *
218
+ * @hidden
219
+ */
220
+ _checkAndConvertToArray(node) {
221
+ if (node === null || typeof node === 'undefined') {
222
+ return null;
223
+ }
224
+ if (typeof node !== 'object') {
225
+ return node;
226
+ }
227
+ const obj = {};
228
+ let numKeys = 0;
229
+ let maxKey = 0;
230
+ let allIntegerKeys = true;
231
+ for (const key in node) {
232
+ if (!node.hasOwnProperty(key)) {
233
+ continue;
234
+ }
235
+ const childNode = node[key];
236
+ obj[key] = this._checkAndConvertToArray(childNode);
237
+ numKeys++;
238
+ const integerRegExp = /^(0|[1-9]\d*)$/;
239
+ if (allIntegerKeys && integerRegExp.test(key)) {
240
+ maxKey = Math.max(maxKey, Number(key));
241
+ }
242
+ else {
243
+ allIntegerKeys = false;
244
+ }
245
+ }
246
+ if (allIntegerKeys && maxKey < 2 * numKeys) {
247
+ // convert to array.
248
+ const array = [];
249
+ _.forOwn(obj, (val, key) => {
250
+ array[key] = val;
251
+ });
252
+ return array;
253
+ }
254
+ return obj;
255
+ }
256
+ /** @hidden */
257
+ _dup(childPath) {
258
+ const dup = new DataSnapshot(this._data, undefined, this.app, this.instance);
259
+ [dup._path, dup._childPath] = [this._path, this._childPath];
260
+ if (childPath) {
261
+ dup._childPath = (0, path_1.joinPath)(dup._childPath, childPath);
262
+ }
263
+ return dup;
264
+ }
265
+ /** @hidden */
266
+ _fullPath() {
267
+ const out = (this._path || '') + '/' + (this._childPath || '');
268
+ return out;
269
+ }
270
+ }
271
+ exports.DataSnapshot = DataSnapshot;
@@ -4,6 +4,7 @@ import * as firebase from 'firebase-admin';
4
4
  import { TaskContext } from './tasks';
5
5
  /** @hidden */
6
6
  export interface Request extends express.Request {
7
+ /** The wire format representation of the request body. */
7
8
  rawBody: Buffer;
8
9
  }
9
10
  interface DecodedAppCheckToken {
@@ -114,37 +115,53 @@ export interface CallableRequest<T = any> {
114
115
  * https://github.com/grpc/grpc/blob/master/doc/statuscodes.md
115
116
  *
116
117
  * Possible values:
117
- * - 'cancelled': The operation was cancelled (typically by the caller).
118
- * - 'unknown': Unknown error or an error from a different error domain.
119
- * - 'invalid-argument': Client specified an invalid argument. Note that this
120
- * differs from 'failed-precondition'. 'invalid-argument' indicates
118
+ *
119
+ * - `cancelled`: The operation was cancelled (typically by the caller).
120
+ *
121
+ * - `unknown`: Unknown error or an error from a different error domain.
122
+ *
123
+ * - `invalid-argument`: Client specified an invalid argument. Note that this
124
+ * differs from `failed-precondition`. `invalid-argument` indicates
121
125
  * arguments that are problematic regardless of the state of the system
122
126
  * (e.g. an invalid field name).
123
- * - 'deadline-exceeded': Deadline expired before operation could complete.
127
+ *
128
+ * - `deadline-exceeded`: Deadline expired before operation could complete.
124
129
  * For operations that change the state of the system, this error may be
125
130
  * returned even if the operation has completed successfully. For example,
126
131
  * a successful response from a server could have been delayed long enough
127
132
  * for the deadline to expire.
128
- * - 'not-found': Some requested document was not found.
129
- * - 'already-exists': Some document that we attempted to create already
133
+ *
134
+ * - `not-found`: Some requested document was not found.
135
+ *
136
+ * - `already-exists`: Some document that we attempted to create already
130
137
  * exists.
131
- * - 'permission-denied': The caller does not have permission to execute the
138
+ *
139
+ * - `permission-denied`: The caller does not have permission to execute the
132
140
  * specified operation.
133
- * - 'resource-exhausted': Some resource has been exhausted, perhaps a
141
+ *
142
+ * - `resource-exhausted`: Some resource has been exhausted, perhaps a
134
143
  * per-user quota, or perhaps the entire file system is out of space.
135
- * - 'failed-precondition': Operation was rejected because the system is not
144
+ *
145
+ * - `failed-precondition`: Operation was rejected because the system is not
136
146
  * in a state required for the operation's execution.
137
- * - 'aborted': The operation was aborted, typically due to a concurrency
147
+ *
148
+ * - `aborted`: The operation was aborted, typically due to a concurrency
138
149
  * issue like transaction aborts, etc.
139
- * - 'out-of-range': Operation was attempted past the valid range.
140
- * - 'unimplemented': Operation is not implemented or not supported/enabled.
141
- * - 'internal': Internal errors. Means some invariants expected by
150
+ *
151
+ * - `out-of-range`: Operation was attempted past the valid range.
152
+ *
153
+ * - `unimplemented`: Operation is not implemented or not supported/enabled.
154
+ *
155
+ * - `internal`: Internal errors. Means some invariants expected by
142
156
  * underlying system has been broken. If you see one of these errors,
143
157
  * something is very broken.
144
- * - 'unavailable': The service is currently unavailable. This is most likely
158
+ *
159
+ * - `unavailable`: The service is currently unavailable. This is most likely
145
160
  * a transient condition and may be corrected by retrying with a backoff.
146
- * - 'data-loss': Unrecoverable data loss or corruption.
147
- * - 'unauthenticated': The request does not have valid authentication
161
+ *
162
+ * - `data-loss`: Unrecoverable data loss or corruption.
163
+ *
164
+ * - `unauthenticated`: The request does not have valid authentication
148
165
  * credentials for the operation.
149
166
  */
150
167
  export declare type FunctionsErrorCode = 'ok' | 'cancelled' | 'unknown' | 'invalid-argument' | 'deadline-exceeded' | 'not-found' | 'already-exists' | 'permission-denied' | 'resource-exhausted' | 'failed-precondition' | 'aborted' | 'out-of-range' | 'unimplemented' | 'internal' | 'unavailable' | 'data-loss' | 'unauthenticated';
@@ -182,6 +199,9 @@ export declare class HttpsError extends Error {
182
199
  */
183
200
  readonly httpErrorCode: HttpErrorCode;
184
201
  constructor(code: FunctionsErrorCode, message: string, details?: unknown);
202
+ /**
203
+ * Returns a JSON-serializable representation of this object.
204
+ */
185
205
  toJSON(): HttpErrorWireFormat;
186
206
  }
187
207
  /** @hidden */
@@ -72,6 +72,9 @@ class HttpsError extends Error {
72
72
  this.details = details;
73
73
  this.httpErrorCode = errorCodeMap[code];
74
74
  }
75
+ /**
76
+ * Returns a JSON-serializable representation of this object.
77
+ */
75
78
  toJSON() {
76
79
  const { details, httpErrorCode: { canonicalName: status }, message, } = this;
77
80
  return {
@@ -2,7 +2,11 @@ import * as firebase from 'firebase-admin';
2
2
  import { EventContext } from '../../cloud-functions';
3
3
  import { HttpsError } from './https';
4
4
  export { HttpsError };
5
- /** Shorthand auth blocking events from GCIP. */
5
+ /**
6
+ * Shorthand auth blocking events from GCIP.
7
+ * @hidden
8
+ * @alpha
9
+ */
6
10
  export declare type AuthBlockingEventType = 'beforeCreate' | 'beforeSignIn';
7
11
  /**
8
12
  * The UserRecord passed to Cloud Functions is the same UserRecord that is returned by the Firebase Admin
@@ -110,7 +110,11 @@ function userRecordConstructor(wireData) {
110
110
  };
111
111
  json.metadata = record.metadata.toJSON();
112
112
  json.customClaims = JSON.parse(JSON.stringify(record.customClaims));
113
- json.providerData = record.providerData.map((entry) => entry.toJSON());
113
+ json.providerData = record.providerData.map((entry) => {
114
+ const newEntry = { ...entry };
115
+ newEntry.toJSON = () => entry;
116
+ return newEntry;
117
+ });
114
118
  return json;
115
119
  };
116
120
  return record;
@@ -422,9 +426,13 @@ function wrapHandler(eventType, handler) {
422
426
  }
423
427
  const decodedPayload = (0, debug_1.isDebugFeatureEnabled)('skipTokenVerification')
424
428
  ? unsafeDecodeAuthBlockingToken(req.body.data.jwt)
425
- : await (0, apps_1.apps)()
426
- .admin.auth()
427
- ._verifyAuthBlockingToken(req.body.data.jwt);
429
+ : handler.length === 2
430
+ ? await (0, apps_1.apps)()
431
+ .admin.auth()
432
+ ._verifyAuthBlockingToken(req.body.data.jwt)
433
+ : await (0, apps_1.apps)()
434
+ .admin.auth()
435
+ ._verifyAuthBlockingToken(req.body.data.jwt, 'run.app');
428
436
  const authUserRecord = parseAuthUserRecord(decodedPayload.user_record);
429
437
  const authEventContext = parseAuthEventContext(decodedPayload, projectId);
430
438
  let authResponse;
@@ -29,9 +29,18 @@ export interface RetryConfig {
29
29
  }
30
30
  /** How congestion control should be applied to the function. */
31
31
  export interface RateLimits {
32
+ /**
33
+ * The maximum number of requests that can be outstanding at a time.
34
+ * If left unspecified, will default to 1000.
35
+ */
32
36
  maxConcurrentDispatches?: number;
37
+ /**
38
+ * The maximum number of requests that can be invoked per second.
39
+ * If left unspecified, will default to 500.
40
+ */
33
41
  maxDispatchesPerSecond?: number;
34
42
  }
43
+ /** Metadata about the authorization used to invoke a function. */
35
44
  export interface AuthData {
36
45
  uid: string;
37
46
  token: firebase.auth.DecodedIdToken;
@@ -33,20 +33,21 @@ function onDispatchHandler(handler) {
33
33
  logger.error('Invalid request, unable to process.');
34
34
  throw new https.HttpsError('invalid-argument', 'Bad Request');
35
35
  }
36
- const authHeader = req.header('Authorization') || '';
37
- const token = (_a = authHeader.match(/^Bearer (.*)$/)) === null || _a === void 0 ? void 0 : _a[1];
38
- // Note: this should never happen since task queue functions are guarded by IAM.
39
- if (!token) {
40
- throw new https.HttpsError('unauthenticated', 'Unauthenticated');
41
- }
42
- // We skip authenticating the token since tq functions are guarded by IAM.
43
- const authToken = await https.unsafeDecodeIdToken(token);
44
- const context = {
45
- auth: {
36
+ const context = {};
37
+ if (!process.env.FUNCTIONS_EMULATOR) {
38
+ const authHeader = req.header('Authorization') || '';
39
+ const token = (_a = authHeader.match(/^Bearer (.*)$/)) === null || _a === void 0 ? void 0 : _a[1];
40
+ // Note: this should never happen since task queue functions are guarded by IAM.
41
+ if (!token) {
42
+ throw new https.HttpsError('unauthenticated', 'Unauthenticated');
43
+ }
44
+ // We skip authenticating the token since tq functions are guarded by IAM.
45
+ const authToken = await https.unsafeDecodeIdToken(token);
46
+ context.auth = {
46
47
  uid: authToken.uid,
47
48
  token: authToken,
48
- },
49
- };
49
+ };
50
+ }
50
51
  const data = https.decode(req.body.data);
51
52
  if (handler.length === 2) {
52
53
  await handler(data, context);
@@ -24,7 +24,7 @@ export declare function region(...regions: Array<typeof SUPPORTED_REGIONS[number
24
24
  * Configure runtime options for the function.
25
25
  * @param runtimeOptions Object with optional fields:
26
26
  * 1. `memory`: amount of memory to allocate to the function, possible values
27
- * are: '128MB', '256MB', '512MB', '1GB', '2GB', and '4GB'.
27
+ * are: '128MB', '256MB', '512MB', '1GB', '2GB', '4GB', and '8GB'.
28
28
  * 2. `timeoutSeconds`: timeout for the function in seconds, possible values are
29
29
  * 0 to 540.
30
30
  * 3. `failurePolicy`: failure policy of the function, with boolean `true` being
@@ -55,7 +55,7 @@ export declare class FunctionBuilder {
55
55
  * Configure runtime options for the function.
56
56
  * @param runtimeOptions Object with optional fields:
57
57
  * 1. `memory`: amount of memory to allocate to the function, possible values
58
- * are: '128MB', '256MB', '512MB', '1GB', '2GB', and '4GB'.
58
+ * are: '128MB', '256MB', '512MB', '1GB', '2GB', '4GB', and '8GB'.
59
59
  * 2. `timeoutSeconds`: timeout for the function in seconds, possible values are
60
60
  * 0 to 540.
61
61
  * 3. `failurePolicy`: failure policy of the function, with boolean `true` being
@@ -78,7 +78,7 @@ export declare class FunctionBuilder {
78
78
  * Declares a callable method for clients to call using a Firebase SDK.
79
79
  * @param handler A method that takes a data and context and returns a value.
80
80
  */
81
- onCall: (handler: (data: any, context: https.CallableContext) => any | Promise<any>) => import("./cloud-functions").TriggerAnnotated & import("./cloud-functions").EndpointAnnotated & ((req: express.Request<import("express-serve-static-core").ParamsDictionary>, resp: express.Response<any>) => void | Promise<void>) & import("./cloud-functions").Runnable<any>;
81
+ onCall: (handler: (data: any, context: https.CallableContext) => any | Promise<any>) => import("./cloud-functions").HttpsFunction & import("./cloud-functions").Runnable<any>;
82
82
  };
83
83
  get tasks(): {
84
84
  /**
@@ -164,7 +164,7 @@ exports.region = region;
164
164
  * Configure runtime options for the function.
165
165
  * @param runtimeOptions Object with optional fields:
166
166
  * 1. `memory`: amount of memory to allocate to the function, possible values
167
- * are: '128MB', '256MB', '512MB', '1GB', '2GB', and '4GB'.
167
+ * are: '128MB', '256MB', '512MB', '1GB', '2GB', '4GB', and '8GB'.
168
168
  * 2. `timeoutSeconds`: timeout for the function in seconds, possible values are
169
169
  * 0 to 540.
170
170
  * 3. `failurePolicy`: failure policy of the function, with boolean `true` being
@@ -206,7 +206,7 @@ class FunctionBuilder {
206
206
  * Configure runtime options for the function.
207
207
  * @param runtimeOptions Object with optional fields:
208
208
  * 1. `memory`: amount of memory to allocate to the function, possible values
209
- * are: '128MB', '256MB', '512MB', '1GB', '2GB', and '4GB'.
209
+ * are: '128MB', '256MB', '512MB', '1GB', '2GB', '4GB', and '8GB'.
210
210
  * 2. `timeoutSeconds`: timeout for the function in seconds, possible values are
211
211
  * 0 to 540.
212
212
  * 3. `failurePolicy`: failure policy of the function, with boolean `true` being
@@ -1,4 +1,25 @@
1
1
  "use strict";
2
+ // The MIT License (MIT)
3
+ //
4
+ // Copyright (c) 2017 Firebase
5
+ //
6
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ // of this software and associated documentation files (the "Software"), to deal
8
+ // in the Software without restriction, including without limitation the rights
9
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ // copies of the Software, and to permit persons to whom the Software is
11
+ // furnished to do so, subject to the following conditions:
12
+ //
13
+ // The above copyright notice and this permission notice shall be included in all
14
+ // copies or substantial portions of the Software.
15
+ //
16
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ // SOFTWARE.
2
23
  var _a, _b, _c;
3
24
  Object.defineProperty(exports, "__esModule", { value: true });
4
25
  exports.UNPATCHED_CONSOLE = exports.CONSOLE_SEVERITY = exports.SUPPORTS_STRUCTURED_LOGS = void 0;
@@ -1,4 +1,25 @@
1
1
  "use strict";
2
+ // The MIT License (MIT)
3
+ //
4
+ // Copyright (c) 2017 Firebase
5
+ //
6
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ // of this software and associated documentation files (the "Software"), to deal
8
+ // in the Software without restriction, including without limitation the rights
9
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ // copies of the Software, and to permit persons to whom the Software is
11
+ // furnished to do so, subject to the following conditions:
12
+ //
13
+ // The above copyright notice and this permission notice shall be included in all
14
+ // copies or substantial portions of the Software.
15
+ //
16
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ // SOFTWARE.
2
23
  Object.defineProperty(exports, "__esModule", { value: true });
3
24
  const util_1 = require("util");
4
25
  const common_1 = require("./common");
@@ -1,11 +1,13 @@
1
1
  /**
2
2
  * `LogSeverity` indicates the detailed severity of the log entry. See [LogSeverity](https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#logseverity).
3
+ * @public
3
4
  */
4
5
  export declare type LogSeverity = 'DEBUG' | 'INFO' | 'NOTICE' | 'WARNING' | 'ERROR' | 'CRITICAL' | 'ALERT' | 'EMERGENCY';
5
6
  /**
6
7
  * `LogEntry` represents a [structured Cloud Logging](https://cloud.google.com/logging/docs/structured-logging)
7
8
  * entry. All keys aside from `severity` and `message` are
8
9
  * included in the `jsonPayload` of the logged entry.
10
+ * @public
9
11
  */
10
12
  export interface LogEntry {
11
13
  severity: LogSeverity;
@@ -14,36 +16,42 @@ export interface LogEntry {
14
16
  }
15
17
  /**
16
18
  * Writes a `LogEntry` to `stdout`/`stderr` (depending on severity).
17
- * @param entry The `LogEntry` including severity, message, and any additional structured metadata.
19
+ * @param entry - The `LogEntry` including severity, message, and any additional structured metadata.
20
+ * @public
18
21
  */
19
22
  export declare function write(entry: LogEntry): void;
20
23
  /**
21
24
  * Writes a `DEBUG` severity log. If the last argument provided is a plain object,
22
25
  * it is added to the `jsonPayload` in the Cloud Logging entry.
23
- * @param args Arguments, concatenated into the log message with space separators.
26
+ * @param args - Arguments, concatenated into the log message with space separators.
27
+ * @public
24
28
  */
25
29
  export declare function debug(...args: any[]): void;
26
30
  /**
27
31
  * Writes an `INFO` severity log. If the last argument provided is a plain object,
28
32
  * it is added to the `jsonPayload` in the Cloud Logging entry.
29
- * @param args Arguments, concatenated into the log message with space separators.
33
+ * @param args - Arguments, concatenated into the log message with space separators.
34
+ * @public
30
35
  */
31
36
  export declare function log(...args: any[]): void;
32
37
  /**
33
38
  * Writes an `INFO` severity log. If the last argument provided is a plain object,
34
39
  * it is added to the `jsonPayload` in the Cloud Logging entry.
35
- * @param args Arguments, concatenated into the log message with space separators.
40
+ * @param args - Arguments, concatenated into the log message with space separators.
41
+ * @public
36
42
  */
37
43
  export declare function info(...args: any[]): void;
38
44
  /**
39
45
  * Writes a `WARNING` severity log. If the last argument provided is a plain object,
40
46
  * it is added to the `jsonPayload` in the Cloud Logging entry.
41
- * @param args Arguments, concatenated into the log message with space separators.
47
+ * @param args - Arguments, concatenated into the log message with space separators.
48
+ * @public
42
49
  */
43
50
  export declare function warn(...args: any[]): void;
44
51
  /**
45
52
  * Writes an `ERROR` severity log. If the last argument provided is a plain object,
46
53
  * it is added to the `jsonPayload` in the Cloud Logging entry.
47
- * @param args Arguments, concatenated into the log message with space separators.
54
+ * @param args - Arguments, concatenated into the log message with space separators.
55
+ * @public
48
56
  */
49
57
  export declare function error(...args: any[]): void;