authscape 1.0.736 → 1.0.738

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
@@ -8144,7 +8144,7 @@ function _asyncToGenerator(n) { return function () { var t = this, e = arguments
8144
8144
  function createSitemapRoute(apiUri) {
8145
8145
  return /*#__PURE__*/function () {
8146
8146
  var _GET = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
8147
- var url, protocol, host, domain, encodedDomain, apiUrl, response, sitemap;
8147
+ var url, protocol, host, domain, encodedDomain, apiUrl, response, errorBody, sitemap;
8148
8148
  return _regeneratorRuntime().wrap(function _callee$(_context) {
8149
8149
  while (1) switch (_context.prev = _context.next) {
8150
8150
  case 0:
@@ -8174,19 +8174,28 @@ function createSitemapRoute(apiUri) {
8174
8174
  encodedDomain = encodeURIComponent(domain);
8175
8175
  apiUrl = "".concat(apiUri, "/api/Sitemap?domain=").concat(encodedDomain);
8176
8176
  console.log('Fetching sitemap from:', apiUrl);
8177
- _context.next = 13;
8177
+ console.log('Domain being sent:', domain);
8178
+ console.log('Encoded domain:', encodedDomain);
8179
+ _context.next = 15;
8178
8180
  return fetch(apiUrl);
8179
- case 13:
8181
+ case 15:
8180
8182
  response = _context.sent;
8181
8183
  if (response.ok) {
8182
- _context.next = 16;
8184
+ _context.next = 24;
8183
8185
  break;
8184
8186
  }
8185
- throw new Error("API request failed with status ".concat(response.status));
8186
- case 16:
8187
- _context.next = 18;
8187
+ console.error('API Response Status:', response.status);
8188
+ console.error('API Response StatusText:', response.statusText);
8189
+ _context.next = 21;
8188
8190
  return response.text();
8189
- case 18:
8191
+ case 21:
8192
+ errorBody = _context.sent;
8193
+ console.error('API Response Body:', errorBody);
8194
+ throw new Error("API request failed with status ".concat(response.status, ": ").concat(errorBody));
8195
+ case 24:
8196
+ _context.next = 26;
8197
+ return response.text();
8198
+ case 26:
8190
8199
  sitemap = _context.sent;
8191
8200
  console.log('Sitemap fetched successfully, length:', sitemap.length);
8192
8201
 
@@ -8198,8 +8207,8 @@ function createSitemapRoute(apiUri) {
8198
8207
  'Cache-Control': 'public, s-maxage=86400, stale-while-revalidate'
8199
8208
  }
8200
8209
  }));
8201
- case 23:
8202
- _context.prev = 23;
8210
+ case 31:
8211
+ _context.prev = 31;
8203
8212
  _context.t0 = _context["catch"](0);
8204
8213
  console.error('AuthScape Sitemap Error:', _context.t0);
8205
8214
  return _context.abrupt("return", new Response("Error generating sitemap: ".concat(_context.t0.message || _context.t0), {
@@ -8208,11 +8217,11 @@ function createSitemapRoute(apiUri) {
8208
8217
  'Content-Type': 'text/plain'
8209
8218
  }
8210
8219
  }));
8211
- case 27:
8220
+ case 35:
8212
8221
  case "end":
8213
8222
  return _context.stop();
8214
8223
  }
8215
- }, _callee, null, [[0, 23]]);
8224
+ }, _callee, null, [[0, 31]]);
8216
8225
  }));
8217
8226
  function GET(_x) {
8218
8227
  return _GET.apply(this, arguments);
@@ -9515,20 +9524,15 @@ function _generateSitemap() {
9515
9524
  while (1) switch (_context.prev = _context.next) {
9516
9525
  case 0:
9517
9526
  _context.prev = 0;
9518
- // Get the domain from the request
9519
- host = req.headers.host; // Determine protocol - same logic as PrivateLabelPageModule
9527
+ host = req.headers.host;
9520
9528
  if (host.includes("localhost")) {
9521
9529
  domain = "http://" + host;
9522
9530
  } else {
9523
9531
  domain = "https://" + host;
9524
9532
  }
9525
-
9526
- // URL encode the domain for the API request
9527
9533
  encodedDomain = encodeURIComponent(domain);
9528
9534
  apiUrl = "".concat(apiUri, "/api/Sitemap?domain=").concat(encodedDomain);
9529
9535
  console.log('Fetching sitemap from:', apiUrl);
9530
-
9531
- // Make a basic HTTP GET request to AuthScape API
9532
9536
  _context.next = 8;
9533
9537
  return fetch(apiUrl);
9534
9538
  case 8:
@@ -9545,7 +9549,7 @@ function _generateSitemap() {
9545
9549
  sitemap = _context.sent;
9546
9550
  console.log('Sitemap fetched successfully, length:', sitemap.length);
9547
9551
 
9548
- // Set status code and headers BEFORE writing
9552
+ // Set headers BEFORE writing
9549
9553
  res.statusCode = 200;
9550
9554
  res.setHeader('Content-Type', 'text/xml; charset=utf-8');
9551
9555
  res.setHeader('Cache-Control', 'public, s-maxage=86400, stale-while-revalidate');
@@ -9553,27 +9557,21 @@ function _generateSitemap() {
9553
9557
  // Write and end the response
9554
9558
  res.write(sitemap);
9555
9559
  res.end();
9556
- return _context.abrupt("return", {
9557
- props: {}
9558
- });
9559
- case 23:
9560
- _context.prev = 23;
9560
+ _context.next = 29;
9561
+ break;
9562
+ case 22:
9563
+ _context.prev = 22;
9561
9564
  _context.t0 = _context["catch"](0);
9562
9565
  console.error('AuthScape Sitemap Error:', _context.t0);
9563
-
9564
- // Set status code BEFORE headers and writing
9565
9566
  res.statusCode = 500;
9566
9567
  res.setHeader('Content-Type', 'text/plain');
9567
9568
  res.write("Error generating sitemap: ".concat(_context.t0.message || _context.t0));
9568
9569
  res.end();
9569
- return _context.abrupt("return", {
9570
- props: {}
9571
- });
9572
- case 31:
9570
+ case 29:
9573
9571
  case "end":
9574
9572
  return _context.stop();
9575
9573
  }
9576
- }, _callee, null, [[0, 23]]);
9574
+ }, _callee, null, [[0, 22]]);
9577
9575
  }));
