backend-manager 3.2.118 → 3.2.119

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.118",
3
+ "version": "3.2.119",
4
4
  "description": "Quick tools for developing Firebase functions",
5
5
  "main": "src/manager/index.js",
6
6
  "bin": {
@@ -76,4 +76,4 @@
76
76
  "wonderful-log": "^1.0.5",
77
77
  "yargs": "^17.7.2"
78
78
  }
79
- }
79
+ }
@@ -610,16 +610,20 @@ BackendAssistant.prototype.authenticate = async function (options) {
610
610
  // Check with custom BEM Token
611
611
  let storedApiKey;
612
612
  try {
613
- const workingConfig = self.Manager?.config || functions.config();
614
- const storedApiKey = workingConfig?.backend_manager?.key || '';
613
+ // Disabled this 5/11/24 because i dont know why we would need to do functions.config() if we already have the Manager
614
+ // const workingConfig = self.Manager?.config || functions.config();
615
+ storedApiKey = self.Manager?.config?.backend_manager?.key || '';
615
616
  } catch (e) {
616
-
617
+ // Do nothing
617
618
  }
618
619
 
620
+ // Set idToken as working token of either backendManagerKey or authenticationToken
619
621
  idToken = data.backendManagerKey || data.authenticationToken;
620
622
 
623
+ // Log the token
621
624
  self.log('Found "backendManagerKey" or "authenticationToken" parameter', {storedApiKey: storedApiKey, idToken: idToken});
622
625
 
626
+ // Check if the token is correct
623
627
  if (storedApiKey && (storedApiKey === data.backendManagerKey || storedApiKey === data.authenticationToken)) {
624
628
  self.request.user.authenticated = true;
625
629
  self.request.user.roles.admin = true;
@@ -92,10 +92,16 @@ Manager.prototype.init = function (exporter, options) {
92
92
  self.project.serviceAccountPath = path.resolve(self.cwd, options.serviceAccountPath);
93
93
  self.project.backendManagerConfigPath = path.resolve(self.cwd, options.backendManagerConfigPath);
94
94
 
95
+ // Load package.json
95
96
  self.package = resolveProjectPackage();
97
+
98
+ // Load config
96
99
  self.config = merge(
97
100
  requireJSON5(self.project.backendManagerConfigPath),
98
- self.libraries.functions ? self.libraries.functions.config() : {}
101
+ manuallyLoadRuntimeConfig(self.cwd),
102
+ self.libraries.functions
103
+ ? self.libraries.functions.config()
104
+ : {},
99
105
  );
100
106
 
101
107
  // Saved config
@@ -983,4 +989,14 @@ function requireJSON5(p) {
983
989
  }
984
990
  }
985
991
 
992
+ function manuallyLoadRuntimeConfig(cwd) {
993
+ try {
994
+ console.log('=====+++', jetpack.list(cwd));
995
+ console.log('=====+++', require(path.resolve(cwd, '.runtimeconfig.json')));
996
+ return require(path.resolve(cwd, '.runtimeconfig.json'));
997
+ } catch (e) {
998
+ return {};
999
+ }
1000
+ }
1001
+
986
1002
  module.exports = Manager;