firebase-functions 3.21.0 → 3.21.1

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 (49) hide show
  1. package/lib/bin/firebase-functions.js +21 -0
  2. package/lib/cloud-functions.d.ts +53 -40
  3. package/lib/common/encoding.js +21 -1
  4. package/lib/common/providers/https.d.ts +37 -17
  5. package/lib/common/providers/https.js +3 -0
  6. package/lib/common/providers/identity.d.ts +5 -1
  7. package/lib/common/providers/tasks.d.ts +9 -0
  8. package/lib/function-builder.d.ts +1 -1
  9. package/lib/logger/common.js +21 -0
  10. package/lib/logger/compat.js +21 -0
  11. package/lib/logger/index.d.ts +14 -6
  12. package/lib/logger/index.js +33 -6
  13. package/lib/providers/auth.d.ts +26 -5
  14. package/lib/providers/auth.js +18 -4
  15. package/lib/providers/pubsub.d.ts +6 -6
  16. package/lib/providers/pubsub.js +6 -6
  17. package/lib/providers/tasks.d.ts +29 -14
  18. package/lib/providers/tasks.js +10 -3
  19. package/lib/v2/core.d.ts +23 -1
  20. package/lib/v2/index.d.ts +9 -3
  21. package/lib/v2/index.js +8 -3
  22. package/lib/v2/options.d.ts +13 -34
  23. package/lib/v2/options.js +6 -58
  24. package/lib/v2/params/index.d.ts +4 -1
  25. package/lib/v2/params/index.js +25 -1
  26. package/lib/v2/params/types.js +21 -0
  27. package/lib/v2/providers/alerts/alerts.d.ts +94 -3
  28. package/lib/v2/providers/alerts/alerts.js +23 -7
  29. package/lib/v2/providers/alerts/appDistribution.d.ts +101 -1
  30. package/lib/v2/providers/alerts/appDistribution.js +28 -1
  31. package/lib/v2/providers/alerts/billing.d.ts +23 -2
  32. package/lib/v2/providers/alerts/billing.js +37 -0
  33. package/lib/v2/providers/alerts/crashlytics.d.ts +193 -18
  34. package/lib/v2/providers/alerts/crashlytics.js +62 -1
  35. package/lib/v2/providers/alerts/index.d.ts +6 -0
  36. package/lib/v2/providers/alerts/index.js +27 -0
  37. package/lib/v2/providers/eventarc.d.ts +89 -5
  38. package/lib/v2/providers/eventarc.js +4 -0
  39. package/lib/v2/providers/https.d.ts +123 -2
  40. package/lib/v2/providers/https.js +13 -3
  41. package/lib/v2/providers/identity.d.ts +108 -4
  42. package/lib/v2/providers/identity.js +33 -2
  43. package/lib/v2/providers/pubsub.d.ts +122 -5
  44. package/lib/v2/providers/pubsub.js +58 -2
  45. package/lib/v2/providers/storage.d.ts +192 -4
  46. package/lib/v2/providers/storage.js +52 -9
  47. package/lib/v2/providers/tasks.d.ts +106 -6
  48. package/lib/v2/providers/tasks.js +4 -0
  49. package/package.json +6 -4
@@ -1,5 +1,26 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
+ // The MIT License (MIT)
4
+ //
5
+ // Copyright (c) 2022 Firebase
6
+ //
7
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ // of this software and associated documentation files (the "Software"), to deal
9
+ // in the Software without restriction, including without limitation the rights
10
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ // copies of the Software, and to permit persons to whom the Software is
12
+ // furnished to do so, subject to the following conditions:
13
+ //
14
+ // The above copyright notice and this permission notice shall be included in all
15
+ // copies or substantial portions of the Software.
16
+ //
17
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ // SOFTWARE.
3
24
  Object.defineProperty(exports, "__esModule", { value: true });
4
25
  const express = require("express");
5
26
  const loader_1 = require("../runtime/loader");
@@ -173,46 +173,35 @@ export interface Resource {
173
173
  };
174
174
  }
175
175
  /**
176
- * @hidden
177
- * TriggerAnnotated is used internally by the firebase CLI to understand what
176
+ * TriggerAnnotion is used internally by the firebase CLI to understand what
178
177
  * type of Cloud Function to deploy.
179
178
  */
