@server/next 0.27.10 → 0.27.12

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 (3) hide show
  1. package/index.d.ts +1 -3
  2. package/index.js +8 -8
  3. package/package.json +2 -2
package/index.d.ts CHANGED
@@ -46,9 +46,7 @@ type KVStore = {
46
46
  name?: string;
47
47
  prefix: (key: string) => KVStore;
48
48
  get: <T = SerializableValue>(key: string) => Promise<T>;
49
- set: <T = SerializableValue>(key: string, value: T, options?: {
50
- expires: string | number;
51
- }) => Promise<void | string>;
49
+ set: <T = SerializableValue>(key: string, value: T, expires?: string | number) => Promise<void | string>;
52
50
  has: (key: string) => Promise<boolean>;
53
51
  del: (key: string) => Promise<void | string>;
54
52
  keys: () => Promise<string[]>;
package/index.js CHANGED
@@ -101,7 +101,7 @@ var createSession = async (user, ctx) => {
101
101
  await session2.set(
102
102
  id,
103
103
  { id, strategy, provider, user: user.email },
104
- { expires: "1w" }
104
+ "1w"
105
105
  );
106
106
  if (!strategy) throw new Error(`Invalid strategy "${strategy}"`);
107
107
  if (strategy.includes("token")) {
@@ -343,7 +343,7 @@ var callback = async (ctx) => {
343
343
  created: profile.created_at
344
344
  });
345
345
  await store.set(auth2.user, user);
346
- await session2.set(auth2.id, auth2, { expires: "1w" });
346
+ await session2.set(auth2.id, auth2, "1w");
347
347
  if (auth2.strategy.includes("token")) {
348
348
  return status(201).json({ ...user, token: auth2.id });
349
349
  }
@@ -668,7 +668,7 @@ function config(options = {}) {
668
668
  // src/helpers/cors.ts
669
669
  var localhost = /^https?:\/\/localhost(:\d+)?$/;
670
670
  function cors(config2, origin = "") {
671
- origin = origin.toLowerCase();
671
+ origin = origin?.toLowerCase();
672
672
  if (config2 === true) return origin || null;
673
673
  if (config2 === "*") return "*";
674
674
  if (!origin) return null;
@@ -693,6 +693,9 @@ parse.month = parse.b = parse.y / 12;
693
693
  function parse(str) {
694
694
  if (str === null || str === void 0) return null;
695
695
  if (typeof str === "number") return str;
696
+ if (typeof str !== "string") {
697
+ throw new Error(`Not a string: ${str} (${typeof str})`);
698
+ }
696
699
  str = str.toLowerCase().replace(/[,_]/g, "");
697
700
  const [_, value, units] = times.exec(str) || [];
698
701
  if (!units) return null;
@@ -1308,13 +1311,10 @@ async function verify(password, hash3) {
1308
1311
  // src/auth/findSessionId.ts
1309
1312
  var validateToken = (authorization) => {
1310
1313
  const [type2, id] = authorization.trim().split(" ");
1311
- if (!type2 || !id) {
1312
- throw ServerError_default.AUTH_INVALID_HEADER({ type: type2 });
1313
- }
1314
- if (type2.toLowerCase() !== "bearer") {
1314
+ if (!type2 || type2.toLowerCase() !== "bearer") {
1315
1315
  throw ServerError_default.AUTH_INVALID_HEADER({ type: type2 });
1316
1316
  }
1317
- if (id.length !== 16) {
1317
+ if (!id || id.length !== 16) {
1318
1318
  throw ServerError_default.AUTH_INVALID_TOKEN();
1319
1319
  }
1320
1320
  return id;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@server/next",
3
- "version": "0.27.10",
3
+ "version": "0.27.12",
4
4
  "description": "A fully-fledged web server with routing, file uploads, sessions, static files, schema validation, websockets, testing, etc.",
5
5
  "homepage": "https://server-js.com/",
6
6
  "repository": "https://github.com/franciscop/server-next.git",
@@ -49,7 +49,7 @@
49
49
  "@types/node": "^24.10.0",
50
50
  "check-dts": "^0.8.2",
51
51
  "jest": "^29.7.0",
52
- "polystore": "^0.14.1",
52
+ "polystore": "^0.18.0",
53
53
  "tsup": "^8.5.1",
54
54
  "typescript": "^5.9.3"
55
55
  },