authscape 1.0.299 → 1.0.302

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
@@ -4274,21 +4274,26 @@ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyri
4274
4274
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4275
4275
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
4276
4276
  var setupOEMProps = /*#__PURE__*/function () {
4277
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(apiUri, Component, ctx) {
4278
- var pageProps, host, response;
4277
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
4278
+ var Component, ctx, pageProps, host, response;
4279
4279
  return _regeneratorRuntime().wrap(function _callee$(_context) {
4280
4280
  while (1) switch (_context.prev = _context.next) {
4281
4281
  case 0:
4282
+ Component = _ref.Component, ctx = _ref.ctx;
4282
4283
  pageProps = {};
4283
4284
  if (!Component.getInitialProps) {
4284
- _context.next = 5;
4285
+ _context.next = 6;
4285
4286
  break;
4286
4287
  }
4287
- _context.next = 4;
4288
+ _context.next = 5;
4288
4289
  return Component.getInitialProps(ctx);
4289
- case 4:
4290
- pageProps = _context.sent;
4291
4290
  case 5:
4291
+ pageProps = _context.sent;
4292
+ case 6:
4293
+ if (!(ctx.req != null)) {
4294
+ _context.next = 15;
4295
+ break;
4296
+ }
4292
4297
  host = ctx.req.headers.host;
4293
4298
  if (host.includes("localhost")) {
4294
4299
  pageProps.host = "http://" + ctx.req.headers.host;
@@ -4297,27 +4302,29 @@ var setupOEMProps = /*#__PURE__*/function () {
4297
4302
  }
4298
4303
 
4299
4304
  // get the companyId
4300
- _context.next = 9;
4301
- return apiService().get(apiUri + "/api/WhiteLabel/GetCompanyIdFromDomain?domain=" + pageProps.host);
4302
- case 9:
4305
+ _context.next = 11;
4306
+ return fetch(process.env.apiUri + "/api/WhiteLabel/GetCompanyIdFromDomain?domain=" + pageProps.host);
4307
+ case 11:
4303
4308
  response = _context.sent;
4304
- if (response != null && response.status == 200) {
4305
- pageProps.oemCompanyId = response.data;
4306
- }
4309
+ _context.next = 14;
4310
+ return response.json();
4311
+ case 14:
4312
+ pageProps.oemCompanyId = _context.sent;
4313
+ case 15:
4307
4314
  return _context.abrupt("return", pageProps);
4308
- case 12:
4315
+ case 16:
4309
4316
  case "end":
4310
4317
  return _context.stop();
4311
4318
  }
4312
4319
  }, _callee);
4313
4320
  }));
4314
- return function setupOEMProps(_x, _x2, _x3) {
4315
- return _ref.apply(this, arguments);
4321
+ return function setupOEMProps(_x) {
4322
+ return _ref2.apply(this, arguments);
4316
4323
  };
4317
4324
  }();
4318
4325
  exports.setupOEMProps = setupOEMProps;
4319
- function HeaderRecords(_ref2) {
4320
- var pageProps = _ref2.pageProps;
4326
+ function HeaderRecords(_ref3) {
4327
+ var pageProps = _ref3.pageProps;
4321
4328
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, pageProps != null && pageProps.host != null && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("link", {
4322
4329
  href: process.env.apiUri + "/api/WhiteLabel/GetDataFromRecord?domain=" + pageProps.host,
4323
4330
  rel: "stylesheet"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "authscape",
3
- "version": "1.0.299",
3
+ "version": "1.0.302",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,30 +1,30 @@
1
1
  import React, { useEffect, useState, useRef } from 'react';
2
2
 
3
- export const setupOEMProps = async (apiUri, Component, ctx) => {
3
+ export const setupOEMProps = async ({Component, ctx}) => {
4
4
 
5
5
  let pageProps = {};
6
-
6
+
7
7
  if (Component.getInitialProps) {
8
8
  pageProps = await Component.getInitialProps(ctx);
9
9
  }
10
-
11
- let host = ctx.req.headers.host;
12
- if (host.includes("localhost"))
13
- {
14
- pageProps.host = "http://" + ctx.req.headers.host;
15
- }
16
- else
10
+
11
+ if (ctx.req != null)
17
12
  {
18
- pageProps.host = "https://" + ctx.req.headers.host;
13
+ let host = ctx.req.headers.host;
14
+ if (host.includes("localhost"))
15
+ {
16
+ pageProps.host = "http://" + ctx.req.headers.host;
17
+ }
18
+ else
19
+ {
20
+ pageProps.host = "https://" + ctx.req.headers.host;
21
+ }
22
+
23
+ // get the companyId
24
+ const response = await fetch(process.env.apiUri + "/api/WhiteLabel/GetCompanyIdFromDomain?domain=" + pageProps.host);
25
+ pageProps.oemCompanyId = await response.json();
19
26
  }
20
-
21
- // get the companyId
22
- let response = await apiService().get(apiUri + "/api/WhiteLabel/GetCompanyIdFromDomain?domain=" + pageProps.host);
23
- if (response != null && response.status == 200)
24
- {
25
- pageProps.oemCompanyId = response.data;
26
- }
27
-
27
+
28
28
  return pageProps;
29
29
  }
30
30