authscape 1.0.716 → 1.0.720
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/.claude/settings.local.json +11 -0
- package/index.js +406 -0
- package/package.json +3 -2
- package/readme.md +103 -1
- package/src/lib/sitemap-route.js +58 -0
- package/src/lib/sitemap.js +67 -0
- package/src/scripts/postinstall.js +107 -0
- package/src/services/sitemapService.js +86 -0
package/index.js
CHANGED
|
@@ -8122,6 +8122,280 @@ function YesNoDialog(_ref) {
|
|
|
8122
8122
|
}
|
|
8123
8123
|
"use strict";
|
|
8124
8124
|
|
|
8125
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8126
|
+
value: true
|
|
8127
|
+
});
|
|
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); }
|
|
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
|
+
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
|
+
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
|
+
/**
|
|
8134
|
+
* AuthScape Sitemap - App Router Implementation
|
|
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
|
|
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'
|
|
8186
|
+
}
|
|
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'
|
|
8196
|
+
}
|
|
8197
|
+
}));
|
|
8198
|
+
case 25:
|
|
8199
|
+
case "end":
|
|
8200
|
+
return _context.stop();
|
|
8201
|
+
}
|
|
8202
|
+
}, _callee, null, [[0, 21]]);
|
|
8203
|
+
}));
|
|
8204
|
+
return _GET.apply(this, arguments);
|
|
8205
|
+
}
|
|
8206
|
+
"use strict";
|
|
8207
|
+
|
|
8208
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8209
|
+
value: true
|
|
8210
|
+
});
|
|
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); }
|
|
8214
|
+
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
|
+
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
|
+
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
|
+
/**
|
|
8218
|
+
* AuthScape Sitemap - Pages Router Implementation
|
|
8219
|
+
* 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
|
|
8221
|
+
*/
|
|
8222
|
+
|
|
8223
|
+
// Empty component - sitemap is generated server-side only
|
|
8224
|
+
function Sitemap() {
|
|
8225
|
+
return null;
|
|
8226
|
+
}
|
|
8227
|
+
|
|
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');
|
|
8276
|
+
|
|
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);
|
|
8301
|
+
}
|
|
8302
|
+
#!/usr/bin/env node
|
|
8303
|
+
|
|
8304
|
+
/**
|
|
8305
|
+
* AuthScape Post-Install Script
|
|
8306
|
+
* Automatically sets up sitemap.xml for Next.js projects (both Pages Router and App Router)
|
|
8307
|
+
*/
|
|
8308
|
+
"use strict";
|
|
8309
|
+
|
|
8310
|
+
var fs = require('fs');
|
|
8311
|
+
var path = require('path');
|
|
8312
|
+
|
|
8313
|
+
// Template for Pages Router
|
|
8314
|
+
var PAGES_ROUTER_TEMPLATE = "// Auto-generated by AuthScape - Do not edit manually\nexport { default, getServerSideProps } from 'authscape/lib/sitemap';\n";
|
|
8315
|
+
|
|
8316
|
+
// Template for App Router
|
|
8317
|
+
var APP_ROUTER_TEMPLATE = "// Auto-generated by AuthScape - Do not edit manually\nexport { GET } from 'authscape/lib/sitemap-route';\n";
|
|
8318
|
+
function detectProjectStructure() {
|
|
8319
|
+
// Get the parent directory where the user ran npm install
|
|
8320
|
+
// This goes up from node_modules/authscape to the project root
|
|
8321
|
+
var projectRoot = path.resolve(process.cwd(), '../..');
|
|
8322
|
+
|
|
8323
|
+
// Check for App Router (prioritize newer approach)
|
|
8324
|
+
var appDirs = [path.join(projectRoot, 'app'), path.join(projectRoot, 'src', 'app')];
|
|
8325
|
+
for (var _i = 0, _appDirs = appDirs; _i < _appDirs.length; _i++) {
|
|
8326
|
+
var dir = _appDirs[_i];
|
|
8327
|
+
if (fs.existsSync(dir)) {
|
|
8328
|
+
return {
|
|
8329
|
+
type: 'app',
|
|
8330
|
+
baseDir: dir,
|
|
8331
|
+
sitemapPath: path.join(dir, 'sitemap.xml'),
|
|
8332
|
+
filePath: path.join(dir, 'sitemap.xml', 'route.js')
|
|
8333
|
+
};
|
|
8334
|
+
}
|
|
8335
|
+
}
|
|
8336
|
+
|
|
8337
|
+
// Check for Pages Router
|
|
8338
|
+
var pagesDirs = [path.join(projectRoot, 'pages'), path.join(projectRoot, 'src', 'pages')];
|
|
8339
|
+
for (var _i2 = 0, _pagesDirs = pagesDirs; _i2 < _pagesDirs.length; _i2++) {
|
|
8340
|
+
var _dir = _pagesDirs[_i2];
|
|
8341
|
+
if (fs.existsSync(_dir)) {
|
|
8342
|
+
return {
|
|
8343
|
+
type: 'pages',
|
|
8344
|
+
baseDir: _dir,
|
|
8345
|
+
sitemapPath: path.join(_dir, 'sitemap.xml.js'),
|
|
8346
|
+
filePath: path.join(_dir, 'sitemap.xml.js')
|
|
8347
|
+
};
|
|
8348
|
+
}
|
|
8349
|
+
}
|
|
8350
|
+
return null;
|
|
8351
|
+
}
|
|
8352
|
+
function setupSitemap() {
|
|
8353
|
+
var structure = detectProjectStructure();
|
|
8354
|
+
if (!structure) {
|
|
8355
|
+
console.log('⚠️ Next.js pages/app directory not found. Skipping sitemap setup.');
|
|
8356
|
+
console.log(' To set up manually, visit: https://authscape.com/docs/sitemap');
|
|
8357
|
+
return;
|
|
8358
|
+
}
|
|
8359
|
+
|
|
8360
|
+
// Check if sitemap file already exists
|
|
8361
|
+
if (fs.existsSync(structure.filePath)) {
|
|
8362
|
+
// File exists, don't overwrite
|
|
8363
|
+
return;
|
|
8364
|
+
}
|
|
8365
|
+
try {
|
|
8366
|
+
if (structure.type === 'app') {
|
|
8367
|
+
// App Router: Create directory first, then route.js inside it
|
|
8368
|
+
if (!fs.existsSync(structure.sitemapPath)) {
|
|
8369
|
+
fs.mkdirSync(structure.sitemapPath, {
|
|
8370
|
+
recursive: true
|
|
8371
|
+
});
|
|
8372
|
+
}
|
|
8373
|
+
fs.writeFileSync(structure.filePath, APP_ROUTER_TEMPLATE, 'utf8');
|
|
8374
|
+
console.log('✅ AuthScape sitemap configured at /sitemap.xml (App Router)');
|
|
8375
|
+
} else {
|
|
8376
|
+
// Pages Router: Just create the file
|
|
8377
|
+
fs.writeFileSync(structure.filePath, PAGES_ROUTER_TEMPLATE, 'utf8');
|
|
8378
|
+
console.log('✅ AuthScape sitemap configured at /sitemap.xml (Pages Router)');
|
|
8379
|
+
}
|
|
8380
|
+
} catch (error) {
|
|
8381
|
+
// Silent failure - don't break the install
|
|
8382
|
+
console.log('⚠️ Could not auto-configure sitemap:', error.message);
|
|
8383
|
+
console.log(' To set up manually, visit: https://authscape.com/docs/sitemap');
|
|
8384
|
+
}
|
|
8385
|
+
}
|
|
8386
|
+
|
|
8387
|
+
// Run the setup
|
|
8388
|
+
try {
|
|
8389
|
+
setupSitemap();
|
|
8390
|
+
} catch (error) {
|
|
8391
|
+
// Completely silent failure to avoid breaking npm install
|
|
8392
|
+
// Only log if there's an unexpected error
|
|
8393
|
+
if (process.env.DEBUG) {
|
|
8394
|
+
console.error('AuthScape postinstall error:', error);
|
|
8395
|
+
}
|
|
8396
|
+
}
|
|
8397
|
+
"use strict";
|
|
8398
|
+
|
|
8125
8399
|
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); }
|
|
8126
8400
|
Object.defineProperty(exports, "__esModule", {
|
|
8127
8401
|
value: true
|
|
@@ -9284,6 +9558,138 @@ var signInValidator = exports.signInValidator = /*#__PURE__*/function () {
|
|
|
9284
9558
|
}();
|
|
9285
9559
|
"use strict";
|
|
9286
9560
|
|
|
9561
|
+
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); }
|
|
9562
|
+
Object.defineProperty(exports, "__esModule", {
|
|
9563
|
+
value: true
|
|
9564
|
+
});
|
|
9565
|
+
exports.createSitemapHandler = createSitemapHandler;
|
|
9566
|
+
exports["default"] = void 0;
|
|
9567
|
+
exports.generateSitemap = generateSitemap;
|
|
9568
|
+
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; }
|
|
9569
|
+
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); }
|
|
9570
|
+
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); }); }; }
|
|
9571
|
+
/**
|
|
9572
|
+
* AuthScape Sitemap Service
|
|
9573
|
+
* Provides automatic sitemap.xml generation by fetching from AuthScape API
|
|
9574
|
+
*/
|
|
9575
|
+
/**
|
|
9576
|
+
* Generates a sitemap XML response by fetching from the AuthScape API
|
|
9577
|
+
* @param {Object} req - Next.js request object
|
|
9578
|
+
* @param {Object} res - Next.js response object
|
|
9579
|
+
* @param {string} apiUri - The AuthScape API base URI (from process.env.apiUri)
|
|
9580
|
+
* @returns {Promise<void>}
|
|
9581
|
+
*/
|
|
9582
|
+
function generateSitemap(_x, _x2, _x3) {
|
|
9583
|
+
return _generateSitemap.apply(this, arguments);
|
|
9584
|
+
}
|
|
9585
|
+
/**
|
|
9586
|
+
* Higher-order function that returns a getServerSideProps function
|
|
9587
|
+
* configured with the API URI from environment variables
|
|
9588
|
+
*
|
|
9589
|
+
* @param {string} apiUri - Optional API URI override (defaults to process.env.apiUri)
|
|
9590
|
+
* @returns {Function} getServerSideProps function
|
|
9591
|
+
*/
|
|
9592
|
+
function _generateSitemap() {
|
|
9593
|
+
_generateSitemap = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(req, res, apiUri) {
|
|
9594
|
+
var protocol, host, domain, encodedDomain, response, sitemap;
|
|
9595
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
9596
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
9597
|
+
case 0:
|
|
9598
|
+
_context2.prev = 0;
|
|
9599
|
+
// Get the domain from the request
|
|
9600
|
+
protocol = req.headers['x-forwarded-proto'] || 'http';
|
|
9601
|
+
host = req.headers.host;
|
|
9602
|
+
domain = "".concat(protocol, "://").concat(host); // URL encode the domain for the API request
|
|
9603
|
+
encodedDomain = encodeURIComponent(domain); // Make a basic HTTP GET request to AuthScape API
|
|
9604
|
+
_context2.next = 7;
|
|
9605
|
+
return fetch("".concat(apiUri, "/api/Sitemap?domain=").concat(encodedDomain));
|
|
9606
|
+
case 7:
|
|
9607
|
+
response = _context2.sent;
|
|
9608
|
+
if (response.ok) {
|
|
9609
|
+
_context2.next = 10;
|
|
9610
|
+
break;
|
|
9611
|
+
}
|
|
9612
|
+
throw new Error("API request failed with status ".concat(response.status));
|
|
9613
|
+
case 10:
|
|
9614
|
+
_context2.next = 12;
|
|
9615
|
+
return response.text();
|
|
9616
|
+
case 12:
|
|
9617
|
+
sitemap = _context2.sent;
|
|
9618
|
+
// Set the appropriate headers for XML
|
|
9619
|
+
res.setHeader('Content-Type', 'text/xml; charset=utf-8');
|
|
9620
|
+
res.setHeader('Cache-Control', 'public, s-maxage=86400, stale-while-revalidate');
|
|
9621
|
+
|
|
9622
|
+
// Send the XML response
|
|
9623
|
+
res.write(sitemap);
|
|
9624
|
+
res.end();
|
|
9625
|
+
return _context2.abrupt("return", {
|
|
9626
|
+
props: {}
|
|
9627
|
+
});
|
|
9628
|
+
case 20:
|
|
9629
|
+
_context2.prev = 20;
|
|
9630
|
+
_context2.t0 = _context2["catch"](0);
|
|
9631
|
+
console.error('AuthScape Sitemap Error:', _context2.t0);
|
|
9632
|
+
|
|
9633
|
+
// Return 500 error
|
|
9634
|
+
res.statusCode = 500;
|
|
9635
|
+
res.setHeader('Content-Type', 'text/plain');
|
|
9636
|
+
res.write('Error generating sitemap');
|
|
9637
|
+
res.end();
|
|
9638
|
+
return _context2.abrupt("return", {
|
|
9639
|
+
props: {}
|
|
9640
|
+
});
|
|
9641
|
+
case 28:
|
|
9642
|
+
case "end":
|
|
9643
|
+
return _context2.stop();
|
|
9644
|
+
}
|
|
9645
|
+
}, _callee2, null, [[0, 20]]);
|
|
9646
|
+
}));
|
|
9647
|
+
return _generateSitemap.apply(this, arguments);
|
|
9648
|
+
}
|
|
9649
|
+
function createSitemapHandler(apiUri) {
|
|
9650
|
+
return /*#__PURE__*/function () {
|
|
9651
|
+
var _getServerSideProps = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
|
|
9652
|
+
var req, res, apiBaseUri;
|
|
9653
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
9654
|
+
while (1) switch (_context.prev = _context.next) {
|
|
9655
|
+
case 0:
|
|
9656
|
+
req = _ref.req, res = _ref.res;
|
|
9657
|
+
apiBaseUri = apiUri || process.env.apiUri;
|
|
9658
|
+
if (apiBaseUri) {
|
|
9659
|
+
_context.next = 9;
|
|
9660
|
+
break;
|
|
9661
|
+
}
|
|
9662
|
+
console.error('AuthScape Sitemap Error: apiUri is not configured');
|
|
9663
|
+
res.statusCode = 500;
|
|
9664
|
+
res.setHeader('Content-Type', 'text/plain');
|
|
9665
|
+
res.write('Sitemap configuration error: API URI not set');
|
|
9666
|
+
res.end();
|
|
9667
|
+
return _context.abrupt("return", {
|
|
9668
|
+
props: {}
|
|
9669
|
+
});
|
|
9670
|
+
case 9:
|
|
9671
|
+
_context.next = 11;
|
|
9672
|
+
return generateSitemap(req, res, apiBaseUri);
|
|
9673
|
+
case 11:
|
|
9674
|
+
return _context.abrupt("return", _context.sent);
|
|
9675
|
+
case 12:
|
|
9676
|
+
case "end":
|
|
9677
|
+
return _context.stop();
|
|
9678
|
+
}
|
|
9679
|
+
}, _callee);
|
|
9680
|
+
}));
|
|
9681
|
+
function getServerSideProps(_x4) {
|
|
9682
|
+
return _getServerSideProps.apply(this, arguments);
|
|
9683
|
+
}
|
|
9684
|
+
return getServerSideProps;
|
|
9685
|
+
}();
|
|
9686
|
+
}
|
|
9687
|
+
var _default = exports["default"] = {
|
|
9688
|
+
generateSitemap: generateSitemap,
|
|
9689
|
+
createSitemapHandler: createSitemapHandler
|
|
9690
|
+
};
|
|
9691
|
+
"use strict";
|
|
9692
|
+
|
|
9287
9693
|
Object.defineProperty(exports, "__esModule", {
|
|
9288
9694
|
value: true
|
|
9289
9695
|
});
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "authscape",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.720",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
8
|
-
"build": "npx babel src --out-file index.js"
|
|
8
|
+
"build": "npx babel src --out-file index.js",
|
|
9
|
+
"postinstall": "node src/scripts/postinstall.js || exit 0"
|
|
9
10
|
},
|
|
10
11
|
"author": "zuechb",
|
|
11
12
|
"license": "ISC",
|
package/readme.md
CHANGED
|
@@ -1 +1,103 @@
|
|
|
1
|
-
|
|
1
|
+
# AuthScape NPM Package
|
|
2
|
+
|
|
3
|
+
Complete authentication and user management solution for Next.js applications.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install authscape
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
See the main [AuthScape Documentation](https://authscape.com/docs) for complete setup instructions.
|
|
14
|
+
|
|
15
|
+
## Features
|
|
16
|
+
|
|
17
|
+
### Core Features
|
|
18
|
+
- OAuth2/PKCE Authentication
|
|
19
|
+
- Multi-tenant support
|
|
20
|
+
- User management
|
|
21
|
+
- Role-based permissions
|
|
22
|
+
- Analytics integration (GA4, Microsoft Clarity)
|
|
23
|
+
- Material-UI components
|
|
24
|
+
|
|
25
|
+
### Components
|
|
26
|
+
- Document Manager
|
|
27
|
+
- File Uploader
|
|
28
|
+
- Rich Text Editor
|
|
29
|
+
- Data Tables
|
|
30
|
+
- Stripe Payment Integration
|
|
31
|
+
- Google Maps Integration
|
|
32
|
+
- And more...
|
|
33
|
+
|
|
34
|
+
## Additional Features
|
|
35
|
+
|
|
36
|
+
### Sitemap Generation (NEW!)
|
|
37
|
+
|
|
38
|
+
Automatically generate SEO-friendly sitemaps for your Next.js application.
|
|
39
|
+
|
|
40
|
+
**Automatic setup on install:**
|
|
41
|
+
|
|
42
|
+
When you run `npm install authscape`, a sitemap is automatically configured at `/sitemap.xml` that syncs with your AuthScape content.
|
|
43
|
+
|
|
44
|
+
- Supports both Pages Router and App Router
|
|
45
|
+
- Automatically detects your Next.js project structure
|
|
46
|
+
- Works with both `pages/` and `src/pages/` layouts
|
|
47
|
+
- Works with both `app/` and `src/app/` layouts
|
|
48
|
+
|
|
49
|
+
**To disable:** Simply delete the auto-generated file:
|
|
50
|
+
- Pages Router: `pages/sitemap.xml.js`
|
|
51
|
+
- App Router: `app/sitemap.xml/route.js`
|
|
52
|
+
|
|
53
|
+
## Environment Variables
|
|
54
|
+
|
|
55
|
+
Required environment variables in your `.env.local`:
|
|
56
|
+
|
|
57
|
+
```env
|
|
58
|
+
apiUri=https://your-authscape-api.com
|
|
59
|
+
authorityUri=https://your-auth-server.com
|
|
60
|
+
client_id=your-client-id
|
|
61
|
+
client_secret=your-client-secret
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Optional analytics:
|
|
65
|
+
|
|
66
|
+
```env
|
|
67
|
+
googleAnalytics4=G-XXXXXXXXXX
|
|
68
|
+
microsoftClarityTrackingCode=xxxxxxxxxx
|
|
69
|
+
enableDatabaseAnalytics=true
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Usage Example
|
|
73
|
+
|
|
74
|
+
```javascript
|
|
75
|
+
// pages/_app.js
|
|
76
|
+
import { AuthScapeApp } from 'authscape';
|
|
77
|
+
import 'react-toastify/dist/ReactToastify.css';
|
|
78
|
+
|
|
79
|
+
function MyApp({ Component, pageProps }) {
|
|
80
|
+
return (
|
|
81
|
+
<AuthScapeApp
|
|
82
|
+
Component={Component}
|
|
83
|
+
pageProps={pageProps}
|
|
84
|
+
enforceLoggedIn={false}
|
|
85
|
+
enableAuth={true}
|
|
86
|
+
/>
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export default MyApp;
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Documentation
|
|
94
|
+
|
|
95
|
+
- [AuthScape Docs](https://authscape.com/docs) - Complete documentation
|
|
96
|
+
|
|
97
|
+
## Support
|
|
98
|
+
|
|
99
|
+
For issues or questions, contact AuthScape support or visit [authscape.com](https://authscape.com).
|
|
100
|
+
|
|
101
|
+
## License
|
|
102
|
+
|
|
103
|
+
ISC
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AuthScape Sitemap - App Router Implementation
|
|
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
|
|
5
|
+
*/
|
|
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;
|
|
20
|
+
|
|
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', {
|
|
24
|
+
status: 500,
|
|
25
|
+
headers: {
|
|
26
|
+
'Content-Type': 'text/plain',
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
}
|
|
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
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AuthScape Sitemap - Pages Router Implementation
|
|
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
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// Empty component - sitemap is generated server-side only
|
|
8
|
+
export default function Sitemap() {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
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}`;
|
|
19
|
+
|
|
20
|
+
// URL encode the domain for the API request
|
|
21
|
+
const encodedDomain = encodeURIComponent(domain);
|
|
22
|
+
|
|
23
|
+
// Make a basic HTTP GET request
|
|
24
|
+
const apiUrl = process.env.apiUri;
|
|
25
|
+
|
|
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
|
+
}
|
|
34
|
+
|
|
35
|
+
let response = await fetch(`${apiUrl}/api/Sitemap?domain=${encodedDomain}`);
|
|
36
|
+
|
|
37
|
+
if (!response.ok) {
|
|
38
|
+
throw new Error(`API request failed with status ${response.status}`);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Generate the sitemap XML
|
|
42
|
+
const sitemap = await response.text();
|
|
43
|
+
|
|
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();
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
props: {},
|
|
54
|
+
};
|
|
55
|
+
} catch (error) {
|
|
56
|
+
console.error('AuthScape Sitemap Error:', error);
|
|
57
|
+
|
|
58
|
+
res.statusCode = 500;
|
|
59
|
+
res.setHeader('Content-Type', 'text/plain');
|
|
60
|
+
res.write('Error generating sitemap');
|
|
61
|
+
res.end();
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
props: {},
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* AuthScape Post-Install Script
|
|
5
|
+
* Automatically sets up sitemap.xml for Next.js projects (both Pages Router and App Router)
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
|
|
11
|
+
// Template for Pages Router
|
|
12
|
+
const PAGES_ROUTER_TEMPLATE = `// Auto-generated by AuthScape - Do not edit manually
|
|
13
|
+
export { default, getServerSideProps } from 'authscape/lib/sitemap';
|
|
14
|
+
`;
|
|
15
|
+
|
|
16
|
+
// Template for App Router
|
|
17
|
+
const APP_ROUTER_TEMPLATE = `// Auto-generated by AuthScape - Do not edit manually
|
|
18
|
+
export { GET } from 'authscape/lib/sitemap-route';
|
|
19
|
+
`;
|
|
20
|
+
|
|
21
|
+
function detectProjectStructure() {
|
|
22
|
+
// Get the parent directory where the user ran npm install
|
|
23
|
+
// This goes up from node_modules/authscape to the project root
|
|
24
|
+
const projectRoot = path.resolve(process.cwd(), '../..');
|
|
25
|
+
|
|
26
|
+
// Check for App Router (prioritize newer approach)
|
|
27
|
+
const appDirs = [
|
|
28
|
+
path.join(projectRoot, 'app'),
|
|
29
|
+
path.join(projectRoot, 'src', 'app'),
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
for (const dir of appDirs) {
|
|
33
|
+
if (fs.existsSync(dir)) {
|
|
34
|
+
return {
|
|
35
|
+
type: 'app',
|
|
36
|
+
baseDir: dir,
|
|
37
|
+
sitemapPath: path.join(dir, 'sitemap.xml'),
|
|
38
|
+
filePath: path.join(dir, 'sitemap.xml', 'route.js'),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Check for Pages Router
|
|
44
|
+
const pagesDirs = [
|
|
45
|
+
path.join(projectRoot, 'pages'),
|
|
46
|
+
path.join(projectRoot, 'src', 'pages'),
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
for (const dir of pagesDirs) {
|
|
50
|
+
if (fs.existsSync(dir)) {
|
|
51
|
+
return {
|
|
52
|
+
type: 'pages',
|
|
53
|
+
baseDir: dir,
|
|
54
|
+
sitemapPath: path.join(dir, 'sitemap.xml.js'),
|
|
55
|
+
filePath: path.join(dir, 'sitemap.xml.js'),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function setupSitemap() {
|
|
64
|
+
const structure = detectProjectStructure();
|
|
65
|
+
|
|
66
|
+
if (!structure) {
|
|
67
|
+
console.log('⚠️ Next.js pages/app directory not found. Skipping sitemap setup.');
|
|
68
|
+
console.log(' To set up manually, visit: https://authscape.com/docs/sitemap');
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Check if sitemap file already exists
|
|
73
|
+
if (fs.existsSync(structure.filePath)) {
|
|
74
|
+
// File exists, don't overwrite
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
try {
|
|
79
|
+
if (structure.type === 'app') {
|
|
80
|
+
// App Router: Create directory first, then route.js inside it
|
|
81
|
+
if (!fs.existsSync(structure.sitemapPath)) {
|
|
82
|
+
fs.mkdirSync(structure.sitemapPath, { recursive: true });
|
|
83
|
+
}
|
|
84
|
+
fs.writeFileSync(structure.filePath, APP_ROUTER_TEMPLATE, 'utf8');
|
|
85
|
+
console.log('✅ AuthScape sitemap configured at /sitemap.xml (App Router)');
|
|
86
|
+
} else {
|
|
87
|
+
// Pages Router: Just create the file
|
|
88
|
+
fs.writeFileSync(structure.filePath, PAGES_ROUTER_TEMPLATE, 'utf8');
|
|
89
|
+
console.log('✅ AuthScape sitemap configured at /sitemap.xml (Pages Router)');
|
|
90
|
+
}
|
|
91
|
+
} catch (error) {
|
|
92
|
+
// Silent failure - don't break the install
|
|
93
|
+
console.log('⚠️ Could not auto-configure sitemap:', error.message);
|
|
94
|
+
console.log(' To set up manually, visit: https://authscape.com/docs/sitemap');
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Run the setup
|
|
99
|
+
try {
|
|
100
|
+
setupSitemap();
|
|
101
|
+
} catch (error) {
|
|
102
|
+
// Completely silent failure to avoid breaking npm install
|
|
103
|
+
// Only log if there's an unexpected error
|
|
104
|
+
if (process.env.DEBUG) {
|
|
105
|
+
console.error('AuthScape postinstall error:', error);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AuthScape Sitemap Service
|
|
3
|
+
* Provides automatic sitemap.xml generation by fetching from AuthScape API
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Generates a sitemap XML response by fetching from the AuthScape API
|
|
8
|
+
* @param {Object} req - Next.js request object
|
|
9
|
+
* @param {Object} res - Next.js response object
|
|
10
|
+
* @param {string} apiUri - The AuthScape API base URI (from process.env.apiUri)
|
|
11
|
+
* @returns {Promise<void>}
|
|
12
|
+
*/
|
|
13
|
+
export async function generateSitemap(req, res, apiUri) {
|
|
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}`;
|
|
19
|
+
|
|
20
|
+
// URL encode the domain for the API request
|
|
21
|
+
const encodedDomain = encodeURIComponent(domain);
|
|
22
|
+
|
|
23
|
+
// Make a basic HTTP GET request to AuthScape API
|
|
24
|
+
const response = await fetch(`${apiUri}/api/Sitemap?domain=${encodedDomain}`);
|
|
25
|
+
|
|
26
|
+
if (!response.ok) {
|
|
27
|
+
throw new Error(`API request failed with status ${response.status}`);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Get the sitemap XML from the API
|
|
31
|
+
const sitemap = await response.text();
|
|
32
|
+
|
|
33
|
+
// Set the appropriate headers for XML
|
|
34
|
+
res.setHeader('Content-Type', 'text/xml; charset=utf-8');
|
|
35
|
+
res.setHeader('Cache-Control', 'public, s-maxage=86400, stale-while-revalidate');
|
|
36
|
+
|
|
37
|
+
// Send the XML response
|
|
38
|
+
res.write(sitemap);
|
|
39
|
+
res.end();
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
props: {},
|
|
43
|
+
};
|
|
44
|
+
} catch (error) {
|
|
45
|
+
console.error('AuthScape Sitemap Error:', error);
|
|
46
|
+
|
|
47
|
+
// Return 500 error
|
|
48
|
+
res.statusCode = 500;
|
|
49
|
+
res.setHeader('Content-Type', 'text/plain');
|
|
50
|
+
res.write('Error generating sitemap');
|
|
51
|
+
res.end();
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
props: {},
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Higher-order function that returns a getServerSideProps function
|
|
61
|
+
* configured with the API URI from environment variables
|
|
62
|
+
*
|
|
63
|
+
* @param {string} apiUri - Optional API URI override (defaults to process.env.apiUri)
|
|
64
|
+
* @returns {Function} getServerSideProps function
|
|
65
|
+
*/
|
|
66
|
+
export function createSitemapHandler(apiUri) {
|
|
67
|
+
return async function getServerSideProps({ req, res }) {
|
|
68
|
+
const apiBaseUri = apiUri || process.env.apiUri;
|
|
69
|
+
|
|
70
|
+
if (!apiBaseUri) {
|
|
71
|
+
console.error('AuthScape Sitemap Error: apiUri is not configured');
|
|
72
|
+
res.statusCode = 500;
|
|
73
|
+
res.setHeader('Content-Type', 'text/plain');
|
|
74
|
+
res.write('Sitemap configuration error: API URI not set');
|
|
75
|
+
res.end();
|
|
76
|
+
return { props: {} };
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return await generateSitemap(req, res, apiBaseUri);
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export default {
|
|
84
|
+
generateSitemap,
|
|
85
|
+
createSitemapHandler
|
|
86
|
+
};
|