backend-manager 3.2.10 → 3.2.12

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "backend-manager",
3
- "version": "3.2.10",
3
+ "version": "3.2.12",
4
4
  "description": "Quick tools for developing Firebase functions",
5
5
  "main": "src/manager/index.js",
6
6
  "bin": {
@@ -70,4 +70,4 @@
70
70
  "wonderful-log": "^1.0.5",
71
71
  "yargs": "^17.7.2"
72
72
  }
73
- }
73
+ }
@@ -495,14 +495,24 @@ function _attachHeaderProperties(self, options, error) {
495
495
  },
496
496
  additional: options.additional || {},
497
497
  }
498
+ const req = self.ref.req;
499
+ const res = self.ref.res;
498
500
 
499
501
  // Attach properties
500
502
  try {
501
- self.ref.res.header('bm-properties', JSON.stringify(headers));
503
+ res.header('bm-properties', JSON.stringify(headers));
502
504
  } catch (e) {
503
505
  self.warn('Error attaching properties to header', e);
504
506
  }
505
507
 
508
+ // Add bm-properties to Access-Control-Expose-Headers
509
+ const existingExposed = res.get('Access-Control-Expose-Headers') || '';
510
+ const newExposed = `${existingExposed}, bm-properties`.replace(/^, /, '');
511
+
512
+ if (!existingExposed.match(/bm-properties/i)) {
513
+ res.header('Access-Control-Expose-Headers', newExposed);
514
+ }
515
+
506
516
  // Attach properties
507
517
  if (error) {
508
518
  Object.keys(headers)
@@ -59,6 +59,10 @@ Middleware.prototype.run = function (library, options) {
59
59
  assistant.usage = await Manager.Usage().init(assistant);
60
60
  }
61
61
 
62
+ // Log working user
63
+ const workingUser = assistant?.usage?.user || assistant.request.user;
64
+ assistant.log(`Middleware.process(): User (${workingUser.auth.uid}, ${workingUser.auth.email}, ${workingUser.plan.id}=${workingUser.plan.status}):`, JSON.stringify(workingUser));
65
+
62
66
  // Setup analytics
63
67
  if (options.setupAnalytics) {
64
68
  const uuid = assistant?.usage?.user?.auth?.uid
@@ -42,7 +42,7 @@ Settings.prototype.resolve = function (assistant, schema, settings) {
42
42
  // Resolve settings
43
43
  self.settings = powertools.defaults(settings, schema);
44
44
 
45
- // // Perform checks
45
+ // Check for missing required keys
46
46
  powertools.getKeys(schema).forEach((key) => {
47
47
  const isRequired = key.endsWith('.required') ? _.get(schema, key, false) : false;
48
48