authscape 1.0.724 → 1.0.728

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
@@ -8122,102 +8122,109 @@ function YesNoDialog(_ref) {
8122
8122
  }
8123
8123
  "use strict";
8124
8124
 
8125
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
8125
8126
  Object.defineProperty(exports, "__esModule", {
8126
8127
  value: true
8127
8128
  });
8128
- exports.GET = GET;
8129
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
8129
+ exports.createSitemapRoute = createSitemapRoute;
8130
8130
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
8131
8131
  function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
8132
8132
  function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
8133
8133
  /**
8134
8134
  * AuthScape Sitemap - App Router Implementation
8135
8135
  * This file contains the complete sitemap logic for Next.js App Router (Route Handlers)
8136
- * Users will re-export this from their app/sitemap.xml/route.js file
8136
+ * Users will import and call createSitemapRoute from their app/sitemap.xml/route.js file
8137
8137
  */
8138
- function GET(_x) {
8139
- return _GET.apply(this, arguments);
8140
- }
8141
- function _GET() {
8142
- _GET = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
8143
- var url, protocol, host, domain, encodedDomain, apiUrl, response, sitemap;
8144
- return _regeneratorRuntime().wrap(function _callee$(_context) {
8145
- while (1) switch (_context.prev = _context.next) {
8146
- case 0:
8147
- _context.prev = 0;
8148
- // Get the domain from the request
8149
- url = new URL(request.url);
8150
- protocol = request.headers.get('x-forwarded-proto') || url.protocol.replace(':', '');
8151
- host = request.headers.get('host') || url.host;
8152
- domain = "".concat(protocol, "://").concat(host); // URL encode the domain for the API request
8153
- encodedDomain = encodeURIComponent(domain); // Make a basic HTTP GET request
8154
- apiUrl = process.env.apiUri;
8155
- if (apiUrl) {
8156
- _context.next = 10;
8157
- break;
8158
- }
8159
- console.error('AuthScape Sitemap Error: apiUri is not configured in environment variables');
8160
- return _context.abrupt("return", new Response('Sitemap configuration error: API URI not set', {
8161
- status: 500,
8162
- headers: {
8163
- 'Content-Type': 'text/plain'
8164
- }
8165
- }));
8166
- case 10:
8167
- _context.next = 12;
8168
- return fetch("".concat(apiUrl, "/api/Sitemap?domain=").concat(encodedDomain));
8169
- case 12:
8170
- response = _context.sent;
8171
- if (response.ok) {
8172
- _context.next = 15;
8173
- break;
8174
- }
8175
- throw new Error("API request failed with status ".concat(response.status));
8176
- case 15:
8177
- _context.next = 17;
8178
- return response.text();
8179
- case 17:
8180
- sitemap = _context.sent;
8181
- return _context.abrupt("return", new Response(sitemap, {
8182
- status: 200,
8183
- headers: {
8184
- 'Content-Type': 'text/xml; charset=utf-8',
8185
- 'Cache-Control': 'public, s-maxage=86400, stale-while-revalidate'
8138
+
8139
+ /**
8140
+ * Creates a sitemap route handler with the provided API URI
8141
+ * @param {string} apiUri - The AuthScape API base URI (from process.env.apiUri)
8142
+ * @returns {Function} GET route handler function
8143
+ */
8144
+ function createSitemapRoute(apiUri) {
8145
+ return /*#__PURE__*/function () {
8146
+ var _GET = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(request) {
8147
+ var url, protocol, host, domain, encodedDomain, response, sitemap;
8148
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
8149
+ while (1) switch (_context.prev = _context.next) {
8150
+ case 0:
8151
+ _context.prev = 0;
8152
+ // Get the domain from the request
8153
+ url = new URL(request.url);
8154
+ protocol = request.headers.get('x-forwarded-proto') || url.protocol.replace(':', '');
8155
+ host = request.headers.get('host') || url.host;
8156
+ domain = "".concat(protocol, "://").concat(host); // URL encode the domain for the API request
8157
+ encodedDomain = encodeURIComponent(domain);
8158
+ if (apiUri) {
8159
+ _context.next = 9;
8160
+ break;
8186
8161
  }
8187
- }));
8188
- case 21:
8189
- _context.prev = 21;
8190
- _context.t0 = _context["catch"](0);
8191
- console.error('AuthScape Sitemap Error:', _context.t0);
8192
- return _context.abrupt("return", new Response('Error generating sitemap', {
8193
- status: 500,
8194
- headers: {
8195
- 'Content-Type': 'text/plain'
8162
+ console.error('AuthScape Sitemap Error: apiUri is not configured in environment variables');
8163
+ return _context.abrupt("return", new Response('Sitemap configuration error: API URI not set. Please ensure apiUri is defined in your next.config.js env object or .env.local file.', {
8164
+ status: 500,
8165
+ headers: {
8166
+ 'Content-Type': 'text/plain'
8167
+ }
8168
+ }));
8169
+ case 9:
8170
+ _context.next = 11;
8171
+ return fetch("".concat(apiUri, "/api/Sitemap?domain=").concat(encodedDomain));
8172
+ case 11:
8173
+ response = _context.sent;
8174
+ if (response.ok) {
8175
+ _context.next = 14;
8176
+ break;
8196
8177
  }
8197
- }));
8198
- case 25:
8199
- case "end":
8200
- return _context.stop();
8201
- }
8202
- }, _callee, null, [[0, 21]]);
8203
- }));
8204
- return _GET.apply(this, arguments);
8178
+ throw new Error("API request failed with status ".concat(response.status));
8179
+ case 14:
8180
+ _context.next = 16;
8181
+ return response.text();
8182
+ case 16:
8183
+ sitemap = _context.sent;
8184
+ return _context.abrupt("return", new Response(sitemap, {
8185
+ status: 200,
8186
+ headers: {
8187
+ 'Content-Type': 'text/xml; charset=utf-8',
8188
+ 'Cache-Control': 'public, s-maxage=86400, stale-while-revalidate'
8189
+ }
8190
+ }));
8191
+ case 20:
8192
+ _context.prev = 20;
8193
+ _context.t0 = _context["catch"](0);
8194
+ console.error('AuthScape Sitemap Error:', _context.t0);
8195
+ return _context.abrupt("return", new Response('Error generating sitemap', {
8196
+ status: 500,
8197
+ headers: {
8198
+ 'Content-Type': 'text/plain'
8199
+ }
8200
+ }));
8201
+ case 24:
8202
+ case "end":
8203
+ return _context.stop();
8204
+ }
8205
+ }, _callee, null, [[0, 20]]);
8206
+ }));
8207
+ function GET(_x) {
8208
+ return _GET.apply(this, arguments);
8209
+ }
8210
+ return GET;
8211
+ }();
8205
8212
  }
