firebase-functions 3.21.1 → 3.23.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 (49) hide show
  1. package/lib/bin/firebase-functions.js +2 -1
  2. package/lib/cloud-functions.d.ts +1 -48
  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/providers/database.d.ts +145 -0
  7. package/lib/common/providers/database.js +271 -0
  8. package/lib/common/providers/identity.js +12 -7
  9. package/lib/common/providers/tasks.d.ts +8 -7
  10. package/lib/common/providers/tasks.js +13 -12
  11. package/lib/common/timezone.d.ts +2 -0
  12. package/lib/common/timezone.js +543 -0
  13. package/lib/function-builder.d.ts +2 -2
  14. package/lib/function-builder.js +2 -2
  15. package/lib/function-configuration.d.ts +6 -5
  16. package/lib/providers/database.d.ts +4 -146
  17. package/lib/providers/database.js +7 -251
  18. package/lib/providers/firestore.d.ts +2 -1
  19. package/lib/providers/firestore.js +2 -1
  20. package/lib/runtime/loader.js +6 -1
  21. package/lib/runtime/manifest.d.ts +19 -16
  22. package/lib/runtime/manifest.js +24 -0
  23. package/lib/utilities/path-pattern.d.ts +1 -0
  24. package/lib/utilities/path-pattern.js +142 -0
  25. package/lib/v2/core.d.ts +2 -0
  26. package/lib/v2/core.js +7 -0
  27. package/lib/v2/index.d.ts +4 -1
  28. package/lib/v2/index.js +7 -1
  29. package/lib/v2/options.d.ts +16 -6
  30. package/lib/v2/options.js +2 -2
  31. package/lib/v2/params/index.d.ts +14 -12
  32. package/lib/v2/params/index.js +25 -15
  33. package/lib/v2/params/types.d.ts +97 -24
  34. package/lib/v2/params/types.js +127 -67
  35. package/lib/v2/providers/alerts/alerts.d.ts +7 -6
  36. package/lib/v2/providers/alerts/appDistribution.d.ts +50 -5
  37. package/lib/v2/providers/alerts/appDistribution.js +23 -1
  38. package/lib/v2/providers/alerts/crashlytics.d.ts +6 -5
  39. package/lib/v2/providers/database.d.ts +183 -0
  40. package/lib/v2/providers/database.js +204 -0
  41. package/lib/v2/providers/eventarc.d.ts +6 -5
  42. package/lib/v2/providers/https.d.ts +6 -5
  43. package/lib/v2/providers/identity.d.ts +8 -7
  44. package/lib/v2/providers/pubsub.d.ts +6 -5
  45. package/lib/v2/providers/scheduler.d.ts +63 -0
  46. package/lib/v2/providers/scheduler.js +98 -0
  47. package/lib/v2/providers/storage.d.ts +6 -5
  48. package/lib/v2/providers/tasks.d.ts +7 -6
  49. package/package.json +18 -8
@@ -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;
@@ -397,9 +401,6 @@ function getUpdateMask(authResponse) {
397
401
  }
398
402
  const updateMask = [];
399
403
  for (const key in authResponse) {
400
- if (key === 'customClaims' || key === 'sessionClaims') {
401
- continue;
402
- }
403
404
  if (authResponse.hasOwnProperty(key) &&
404
405
  typeof authResponse[key] !== 'undefined') {
405
406
  updateMask.push(key);
@@ -422,9 +423,13 @@ function wrapHandler(eventType, handler) {
422
423
  }
423
424
  const decodedPayload = (0, debug_1.isDebugFeatureEnabled)('skipTokenVerification')
424
425
  ? unsafeDecodeAuthBlockingToken(req.body.data.jwt)
425
- : await (0, apps_1.apps)()
426
- .admin.auth()
427
- ._verifyAuthBlockingToken(req.body.data.jwt);
426
+ : handler.length === 2
427
+ ? await (0, apps_1.apps)()
428
+ .admin.auth()
429
+ ._verifyAuthBlockingToken(req.body.data.jwt)
430
+ : await (0, apps_1.apps)()
431
+ .admin.auth()
432
+ ._verifyAuthBlockingToken(req.body.data.jwt, 'run.app');
428
433
  const authUserRecord = parseAuthUserRecord(decodedPayload.user_record);
429
434
  const authEventContext = parseAuthEventContext(decodedPayload, projectId);
430
435
  let authResponse;
@@ -1,31 +1,32 @@
1
1
  import * as firebase from 'firebase-admin';
2
+ import { Expression } from '../../v2/params';
2
3
  /** How a task should be retried in the event of a non-2xx return. */
3
4
  export interface RetryConfig {
4
5
  /**
5
6
  * Maximum number of times a request should be attempted.
6
7
  * If left unspecified, will default to 3.
7
8
  */
8
- maxAttempts?: number;
9
+ maxAttempts?: number | Expression<number> | null;
9
10
  /**
10
11
  * Maximum amount of time for retrying failed task.
11
12
  * If left unspecified will retry indefinitely.
12
13
  */
13
- maxRetrySeconds?: number;
14
+ maxRetrySeconds?: number | Expression<number> | null;
14
15
  /**
15
16
  * The maximum amount of time to wait between attempts.
16
17
  * If left unspecified will default to 1hr.
17
18
  */
18
- maxBackoffSeconds?: number;
19
+ maxBackoffSeconds?: number | Expression<number> | null;
19
20
  /**
20
21
  * The maximum number of times to double the backoff between
21
22
  * retries. If left unspecified will default to 16.
22
23
  */
23
- maxDoublings?: number;
24
+ maxDoublings?: number | Expression<number> | null;
24
25
  /**
25
26
  * The minimum time to wait between attempts. If left unspecified
26
27
  * will default to 100ms.
27
28
  */
28
- minBackoffSeconds?: number;
29
+ minBackoffSeconds?: number | Expression<number> | null;
29
30
  }
30
31
  /** How congestion control should be applied to the function. */
31
32
  export interface RateLimits {
@@ -33,12 +34,12 @@ export interface RateLimits {
33
34
  * The maximum number of requests that can be outstanding at a time.
34
35
  * If left unspecified, will default to 1000.
35
36
  */
36
- maxConcurrentDispatches?: number;
37
+ maxConcurrentDispatches?: number | Expression<number> | null;
37
38
  /**
38
39
  * The maximum number of requests that can be invoked per second.
39
40
  * If left unspecified, will default to 500.
40
41
  */
41
- maxDispatchesPerSecond?: number;
42
+ maxDispatchesPerSecond?: number | Expression<number> | null;
42
43
  }
43
44
  /** Metadata about the authorization used to invoke a function. */
44
45
  export interface AuthData {
@@ -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);
@@ -0,0 +1,2 @@
1
+ export declare const tzDatabase: Record<string, string>;
2
+ export declare type timezone = keyof typeof tzDatabase;