openlearn-next 0.3.1 → 0.3.3

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.
Files changed (30) hide show
  1. package/cli.mjs +2 -0
  2. package/dist/assets/{BatchPickerModal-of9a5EJz.js → BatchPickerModal-2jsnyMYM.js} +1 -1
  3. package/dist/assets/{ClassesView-CefnsjZ8.js → ClassesView-DUnZ5nFa.js} +1 -1
  4. package/dist/assets/{CloudDriveModal-DgVQLbO5.js → CloudDriveModal-DXJktxoq.js} +1 -1
  5. package/dist/assets/{CourseManagement-Cxhc784Q.js → CourseManagement-ChHr_wNd.js} +1 -1
  6. package/dist/assets/{CourseWizardModal-Da6PKhnU.js → CourseWizardModal-RAaltA_q.js} +1 -1
  7. package/dist/assets/{Dashboard-LWbFbup4.js → Dashboard-BMXQhpnj.js} +1 -1
  8. package/dist/assets/{ExportWeightModal-Cyg1zMEd.js → ExportWeightModal-BwW76Kqo.js} +1 -1
  9. package/dist/assets/{HelpView-CvpgBpdr.js → HelpView-BqUqq-QE.js} +1 -1
  10. package/dist/assets/{ImportLessonsModal-CfWIrW1K.js → ImportLessonsModal-DHLxg68P.js} +1 -1
  11. package/dist/assets/{InteractiveCoursewareViewer-CS5BqfJZ.js → InteractiveCoursewareViewer-C8uZcebL.js} +1 -1
  12. package/dist/assets/{InteractiveWhiteboard-U23CsqGo.js → InteractiveWhiteboard-C2HAx6zv.js} +1 -1
  13. package/dist/assets/{LazyCourseware-DXL9IxZO.js → LazyCourseware-C1bH8aKj.js} +1 -1
  14. package/dist/assets/{LazyWhiteboard-CtkzSFtN.js → LazyWhiteboard-DE9sMBUF.js} +1 -1
  15. package/dist/assets/{LessonEditorView-Bfxf4VVB.js → LessonEditorView-mIxHUfYb.js} +1 -1
  16. package/dist/assets/{LiveClassroomView-DHzCM4qQ.js → LiveClassroomView-DNGZaCC8.js} +1 -1
  17. package/dist/assets/{NotificationDetailModal-BxrpnlWV.js → NotificationDetailModal-CPrHxHcC.js} +1 -1
  18. package/dist/assets/{PluginView-12qYzmnq.js → PluginView-DSLBfNDj.js} +1 -1
  19. package/dist/assets/{QuizGeneratorModal-DfZI40Ii.js → QuizGeneratorModal-CoeGXKck.js} +1 -1
  20. package/dist/assets/{StudentAssignmentView-BP6zbHuM.js → StudentAssignmentView-V7Kp6TnP.js} +1 -1
  21. package/dist/assets/{StudentLessonView-DEpMzrH2.js → StudentLessonView-IZVXM5kz.js} +1 -1
  22. package/dist/assets/{StudentPreviewModal-DCmai53s.js → StudentPreviewModal-DwumAjWX.js} +1 -1
  23. package/dist/assets/{StudentView-CcGlfW25.js → StudentView-3mCaDwFB.js} +1 -1
  24. package/dist/assets/{SystemResourceLibraryModal-BzHw1edT.js → SystemResourceLibraryModal-B6ms798K.js} +1 -1
  25. package/dist/assets/{TeacherView-Dw6mKwcv.js → TeacherView-BVd_ZMFH.js} +1 -1
  26. package/dist/assets/{index-CYzNsYZB.js → index-Cwf8LQbY.js} +3 -3
  27. package/dist/assets/{index-C8sCKzmN.js → index-Vr-_Vpp3.js} +1 -1
  28. package/dist/index.html +1 -1
  29. package/dist/server.cjs +50 -19
  30. package/package.json +2 -2
@@ -1,2 +1,2 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-B-YxO39A.css"])))=>i.map(i=>d[i]);
2
- import{_ as e}from"./vendor-pdf-Cp-cYteE.js";import{r as t}from"./vendor-react-0Lg0vA-4.js";const i=t.lazy(()=>e(()=>import("./InteractiveCoursewareViewer-CS5BqfJZ.js"),__vite__mapDeps([0])).then(r=>({default:r.InteractiveCoursewareViewer})));export{i as CoursewareViewer};
2
+ import{_ as e}from"./vendor-pdf-Cp-cYteE.js";import{r as t}from"./vendor-react-0Lg0vA-4.js";const i=t.lazy(()=>e(()=>import("./InteractiveCoursewareViewer-C8uZcebL.js"),__vite__mapDeps([0])).then(r=>({default:r.InteractiveCoursewareViewer})));export{i as CoursewareViewer};
package/dist/index.html CHANGED
@@ -15,7 +15,7 @@
15
15
  }