8206
8213
  "use strict";
8207
8214
 
8215
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
8208
8216
  Object.defineProperty(exports, "__esModule", {
8209
8217
  value: true
8210
8218
  });
8211
- exports["default"] = Sitemap;
8212
- exports.getServerSideProps = getServerSideProps;
8213
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
8219
+ exports.Sitemap = Sitemap;
8220
+ exports.createSitemapHandler = createSitemapHandler;
8214
8221
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
8215
8222
  function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
8216
8223
  function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
8217
8224
  /**
8218
8225
  * AuthScape Sitemap - Pages Router Implementation
8219
8226
  * This file contains the complete sitemap logic for Next.js Pages Router
8220
- * Users will re-export this from their pages/sitemap.xml.js file
8227
+ * Users will import and call createSitemapHandler from their pages/sitemap.xml.js file
8221
8228
  */
8222
8229
 
8223
8230
  // Empty component - sitemap is generated server-side only
@@ -8225,79 +8232,84 @@ function Sitemap() {
8225
8232
  return null;
8226
8233
  }
8227
8234
 
8228
- // Server-side sitemap generation
8229
- function getServerSideProps(_x) {
8230
- return _getServerSideProps.apply(this, arguments);
8231
- }
8232
- function _getServerSideProps() {
8233
- _getServerSideProps = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
8234
- var req, res, protocol, host, domain, encodedDomain, apiUrl, response, sitemap;
8235
- return _regeneratorRuntime().wrap(function _callee$(_context) {
8236
- while (1) switch (_context.prev = _context.next) {
8237
- case 0:
8238
- req = _ref.req, res = _ref.res;
8239
- _context.prev = 1;
8240
- // Get the domain from the request
8241
- protocol = req.headers['x-forwarded-proto'] || 'http';
8242
- host = req.headers.host;
8243
- domain = "".concat(protocol, "://").concat(host); // URL encode the domain for the API request
8244
- encodedDomain = encodeURIComponent(domain); // Make a basic HTTP GET request
8245
- apiUrl = process.env.apiUri;
8246
- if (apiUrl) {
8247
- _context.next = 14;
8248
- break;
8249
- }
8250
- console.error('AuthScape Sitemap Error: apiUri is not configured in environment variables');
8251
- res.statusCode = 500;
8252
- res.setHeader('Content-Type', 'text/plain');
8253
- res.write('Sitemap configuration error: API URI not set');
8254
- res.end();
8255
- return _context.abrupt("return", {
8256
- props: {}
8257
- });
8258
- case 14:
8259
- _context.next = 16;
8260
- return fetch("".concat(apiUrl, "/api/Sitemap?domain=").concat(encodedDomain));
8261
- case 16:
8262
- response = _context.sent;
8263
- if (response.ok) {
8264
- _context.next = 19;
8265
- break;
8266
- }
8267
- throw new Error("API request failed with status ".concat(response.status));
8268
- case 19:
8269
- _context.next = 21;
8270
- return response.text();
8271
- case 21:
8272
- sitemap = _context.sent;
8273
- // Set the appropriate headers for XML
8274
- res.setHeader('Content-Type', 'text/xml; charset=utf-8');
8275
- res.setHeader('Cache-Control', 'public, s-maxage=86400, stale-while-revalidate');
8235
+ /**
8236
+ * Creates a sitemap handler with the provided API URI
8237
+ * @param {string} apiUri - The AuthScape API base URI (from process.env.apiUri)
8238
+ * @returns {Function} getServerSideProps function
8239
+ */
8240
+ function createSitemapHandler(apiUri) {
8241
+ return /*#__PURE__*/function () {
8242
+ var _getServerSideProps = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
8243
+ var req, res, protocol, host, domain, encodedDomain, response, sitemap;
8244
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
8245
+ while (1) switch (_context.prev = _context.next) {
8246
+ case 0:
8247
+ req = _ref.req, res = _ref.res;
8248
+ _context.prev = 1;
8249
+ // Get the domain from the request
8250
+ protocol = req.headers['x-forwarded-proto'] || 'http';
8251
+ host = req.headers.host;
8252
+ domain = "".concat(protocol, "://").concat(host); // URL encode the domain for the API request
8253
+ encodedDomain = encodeURIComponent(domain);
8254
+ if (apiUri) {
8255
+ _context.next = 13;
8256
+ break;
8257
+ }
8258
+ console.error('AuthScape Sitemap Error: apiUri is not configured in environment variables');
8259
+ res.statusCode = 500;
8260
+ res.setHeader('Content-Type', 'text/plain');
8261
+ res.write('Sitemap configuration error: API URI not set. Please ensure apiUri is defined in your next.config.js env object or .env.local file.');
8262
+ res.end();
8263
+ return _context.abrupt("return", {
8264
+ props: {}
8265
+ });
8266
+ case 13:
8267
+ _context.next = 15;
8268
+ return fetch("".concat(apiUri, "/api/Sitemap?domain=").concat(encodedDomain));
8269
+ case 15:
8270
+ response = _context.sent;
8271
+ if (response.ok) {
8272
+ _context.next = 18;
8273
+ break;
8274
+ }
8275
+ throw new Error("API request failed with status ".concat(response.status));
8276
+ case 18:
8277
+ _context.next = 20;
8278
+ return response.text();
8279
+ case 20:
8280
+ sitemap = _context.sent;
8281
+ // Set the appropriate headers for XML
8282
+ res.setHeader('Content-Type', 'text/xml; charset=utf-8');
8283
+ res.setHeader('Cache-Control', 'public, s-maxage=86400, stale-while-revalidate');
8276
8284
 
8277
- // Send the XML response
8278
- res.write(sitemap);
8279
- res.end();
8280
- return _context.abrupt("return", {
8281
- props: {}
8282
- });
8283
- case 29:
8284
- _context.prev = 29;
8285
- _context.t0 = _context["catch"](1);
8286
- console.error('AuthScape Sitemap Error:', _context.t0);
8287
- res.statusCode = 500;
8288
- res.setHeader('Content-Type', 'text/plain');
8289
- res.write('Error generating sitemap');
8290
- res.end();
8291
- return _context.abrupt("return", {
8292
- props: {}
8293
- });
8294
- case 37:
8295
- case "end":
8296
- return _context.stop();
8297
- }
8298
- }, _callee, null, [[1, 29]]);
8299
- }));
8300
- return _getServerSideProps.apply(this, arguments);
8285
+ // Send the XML response
8286
+ res.write(sitemap);
8287
+ res.end();
8288
+ return _context.abrupt("return", {
8289
+ props: {}
8290
+ });
8291
+ case 28:
8292
+ _context.prev = 28;
8293
+ _context.t0 = _context["catch"](1);
8294
+ console.error('AuthScape Sitemap Error:', _context.t0);
8295
+ res.statusCode = 500;
8296
+ res.setHeader('Content-Type', 'text/plain');
8297
+ res.write('Error generating sitemap');
8298
+ res.end();
8299
+ return _context.abrupt("return", {
8300
+ props: {}
8301
+ });
8302
+ case 36:
8303
+ case "end":
8304
+ return _context.stop();
8305
+ }
8306
+ }, _callee, null, [[1, 28]]);
8307
+ }));
8308
+ function getServerSideProps(_x) {
8309
+ return _getServerSideProps.apply(this, arguments);
8310
+ }
8311
+ return getServerSideProps;
8312
+ }();
8301
8313
  }
