@paroicms/site-generator-plugin 0.17.0 → 0.17.1
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.
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isObj } from "@paroicms/public-anywhere-lib";
|
|
1
2
|
import { ApiError } from "@paroicms/public-server-lib";
|
|
2
3
|
import { nanoid } from "nanoid";
|
|
3
4
|
import { getInvalidSessionError } from "../db/db-read.queries.js";
|
|
@@ -32,11 +33,12 @@ export async function renewSessionCommand(ctx, command) {
|
|
|
32
33
|
payload = verify(command.sessionToken, ctx.jwtSecret, { ignoreExpiration: true });
|
|
33
34
|
}
|
|
34
35
|
catch (error) {
|
|
35
|
-
if (error.name === "JsonWebTokenError")
|
|
36
|
+
if (isObj(error) && error.name === "JsonWebTokenError") {
|
|
36
37
|
throw new ApiError("Invalid session token", 401);
|
|
38
|
+
}
|
|
37
39
|
throw error;
|
|
38
40
|
}
|
|
39
|
-
if (!payload || !("sessionId" in payload) || typeof payload.sessionId !== "string") {
|
|
41
|
+
if (!isObj(payload) || !("sessionId" in payload) || typeof payload.sessionId !== "string") {
|
|
40
42
|
throw new ApiError("Invalid session token", 401);
|
|
41
43
|
}
|
|
42
44
|
const sessionId = payload.sessionId;
|
|
@@ -62,13 +64,15 @@ export async function verifySessionToken(ctx, token) {
|
|
|
62
64
|
payload = verify(token, ctx.jwtSecret);
|
|
63
65
|
}
|
|
64
66
|
catch (error) {
|
|
65
|
-
if (error
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
if (isObj(error)) {
|
|
68
|
+
if (error.name === "TokenExpiredError")
|
|
69
|
+
throw new ApiError("Session token expired", 401);
|
|
70
|
+
if (error.name === "JsonWebTokenError")
|
|
71
|
+
throw new ApiError("Invalid session token", 401);
|
|
72
|
+
}
|
|
69
73
|
throw error;
|
|
70
74
|
}
|
|
71
|
-
if (!payload || !("sessionId" in payload) || typeof payload.sessionId !== "string") {
|
|
75
|
+
if (!isObj(payload) || !("sessionId" in payload) || typeof payload.sessionId !== "string") {
|
|
72
76
|
throw new ApiError("Invalid session token", 401);
|
|
73
77
|
}
|
|
74
78
|
const sessionId = payload.sessionId;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { ensureDirectory } from "@paroicms/internal-server-lib";
|
|
2
|
+
import { isObj, messageOf } from "@paroicms/public-anywhere-lib";
|
|
1
3
|
import { readFile, writeFile } from "node:fs/promises";
|
|
2
4
|
import { join } from "node:path";
|
|
3
|
-
import { ensureDirectory } from "@paroicms/internal-server-lib";
|
|
4
|
-
import { messageOf } from "@paroicms/public-anywhere-lib";
|
|
5
5
|
import { estimateTokenCount } from "./llm-tokens.js";
|
|
6
6
|
const debugSep = "\n\n========================\n\n";
|
|
7
7
|
export async function debugLlmOutput(ctx, llmTaskName, llmModelName, stepHandle, llmInput) {
|
|
@@ -97,7 +97,7 @@ async function readDebugLlmOutputs(ctx, options) {
|
|
|
97
97
|
return { outputs, llmReport };
|
|
98
98
|
}
|
|
99
99
|
catch (error) {
|
|
100
|
-
if (error.code !== "ENOENT") {
|
|
100
|
+
if (!isObj(error) || error.code !== "ENOENT") {
|
|
101
101
|
logger.error(`Error reading debug output from "${debugFile}": ${messageOf(error)}`);
|
|
102
102
|
}
|
|
103
103
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isObj } from "@paroicms/public-anywhere-lib";
|
|
1
2
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
2
3
|
import { dirname, join } from "node:path";
|
|
3
4
|
import { getPredefinedFields } from "../lib/create-prompt.js";
|
|
@@ -187,7 +188,7 @@ async function ensureDirectory(dirPath, { recursive = false } = {}) {
|
|
|
187
188
|
await mkdir(dirPath, { recursive });
|
|
188
189
|
}
|
|
189
190
|
catch (e) {
|
|
190
|
-
if (e.code !== "EEXIST")
|
|
191
|
+
if (!isObj(e) || e.code !== "EEXIST")
|
|
191
192
|
throw e;
|
|
192
193
|
}
|
|
193
194
|
}
|