9578
9576
  return _generateSitemap.apply(this, arguments);
9579
9577
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "authscape",
3
- "version": "1.0.736",
3
+ "version": "1.0.738",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -40,11 +40,17 @@ export function createSitemapRoute(apiUri) {
40
40
  const apiUrl = `${apiUri}/api/Sitemap?domain=${encodedDomain}`;
41
41
 
42
42
  console.log('Fetching sitemap from:', apiUrl);
43
+ console.log('Domain being sent:', domain);
44
+ console.log('Encoded domain:', encodedDomain);
43
45
 
44
46
  const response = await fetch(apiUrl);
45
47
 
46
48
  if (!response.ok) {
47
- throw new Error(`API request failed with status ${response.status}`);
49
+ console.error('API Response Status:', response.status);
50
+ console.error('API Response StatusText:', response.statusText);
51
+ const errorBody = await response.text();
52
+ console.error('API Response Body:', errorBody);
53
+ throw new Error(`API request failed with status ${response.status}: ${errorBody}`);
48
54
  }
49
55
 
50
56
  // Get the sitemap XML
@@ -12,11 +12,6 @@ const path = require('path');
12
12
  const PAGES_ROUTER_TEMPLATE = `// Auto-generated by AuthScape - Do not edit manually
13
13
  import { generateSitemap } from 'authscape/src/services/sitemapService';
14
14
 
15
- export default function Sitemap() {
16
- // This page is handled by getServerSideProps
17
- return null;
18
- }
19
-
20
15
  export async function getServerSideProps({ req, res }) {
21
16
  const apiBaseUri = process.env.apiUri;
22
17
 
@@ -29,7 +24,13 @@ export async function getServerSideProps({ req, res }) {
29
24
  return { props: {} };
30
25
  }
31
26
 
32
- return await generateSitemap(req, res, apiBaseUri);
27
+ await generateSitemap(req, res, apiBaseUri);
28
+
29
+ return { props: {} };
30
+ }
31
+
32
+ export default function Sitemap() {
33
+ return null;
33
34
  }
34
35
  `;
35
36
 
@@ -12,10 +12,8 @@
12
12
  */
13
13
  export async function generateSitemap(req, res, apiUri) {
14
14
  try {
15
- // Get the domain from the request
16
15
  const host = req.headers.host;
17
16
 
18
- // Determine protocol - same logic as PrivateLabelPageModule
19
17
  let domain;
20
18
  if (host.includes("localhost")) {
21
19
  domain = "http://" + host;
@@ -23,25 +21,22 @@ export async function generateSitemap(req, res, apiUri) {
23
21
  domain = "https://" + host;
24
22
  }
25
23
 
26
- // URL encode the domain for the API request
27
24
  const encodedDomain = encodeURIComponent(domain);
28
25
  const apiUrl = `${apiUri}/api/Sitemap?domain=${encodedDomain}`;
29
26
 
30
27
  console.log('Fetching sitemap from:', apiUrl);
31
28
 
32
- // Make a basic HTTP GET request to AuthScape API
33
29
  const response = await fetch(apiUrl);
34
30
 
35
31
  if (!response.ok) {
36
32
  throw new Error(`API request failed with status ${response.status}`);
37
33
  }
38
34
 
39
- // Get the sitemap XML from the API
40
35
  const sitemap = await response.text();
41
36
 
42
37
  console.log('Sitemap fetched successfully, length:', sitemap.length);
43
38
 
44
- // Set status code and headers BEFORE writing
39
+ // Set headers BEFORE writing
45
40
  res.statusCode = 200;
46
41
  res.setHeader('Content-Type', 'text/xml; charset=utf-8');
47
42
  res.setHeader('Cache-Control', 'public, s-maxage=86400, stale-while-revalidate');
@@ -50,21 +45,13 @@ export async function generateSitemap(req, res, apiUri) {
50
45
  res.write(sitemap);
51
46
  res.end();
52
47
 
53
- return {
54
- props: {},
55
- };
56
48
  } catch (error) {
57
49
  console.error('AuthScape Sitemap Error:', error);
58
50
 
59
- // Set status code BEFORE headers and writing
60
51
  res.statusCode = 500;
61
52
  res.setHeader('Content-Type', 'text/plain');
62
53
  res.write(`Error generating sitemap: ${error.message || error}`);
63
54
  res.end();
64
-
65
- return {
66
- props: {},
67
- };
68
55
  }
69
56
  }
70
57