web-manager 3.2.65 → 3.2.67

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/index.js CHANGED
@@ -87,6 +87,8 @@ function Manager() {
87
87
  global: {
88
88
  version: '',
89
89
  url: '',
90
+ functionsUrl: '',
91
+ apiUrl: '',
90
92
  buildTime: 0,
91
93
  cacheBreaker: '',
92
94
  brand: {
@@ -637,6 +639,11 @@ Manager.prototype.init = function(configuration, callback) {
637
639
  self.properties.meta.environment = utilities.get(configuration, 'global.settings.debug.environment', self.properties.meta.environment);
638
640
  self.properties.page.queryString = new URLSearchParams(window.location.search);
639
641
 
642
+ // set global properties
643
+ self.properties.global.apiUrl = getApiUrl(self.properties.global.url);
644
+ self.properties.global.functionsUrl = 'https://us-central1-' + self.properties.options.libraries.firebase_app.config.projectId + '.cloudfunctions.net';
645
+
646
+ // set page properties
640
647
  var pagePathname = window.location.pathname;
641
648
  var redirect = false;
642
649
 
@@ -1804,6 +1811,25 @@ Manager.prototype.isDevelopment = function () {
1804
1811
  // }
1805
1812
  // }
1806
1813
 
1814
+ function getApiUrl(url) {
1815
+ // Set API url
1816
+ var globalUrl = new URL(url);
1817
+ var hostnameParts = globalUrl.hostname.split('.');
1818
+
1819
+ // Check if subdomain exists
1820
+ if (hostnameParts.length > 2) {
1821
+ hostnameParts[0] = 'api';
1822
+ } else {
1823
+ hostnameParts.unshift('api');
1824
+ }
1825
+
1826
+ // Set hostname
1827
+ globalUrl.hostname = hostnameParts.join('.');
1828
+
1829
+ // Return new URL
1830
+ return globalUrl.toString();
1831
+ }
1832
+
1807
1833
 
1808
1834
  /**
1809
1835
  * HELPERS
package/lib/account.js CHANGED
@@ -70,7 +70,7 @@ Account.prototype.delete = function (options) {
70
70
  } else {
71
71
  user.getIdToken(false)
72
72
  .then(function(token) {
73
- fetch('https://us-central1-' + self.utilities.get(self.Manager, 'properties.options.libraries.firebase_app.config.projectId', 'unknown') + '.cloudfunctions.net/bm_api', {
73
+ fetch(self.Manager.properties.properties.global.functionsUrl + '/bm_api', {
74
74
  // fetch('http://localhost:5001/optiic-api/us-central1/bm_api', {
75
75
  method: 'POST',
76
76
  headers: { 'Content-Type': 'application/json' },
@@ -478,6 +478,10 @@ Account.prototype._resolveAccount = function (firebaseUser, account, options) {
478
478
  account.personal.telephone.countryCode = account.personal.telephone.countryCode || 0;
479
479
  account.personal.telephone.national = account.personal.telephone.national || 0;
480
480
 
481
+ account.personal.company = account.personal.company || {};
482
+ account.personal.company.name = account.personal.company.name || '';
483
+ account.personal.company.position = account.personal.company.position || '';
484
+
481
485
  // Set UI elements
482
486
  // In a try/catch because this lib is used in node sometimes
483
487
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-manager",
3
- "version": "3.2.65",
3
+ "version": "3.2.67",
4
4
  "description": "Easily access important variables such as the query string, current domain, and current page in a single object.",
5
5
  "main": "index.js",
6
6
  "scripts": {