16
16
  }
17
17
  </script>
18
- <script type="module" crossorigin src="/assets/index-CYzNsYZB.js"></script>
18
+ <script type="module" crossorigin src="/assets/index-Cwf8LQbY.js"></script>
19
19
  <link rel="stylesheet" crossorigin href="/assets/index-B-YxO39A.css">
20
20
  </head>
21
21
  <body>
package/dist/server.cjs CHANGED
@@ -3337,7 +3337,6 @@ var import_express3 = __toESM(require("express"), 1);
3337
3337
  var import_path15 = __toESM(require("path"), 1);
3338
3338
  var import_fs14 = __toESM(require("fs"), 1);
3339
3339
  var import_dotenv = __toESM(require("dotenv"), 1);
3340
- var import_vite = require("vite");
3341
3340
  var import_http = require("http");
3342
3341
  var import_socket = require("socket.io");
3343
3342
 
@@ -7678,7 +7677,6 @@ var import_express = __toESM(require("express"), 1);
7678
7677
  var import_node_url = require("node:url");
7679
7678
 
7680
7679
  // packages/core/esm-loader/install-utils.ts
7681
- var esbuild = __toESM(require("esbuild"), 1);
7682
7680
  var import_jszip = __toESM(require("jszip"), 1);
7683
7681
  var fs3 = __toESM(require("fs"), 1);
7684
7682
  var os2 = __toESM(require("os"), 1);
@@ -7686,6 +7684,7 @@ var path4 = __toESM(require("path"), 1);
7686
7684
  var import_uuid10 = require("uuid");
7687
7685
  var MAX_UNCOMPRESSED_SIZE = 300 * 1024 * 1024;