8302
8314
  "use strict";
8303
8315
 
@@ -9502,7 +9514,8 @@ function _generateSitemap() {
9502
9514
  case 0:
9503
9515
  _context2.prev = 0;
9504
9516
  // Get the domain from the request
9505
- protocol = req.headers['x-forwarded-proto'] || 'http';
9517
+ // Check multiple headers to determine the protocol
9518
+ protocol = req.headers['x-forwarded-proto'] || req.headers['x-forwarded-protocol'] || (req.connection && req.connection.encrypted ? 'https' : null) || (req.headers.referer && req.headers.referer.startsWith('https') ? 'https' : null) || 'https'; // Default to https as most production sites use SSL
9506
9519
  host = req.headers.host;
9507
9520
  domain = "".concat(protocol, "://").concat(host); // URL encode the domain for the API request
9508
9521
  encodedDomain = encodeURIComponent(domain); // Make a basic HTTP GET request to AuthScape API
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "authscape",
3
- "version": "1.0.724",
3
+ "version": "1.0.728",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -1,58 +1,62 @@
1
1
  /**
2
2
  * AuthScape Sitemap - App Router Implementation
3
3
  * This file contains the complete sitemap logic for Next.js App Router (Route Handlers)
4
- * Users will re-export this from their app/sitemap.xml/route.js file
4
+ * Users will import and call createSitemapRoute from their app/sitemap.xml/route.js file
5
5
  */
6
6
 
7
- export async function GET(request) {
8
- try {
9
- // Get the domain from the request
10
- const url = new URL(request.url);
11
- const protocol = request.headers.get('x-forwarded-proto') || url.protocol.replace(':', '');
12
- const host = request.headers.get('host') || url.host;
13
- const domain = `${protocol}://${host}`;
14
-
15
- // URL encode the domain for the API request
16
- const encodedDomain = encodeURIComponent(domain);
17
-
18
- // Make a basic HTTP GET request
19
- const apiUrl = process.env.apiUri;
7
+ /**
8
+ * Creates a sitemap route handler with the provided API URI
9
+ * @param {string} apiUri - The AuthScape API base URI (from process.env.apiUri)
10
+ * @returns {Function} GET route handler function
11
+ */
12
+ export function createSitemapRoute(apiUri) {
13
+ return async function GET(request) {
14
+ try {
15
+ // Get the domain from the request
16
+ const url = new URL(request.url);
17
+ const protocol = request.headers.get('x-forwarded-proto') || url.protocol.replace(':', '');
18
+ const host = request.headers.get('host') || url.host;
19
+ const domain = `${protocol}://${host}`;
20
+
21
+ // URL encode the domain for the API request
22
+ const encodedDomain = encodeURIComponent(domain);
23
+
24
+ if (!apiUri) {
25
+ console.error('AuthScape Sitemap Error: apiUri is not configured in environment variables');
26
+ return new Response('Sitemap configuration error: API URI not set. Please ensure apiUri is defined in your next.config.js env object or .env.local file.', {
27
+ status: 500,
28
+ headers: {
29
+ 'Content-Type': 'text/plain',
30
+ },
31
+ });
32
+ }
33
+
34
+ const response = await fetch(`${apiUri}/api/Sitemap?domain=${encodedDomain}`);
35
+
36
+ if (!response.ok) {
37
+ throw new Error(`API request failed with status ${response.status}`);
38
+ }
39
+
40
+ // Get the sitemap XML
41
+ const sitemap = await response.text();
42
+
43
+ // Return the XML response with appropriate headers
44
+ return new Response(sitemap, {
45
+ status: 200,
46
+ headers: {
47
+ 'Content-Type': 'text/xml; charset=utf-8',
48
+ 'Cache-Control': 'public, s-maxage=86400, stale-while-revalidate',
49
+ },
50
+ });
51
+ } catch (error) {
52
+ console.error('AuthScape Sitemap Error:', error);
20
53
 
21
- if (!apiUrl) {
22
- console.error('AuthScape Sitemap Error: apiUri is not configured in environment variables');
23
- return new Response('Sitemap configuration error: API URI not set', {
54
+ return new Response('Error generating sitemap', {
24
55
  status: 500,
25
56
  headers: {
26
57
  'Content-Type': 'text/plain',
27
58
  },
28
59
  });
29
60
  }
30
-
31
- const response = await fetch(`${apiUrl}/api/Sitemap?domain=${encodedDomain}`);
32
-
33
- if (!response.ok) {
34
- throw new Error(`API request failed with status ${response.status}`);
35
- }
36
-
37
- // Get the sitemap XML
38
- const sitemap = await response.text();
39
-
40
- // Return the XML response with appropriate headers
41
- return new Response(sitemap, {
42
- status: 200,
43
- headers: {
44
- 'Content-Type': 'text/xml; charset=utf-8',
45
- 'Cache-Control': 'public, s-maxage=86400, stale-while-revalidate',
46
- },
47
- });
48
- } catch (error) {
49
- console.error('AuthScape Sitemap Error:', error);
50
-
51
- return new Response('Error generating sitemap', {
52
- status: 500,
53
- headers: {
54
- 'Content-Type': 'text/plain',
55
- },
56
- });
57
- }
61
+ };
58
62
  }
@@ -1,67 +1,70 @@
1
1
  /**
2
2
  * AuthScape Sitemap - Pages Router Implementation
3
3
  * This file contains the complete sitemap logic for Next.js Pages Router
4
- * Users will re-export this from their pages/sitemap.xml.js file
4
+ * Users will import and call createSitemapHandler from their pages/sitemap.xml.js file
5
5
  */
6
6
 
7
7
  // Empty component - sitemap is generated server-side only
8
- export default function Sitemap() {
8
+ export function Sitemap() {
9
9
  return null;
10
10
  }
11
11
 
12
- // Server-side sitemap generation
13
- export async function getServerSideProps({ req, res }) {
14
- try {
15
- // Get the domain from the request
16
- const protocol = req.headers['x-forwarded-proto'] || 'http';
17
- const host = req.headers.host;
18
- const domain = `${protocol}://${host}`;
12
+ /**
13
+ * Creates a sitemap handler with the provided API URI
14
+ * @param {string} apiUri - The AuthScape API base URI (from process.env.apiUri)
15
+ * @returns {Function} getServerSideProps function
16
+ */
17
+ export function createSitemapHandler(apiUri) {
18
+ return async function getServerSideProps({ req, res }) {
19
+ try {
20
+ // Get the domain from the request
21
+ const protocol = req.headers['x-forwarded-proto'] || 'http';
22
+ const host = req.headers.host;
23
+ const domain = `${protocol}://${host}`;
19
24
 
20
- // URL encode the domain for the API request
21
- const encodedDomain = encodeURIComponent(domain);
25
+ // URL encode the domain for the API request
26
+ const encodedDomain = encodeURIComponent(domain);
22
27
 
23
- // Make a basic HTTP GET request
24
- const apiUrl = process.env.apiUri;
28
+ if (!apiUri) {
29
+ console.error('AuthScape Sitemap Error: apiUri is not configured in environment variables');
30
+ res.statusCode = 500;
31
+ res.setHeader('Content-Type', 'text/plain');
32
+ res.write('Sitemap configuration error: API URI not set. Please ensure apiUri is defined in your next.config.js env object or .env.local file.');
33
+ res.end();
34
+ return { props: {} };
35
+ }
25
36
 
26
- if (!apiUrl) {
27
- console.error('AuthScape Sitemap Error: apiUri is not configured in environment variables');
28
- res.statusCode = 500;
29
- res.setHeader('Content-Type', 'text/plain');
30
- res.write('Sitemap configuration error: API URI not set');
31
- res.end();
32
- return { props: {} };
33
- }
37
+ let response = await fetch(`${apiUri}/api/Sitemap?domain=${encodedDomain}`);
34
38
 
35
- let response = await fetch(`${apiUrl}/api/Sitemap?domain=${encodedDomain}`);
39
+ if (!response.ok) {
40
+ throw new Error(`API request failed with status ${response.status}`);
41
+ }
36
42
 
37
- if (!response.ok) {
38
- throw new Error(`API request failed with status ${response.status}`);
39
- }
43
+ // Generate the sitemap XML
44
+ const sitemap = await response.text();
40
45
 
41
- // Generate the sitemap XML
42
- const sitemap = await response.text();
46
+ // Set the appropriate headers for XML
47
+ res.setHeader('Content-Type', 'text/xml; charset=utf-8');
48
+ res.setHeader('Cache-Control', 'public, s-maxage=86400, stale-while-revalidate');
43
49
 
44
- // Set the appropriate headers for XML
45
- res.setHeader('Content-Type', 'text/xml; charset=utf-8');
46
- res.setHeader('Cache-Control', 'public, s-maxage=86400, stale-while-revalidate');
47
-
48
- // Send the XML response
49
- res.write(sitemap);
50
- res.end();
50
+ // Send the XML response
51
+ res.write(sitemap);
52
+ res.end();
51
53
 
52
- return {
53
- props: {},
54
- };
55
- } catch (error) {
56
- console.error('AuthScape Sitemap Error:', error);
54
+ return {
55
+ props: {},
56
+ };
57
+ } catch (error) {
58
+ console.error('AuthScape Sitemap Error:', error);
57
59
 
58
- res.statusCode = 500;
59
- res.setHeader('Content-Type', 'text/plain');
60
- res.write('Error generating sitemap');
61
- res.end();
60
+ res.statusCode = 500;
61
+ res.setHeader('Content-Type', 'text/plain');
62
+ res.write('Error generating sitemap');
63
+ res.end();
62
64
 
63
- return {
64
- props: {},
65
- };
66
- }
65
+ return {
66
+ props: {},
67
+ };
68
+ }
69
+ };
67
70
  }
@@ -10,12 +10,18 @@ const path = require('path');
10
10
 
11
11
  // Template for Pages Router
12
12
  const PAGES_ROUTER_TEMPLATE = `// Auto-generated by AuthScape - Do not edit manually
13
- export { default, getServerSideProps } from 'authscape/src/lib/sitemap';
13
+ import { Sitemap, createSitemapHandler } from 'authscape/src/lib/sitemap';
14
+
15
+ export default Sitemap;
16
+
17
+ export const getServerSideProps = createSitemapHandler(process.env.apiUri);
14
18
  `;
15
19
 
16
20
  // Template for App Router
17
21
  const APP_ROUTER_TEMPLATE = `// Auto-generated by AuthScape - Do not edit manually
18
- export { GET } from 'authscape/src/lib/sitemap-route';
22
+ import { createSitemapRoute } from 'authscape/src/lib/sitemap-route';
23
+
24
+ export const GET = createSitemapRoute(process.env.apiUri);
19
25
  `;
20
26
 
21
27
  function detectProjectStructure() {
@@ -13,7 +13,14 @@
13
13
  export async function generateSitemap(req, res, apiUri) {
14
14
  try {
15
15
  // Get the domain from the request
16
- const protocol = req.headers['x-forwarded-proto'] || 'http';
16
+ // Check multiple headers to determine the protocol
17
+ const protocol =
18
+ req.headers['x-forwarded-proto'] ||
19
+ req.headers['x-forwarded-protocol'] ||
20
+ (req.connection && req.connection.encrypted ? 'https' : null) ||
21
+ (req.headers.referer && req.headers.referer.startsWith('https') ? 'https' : null) ||
22
+ 'https'; // Default to https as most production sites use SSL
23
+
17
24
  const host = req.headers.host;
18
25
  const domain = `${protocol}://${host}`;
19
26