180
- export interface TriggerAnnotated {
181
- __trigger: {
182
- availableMemoryMb?: number;
183
- blockingTrigger?: {
184
- eventType: string;
185
- options?: Record<string, unknown>;
186
- };
187
- eventTrigger?: {
188
- eventType: string;
189
- resource: string;
190
- service: string;
191
- };
192
- failurePolicy?: FailurePolicy;
193
- httpsTrigger?: {
194
- invoker?: string[];
195
- };
196
- labels?: {
197
- [key: string]: string;
198
- };
199
- regions?: string[];
200
- schedule?: Schedule;
201
- timeout?: Duration;
202
- vpcConnector?: string;
203
- vpcConnectorEgressSettings?: string;
204
- serviceAccountEmail?: string;
205
- ingressSettings?: string;
206
- secrets?: string[];
179
+ interface TriggerAnnotation {
180
+ availableMemoryMb?: number;
181
+ blockingTrigger?: {
182
+ eventType: string;
183
+ options?: Record<string, unknown>;
207
184
  };
208
- }
209
- /**
210
- * @hidden
211
- * EndpointAnnotated is used to generate the manifest that conforms to the container contract.
212
- */
213
- export interface EndpointAnnotated {
214
- __endpoint: ManifestEndpoint;
215
- __requiredAPIs?: ManifestRequiredAPI[];
185
+ eventTrigger?: {
186
+ eventType: string;
187
+ resource: string;
188
+ service: string;
189
+ };
190
+ failurePolicy?: FailurePolicy;
191
+ httpsTrigger?: {
192
+ invoker?: string[];
193
+ };
194
+ labels?: {
195
+ [key: string]: string;
196
+ };
197
+ regions?: string[];
198
+ schedule?: Schedule;
199
+ timeout?: Duration;
200
+ vpcConnector?: string;
201
+ vpcConnectorEgressSettings?: string;
202
+ serviceAccountEmail?: string;
203
+ ingressSettings?: string;
204
+ secrets?: string[];
216
205
  }
217
206
  /**
218
207
  * A Runnable has a `run` method which directly invokes the user-defined
@@ -230,11 +219,27 @@ export interface Runnable<T> {
230
219
  * [`Response`](https://expressjs.com/en/api.html#res) objects as its only
231
220
  * arguments.
232
221
  */
233
- export declare type HttpsFunction = TriggerAnnotated & EndpointAnnotated & ((req: Request, resp: Response) => void | Promise<void>);
222
+ export interface HttpsFunction {
223
+ (req: Request, resp: Response): void | Promise<void>;
224
+ /** @alpha */
225
+ __trigger: TriggerAnnotation;
226
+ /** @alpha */
227
+ __endpoint: ManifestEndpoint;
228
+ /** @alpha */
229
+ __requiredAPIs?: ManifestRequiredAPI[];
230
+ }
234
231
  /**
235
232
  * The Cloud Function type for Blocking triggers.
236
233
  */
237
- export declare type BlockingFunction = HttpsFunction;
234
+ export interface BlockingFunction {
235
+ (req: Request, resp: Response): void | Promise<void>;
236
+ /** @alpha */
237
+ __trigger: TriggerAnnotation;
238
+ /** @alpha */
239
+ __endpoint: ManifestEndpoint;
240
+ /** @alpha */
241
+ __requiredAPIs?: ManifestRequiredAPI[];
242
+ }
238
243
  /**
239
244
  * The Cloud Function type for all non-HTTPS triggers. This should be exported
240
245
  * from your JavaScript file to define a Cloud Function.
@@ -242,7 +247,15 @@ export declare type BlockingFunction = HttpsFunction;
242
247
  * This type is a special JavaScript function which takes a templated
243
248
  * `Event` object as its only argument.
244
249
  */
245
- export declare type CloudFunction<T> = Runnable<T> & TriggerAnnotated & EndpointAnnotated & ((input: any, context?: any) => PromiseLike<any> | any);
250
+ export interface CloudFunction<T> extends Runnable<T> {
251
+ (input: any, context?: any): PromiseLike<any> | any;
252
+ /** @alpha */
253
+ __trigger: TriggerAnnotation;
254
+ /** @alpha */
255
+ __endpoint: ManifestEndpoint;
256
+ /** @alpha */
257
+ __requiredAPIs?: ManifestRequiredAPI[];
258
+ }
246
259
  /** @hidden */
247
260
  export interface MakeCloudFunctionArgs<EventData> {
248
261
  after?: (raw: Event) => void;
@@ -1,5 +1,25 @@
1
1
  "use strict";
2
- // Copied from firebase-tools/src/gcp/proto
2
+ // The MIT License (MIT)
3
+ //
4
+ // Copyright (c) 2021 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.
3
23
  Object.defineProperty(exports, "__esModule", { value: true });
4
24
  exports.convertInvoker = exports.serviceAccountFromShorthand = exports.convertIfPresent = exports.copyIfPresent = exports.durationFromSeconds = void 0;
5
25
  /** Get a google.protobuf.Duration for a number of seconds. */
@@ -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
@@ -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;
@@ -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
  /**
@@ -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;
@@ -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
  exports.error = exports.warn = exports.info = exports.log = exports.debug = exports.write = void 0;
4
25
  const util_1 = require("util");
@@ -37,7 +58,8 @@ function removeCircular(obj, refs = []) {
37
58
  }
38
59
  /**
39
60
  * Writes a `LogEntry` to `stdout`/`stderr` (depending on severity).
40
- * @param entry The `LogEntry` including severity, message, and any additional structured metadata.
61
+ * @param entry - The `LogEntry` including severity, message, and any additional structured metadata.
62
+ * @public
41
63
  */
42
64
  function write(entry) {
43
65
  if (common_1.SUPPORTS_STRUCTURED_LOGS) {
@@ -62,7 +84,8 @@ exports.write = write;
62
84
  /**
63
85
  * Writes a `DEBUG` severity log. If the last argument provided is a plain object,
64
86
  * it is added to the `jsonPayload` in the Cloud Logging entry.
65
- * @param args Arguments, concatenated into the log message with space separators.
87
+ * @param args - Arguments, concatenated into the log message with space separators.
88
+ * @public
66
89
  */
67
90
  function debug(...args) {
68
91
  write(entryFromArgs('DEBUG', args));
@@ -71,7 +94,8 @@ exports.debug = debug;
71
94
  /**
72
95
  * Writes an `INFO` severity log. If the last argument provided is a plain object,
73
96
  * it is added to the `jsonPayload` in the Cloud Logging entry.
74
- * @param args Arguments, concatenated into the log message with space separators.
97
+ * @param args - Arguments, concatenated into the log message with space separators.
98
+ * @public
75
99
  */
76
100
  function log(...args) {
77
101
  write(entryFromArgs('INFO', args));
@@ -80,7 +104,8 @@ exports.log = log;
80
104
  /**
81
105
  * Writes an `INFO` severity log. If the last argument provided is a plain object,
82
106
  * it is added to the `jsonPayload` in the Cloud Logging entry.
83
- * @param args Arguments, concatenated into the log message with space separators.
107
+ * @param args - Arguments, concatenated into the log message with space separators.
108
+ * @public
84
109
  */
85
110
  function info(...args) {
86
111
  write(entryFromArgs('INFO', args));
@@ -89,7 +114,8 @@ exports.info = info;
89
114
  /**
90
115
  * Writes a `WARNING` severity log. If the last argument provided is a plain object,
91
116
  * it is added to the `jsonPayload` in the Cloud Logging entry.
92
- * @param args Arguments, concatenated into the log message with space separators.
117
+ * @param args - Arguments, concatenated into the log message with space separators.
118
+ * @public
93
119
  */
94
120
  function warn(...args) {
95
121
  write(entryFromArgs('WARNING', args));
@@ -98,7 +124,8 @@ exports.warn = warn;
98
124
  /**
99
125
  * Writes an `ERROR` severity log. If the last argument provided is a plain object,
100
126
  * it is added to the `jsonPayload` in the Cloud Logging entry.
101
- * @param args Arguments, concatenated into the log message with space separators.
127
+ * @param args - Arguments, concatenated into the log message with space separators.
128
+ * @public
102
129
  */
103
130
  function error(...args) {
104
131
  write(entryFromArgs('ERROR', args));
@@ -7,21 +7,34 @@ export { HttpsError };
7
7
  export declare const provider = "google.firebase.auth";
8
8
  /** @hidden */
9
9
  export declare const service = "firebaseauth.googleapis.com";
10
- /** Resource level options */
10
+ /**
11
+ * Resource level options
12
+ * @public
13
+ */
11
14
  export interface UserOptions {
15
+ /** Options to set configuration at the resource level for blocking functions. */
12
16
  blockingOptions?: {
17
+ /** Pass the ID Token credential to the function. */
13
18
  idToken?: boolean;
19
+ /** Pass the Access Token credential to the function. */
14
20
  accessToken?: boolean;
21
+ /** Pass the Refresh Token credential to the function. */
15
22
  refreshToken?: boolean;
16
23
  };
17
24
  }
18
25
  /**
19
- * Handle events related to Firebase authentication users.
26
+ * Handles events related to Firebase authentication users.
27
+ * @param userOptions - Resource level options
28
+ * @returns UserBuilder - Builder used to create Cloud Functions for Firebase Auth user lifecycle events
29
+ * @public
20
30
  */
21
31
  export declare function user(userOptions?: UserOptions): UserBuilder;
22
32
  /** @hidden */
23
33
  export declare function _userWithOptions(options: DeploymentOptions, userOptions: UserOptions): UserBuilder;
24
- /** Builder used to create Cloud Functions for Firebase Auth user lifecycle events. */
34
+ /**
35
+ * Builder used to create Cloud Functions for Firebase Auth user lifecycle events.
36
+ * @public
37
+ */
25
38
  export declare class UserBuilder {
26
39
  private triggerResource;
27
40
  private options;
@@ -29,12 +42,20 @@ export declare class UserBuilder {
29
42
  private static dataConstructor;
30
43
  /** @hidden */
31
44
  constructor(triggerResource: () => string, options: DeploymentOptions, userOptions?: UserOptions);
32
- /** Respond to the creation of a Firebase Auth user. */
45
+ /**
46
+ * Responds to the creation of a Firebase Auth user.
47
+ * @public
48
+ */
33
49
  onCreate(handler: (user: UserRecord, context: EventContext) => PromiseLike<any> | any): CloudFunction<UserRecord>;
34
- /** Respond to the deletion of a Firebase Auth user. */
50
+ /**
51
+ * Responds to the deletion of a Firebase Auth user.
52
+ * @public
53
+ */
35
54
  onDelete(handler: (user: UserRecord, context: EventContext) => PromiseLike<any> | any): CloudFunction<UserRecord>;
36
55
  beforeCreate(handler: (user: AuthUserRecord, context: AuthEventContext) => BeforeCreateResponse | void | Promise<BeforeCreateResponse> | Promise<void>): BlockingFunction;
37
56
  beforeSignIn(handler: (user: AuthUserRecord, context: AuthEventContext) => BeforeSignInResponse | void | Promise<BeforeSignInResponse> | Promise<void>): BlockingFunction;
57
+ /** @hidden */
38
58
  private onOperation;
59
+ /** @hidden */
39
60
  private beforeOperation;
40
61
  }
@@ -32,7 +32,10 @@ exports.provider = 'google.firebase.auth';
32
32
  /** @hidden */
33
33
  exports.service = 'firebaseauth.googleapis.com';
34
34
  /**
35
- * Handle events related to Firebase authentication users.
35
+ * Handles events related to Firebase authentication users.
36
+ * @param userOptions - Resource level options
37
+ * @returns UserBuilder - Builder used to create Cloud Functions for Firebase Auth user lifecycle events
38
+ * @public
36
39
  */
37
40
  function user(userOptions) {
38
41
  return _userWithOptions({}, userOptions || {});
@@ -48,7 +51,10 @@ function _userWithOptions(options, userOptions) {
48
51
  }, options, userOptions);
49
52
  }
50
53
  exports._userWithOptions = _userWithOptions;
51
- /** Builder used to create Cloud Functions for Firebase Auth user lifecycle events. */
54
+ /**
55
+ * Builder used to create Cloud Functions for Firebase Auth user lifecycle events.
56
+ * @public
57
+ */
52
58
  class UserBuilder {
53
59
  /** @hidden */
54
60
  constructor(triggerResource, options, userOptions) {
@@ -59,11 +65,17 @@ class UserBuilder {
59
65
  static dataConstructor(raw) {
60
66
  return (0, identity_1.userRecordConstructor)(raw.data);
61
67
  }
62
- /** Respond to the creation of a Firebase Auth user. */
68
+ /**
69
+ * Responds to the creation of a Firebase Auth user.
70
+ * @public
71
+ */
63
72
  onCreate(handler) {
64
73
  return this.onOperation(handler, 'user.create');
65
74
  }
66
- /** Respond to the deletion of a Firebase Auth user. */
75
+ /**
76
+ * Responds to the deletion of a Firebase Auth user.
77
+ * @public
78
+ */
67
79
  onDelete(handler) {
68
80
  return this.onOperation(handler, 'user.delete');
69
81
  }
@@ -73,6 +85,7 @@ class UserBuilder {
73
85
  beforeSignIn(handler) {
74
86
  return this.beforeOperation(handler, 'beforeSignIn');
75
87
  }
88
+ /** @hidden */
76
89
  onOperation(handler, eventType) {
77
90
  return (0, cloud_functions_1.makeCloudFunction)({
78
91
  handler,
@@ -85,6 +98,7 @@ class UserBuilder {
85
98
  options: this.options,
86
99
  });
87
100
  }
101
+ /** @hidden */
88
102
  beforeOperation(handler, eventType) {
89
103
  var _a, _b, _c, _d, _e, _f;
90
104
  const accessToken = ((_b = (_a = this.userOptions) === null || _a === void 0 ? void 0 : _a.blockingOptions) === null || _b === void 0 ? void 0 : _b.accessToken) || false;