7688
7686
  async function bundlePlugin(entryCode, resolveDir) {
7687
+ const esbuild = await import("esbuild");
7689
7688
  const result = await esbuild.build({
7690
7689
  stdin: {
7691
7690
  contents: entryCode,
@@ -7701,8 +7700,8 @@ async function bundlePlugin(entryCode, resolveDir) {
7701
7700
  plugins: [
7702
7701
  {
7703
7702
  name: "openlearn-token-enforcer",
7704
- setup(build2) {
7705
- build2.onResolve({ filter: /.*/ }, (args) => {
7703
+ setup(build) {
7704
+ build.onResolve({ filter: /.*/ }, (args) => {
7706
7705
  if (args.path.includes("core/di/interfaces")) {
7707
7706
  const tsPath = path4.resolve(process.cwd(), "packages/core/di/interfaces.ts");
7708
7707
  if (fs3.existsSync(tsPath)) {
@@ -24541,6 +24540,36 @@ async function startServer() {
24541
24540
  app.use(import_express3.default.urlencoded({ limit: "10mb", extended: true }));
24542
24541
  app.use("/uploads", import_express3.default.static(import_path15.default.join(process.cwd(), "uploads")));
24543
24542
  app.use("/plugins", import_express3.default.static(import_path15.default.join(process.cwd(), "plugins")));
24543
+ const configuredOrigins = process.env.ALLOWED_ORIGINS ? process.env.ALLOWED_ORIGINS.split(",").map((s) => s.trim()).filter(Boolean) : [];
24544
+ const isOriginAllowed = (origin, hostHeader) => {
24545
+ if (!origin) return true;
24546
+ if (configuredOrigins.length > 0) {
24547
+ if (configuredOrigins.includes("*") || configuredOrigins.includes(origin)) {
24548
+ return true;
24549
+ }
24550
+ }
24551
+ if (hostHeader) {
24552
+ try {
24553
+ const originUrl = new URL(origin);
24554
+ if (originUrl.host === hostHeader) {
24555
+ return true;
24556
+ }
24557
+ } catch {
24558
+ }
24559
+ }
24560
+ try {
24561
+ const originUrl = new URL(origin);
24562
+ const hostname = originUrl.hostname;
24563
+ if (hostname === "localhost" || hostname === "127.0.0.1" || hostname === "[::1]" || hostname === "0.0.0.0") {
24564
+ return true;
24565
+ }
24566
+ } catch {
24567
+ }
24568
+ if (process.env.NODE_ENV !== "production") {
24569
+ return true;
24570
+ }
24571
+ return false;
24572
+ };
24544
24573
  app.use((req, res, next) => {
24545
24574
  const origin = req.headers.origin;
24546
24575
  if (origin === "null" || origin === void 0) {
@@ -24548,6 +24577,12 @@ async function startServer() {
24548
24577
  res.setHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, PATCH, OPTIONS");
24549
24578
  res.setHeader("Access-Control-Allow-Headers", "Content-Type, Authorization, X-Requested-With");
24550
24579
  res.setHeader("Access-Control-Max-Age", "86400");
24580
+ } else if (isOriginAllowed(origin, req.headers.host)) {
24581
+ res.setHeader("Access-Control-Allow-Origin", origin);
24582
+ res.setHeader("Access-Control-Allow-Credentials", "true");
24583
+ res.setHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, PATCH, OPTIONS");
24584
+ res.setHeader("Access-Control-Allow-Headers", "Content-Type, Authorization, X-Requested-With");
24585
+ res.setHeader("Access-Control-Max-Age", "86400");
24551
24586
  }
24552
24587
  if (req.method === "OPTIONS") {
24553
24588
  return res.sendStatus(204);
@@ -24570,21 +24605,16 @@ async function startServer() {
24570
24605
  activityRegistry
24571
24606
  };
24572
24607
  const httpServer = (0, import_http.createServer)(app);
24573
- const allowedOrigins = process.env.ALLOWED_ORIGINS ? process.env.ALLOWED_ORIGINS.split(",").map((s) => s.trim()) : process.env.NODE_ENV === "production" ? [] : ["http://localhost:5173", "http://localhost:9000", "http://localhost:4173"];
24574
24608
  const io = new import_socket.Server(httpServer, {
24575
- cors: {
24576
- origin: (origin, callback) => {
24577
- if (!origin) return callback(null, true);
24578
- if (allowedOrigins.length === 0) {
24579
- return callback(new Error("CORS not allowed"));
24580
- }
24581
- if (allowedOrigins.includes(origin) || allowedOrigins.includes("*")) {
24582
- return callback(null, true);
24583
- }
24584
- return callback(new Error("Not allowed by CORS"));
24585
- },
24586
- methods: ["GET", "POST"],
24587
- credentials: true
24609
+ cors: (req, callback) => {
24610
+ const origin = req.headers.origin;
24611
+ const host = req.headers.host;
24612
+ const allowed = isOriginAllowed(origin, host);
24613
+ callback(null, {
24614
+ origin: allowed ? origin || true : false,
24615
+ methods: ["GET", "POST"],
24616
+ credentials: true
24617
+ });
24588
24618
  }
24589
24619
  });
24590
24620
  io.use((socket, next) => {
@@ -24640,7 +24670,8 @@ async function startServer() {
24640
24670
  setupRealtimeBridge({ eventBus: kernelContainer.eventBus, io, db: kernelContainer.db });
24641
24671
  setupPresence({ io, eventBus: kernelContainer.eventBus });
24642
24672
  if (process.env.NODE_ENV !== "production") {
24643
- const vite = await (0, import_vite.createServer)({
24673
+ const { createServer: createViteServer } = await import("vite");
24674
+ const vite = await createViteServer({
24644
24675
  server: {
24645
24676
  middlewareMode: true,
24646
24677
  hmr: process.env.DISABLE_HMR !== "true",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openlearn-next",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "private": false,
5
5
  "description": "A plugin-driven Educational OS / LMS platform with AI agent teaching assistant",
6
6
  "keywords": [
@@ -61,6 +61,7 @@
61
61
  "better-sqlite3": "^12.11.1",
62
62
  "chokidar": "^5.0.0",
63
63
  "dotenv": "^17.2.3",
64
+ "esbuild": "^0.25.0",
64
65
  "express": "^4.21.2",
65
66
  "express-rate-limit": "^8.5.2",
66
67
  "helmet": "^8.2.0",
@@ -106,7 +107,6 @@
106
107
  "@typescript-eslint/parser": "^8.62.0",
107
108
  "@vitejs/plugin-react": "^5.0.4",
108
109
  "autoprefixer": "^10.4.21",
109
- "esbuild": "^0.25.0",
110
110
  "eslint": "^10.5.0",
111
111
  "eslint-plugin-react-hooks": "^7.1.1",
112
112
  "globals": "^17.8.0",