authscape 1.0.299 → 1.0.300

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 = 13;
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,28 @@ 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 apiService().get(process.env.apiUri + "/api/WhiteLabel/GetCompanyIdFromDomain?domain=" + pageProps.host);
4307
+ case 11:
4303
4308
  response = _context.sent;
4304
4309
  if (response != null && response.status == 200) {
4305
4310
  pageProps.oemCompanyId = response.data;
4306
4311
  }
4312
+ case 13:
4307
4313
  return _context.abrupt("return", pageProps);
4308
- case 12:
4314
+ case 14:
4309
4315
  case "end":
4310
4316
  return _context.stop();
4311
4317
  }
4312
4318
  }, _callee);
4313
4319
  }));
4314
- return function setupOEMProps(_x, _x2, _x3) {
4315
- return _ref.apply(this, arguments);
4320
+ return function setupOEMProps(_x) {
4321
+ return _ref2.apply(this, arguments);
4316
4322
  };
4317
4323
  }();
4318
4324
  exports.setupOEMProps = setupOEMProps;
4319
- function HeaderRecords(_ref2) {
4320
- var pageProps = _ref2.pageProps;
4325
+ function HeaderRecords(_ref3) {
4326
+ var pageProps = _ref3.pageProps;
4321
4327
  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
4328
  href: process.env.apiUri + "/api/WhiteLabel/GetDataFromRecord?domain=" + pageProps.host,
4323
4329
  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.300",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,30 +1,33 @@
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
+ let response = await apiService().get(process.env.apiUri + "/api/WhiteLabel/GetCompanyIdFromDomain?domain=" + pageProps.host);
25
+ if (response != null && response.status == 200)
26
+ {
27
+ pageProps.oemCompanyId = response.data;
28
+ }
19
29
  }
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
-
30
+
28
31
  return pageProps;
29
32
  }
30
33