altcha-lib 2.0.2 → 2.1.0

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.
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -55,8 +55,7 @@ function create(options) {
55
55
  res.clearCookie(setCookie.name);
56
56
  }
57
57
  if (error && throwOnFailure) {
58
- res.status(403).json({ error });
59
- return;
58
+ throw Object.assign(new Error(error), { status: 403 });
60
59
  }
61
60
  next();
62
61
  });
@@ -14,7 +14,7 @@ export declare function create(options: AltchaOptions): {
14
14
  challengeHandler: (request: FastifyRequest, reply: FastifyReply) => Promise<never>;
15
15
  verifyHandler: (request: FastifyRequest, reply: FastifyReply) => Promise<never>;
16
16
  getPayloadFromRequest: (request: FastifyRequest, cookieName?: string) => Promise<string | undefined>;
17
- middleware: (options?: AltchaMiddlewareOptions) => (request: FastifyRequest, reply: FastifyReply) => Promise<undefined>;
17
+ middleware: (options?: AltchaMiddlewareOptions) => (request: FastifyRequest, reply: FastifyReply) => Promise<void>;
18
18
  verify: typeof verify;
19
19
  };
20
20
  declare const _default: {
@@ -68,7 +68,7 @@ function create(options) {
68
68
  deleteCookie(reply, setCookie.name, setCookie.path);
69
69
  }
70
70
  if (error && throwOnFailure) {
71
- return reply.code(403).send({ error });
71
+ throw Object.assign(new Error(error), { statusCode: 403 });
72
72
  }
73
73
  };
74
74
  };
@@ -49,8 +49,7 @@ export function create(options) {
49
49
  res.clearCookie(setCookie.name);
50
50
  }
51
51
  if (error && throwOnFailure) {
52
- res.status(403).json({ error });
53
- return;
52
+ throw Object.assign(new Error(error), { status: 403 });
54
53
  }
55
54
  next();
56
55
  });
@@ -14,7 +14,7 @@ export declare function create(options: AltchaOptions): {
14
14
  challengeHandler: (request: FastifyRequest, reply: FastifyReply) => Promise<never>;
15
15
  verifyHandler: (request: FastifyRequest, reply: FastifyReply) => Promise<never>;
16
16
  getPayloadFromRequest: (request: FastifyRequest, cookieName?: string) => Promise<string | undefined>;
17
- middleware: (options?: AltchaMiddlewareOptions) => (request: FastifyRequest, reply: FastifyReply) => Promise<undefined>;
17
+ middleware: (options?: AltchaMiddlewareOptions) => (request: FastifyRequest, reply: FastifyReply) => Promise<void>;
18
18
  verify: typeof verify;
19
19
  };
20
20
  declare const _default: {
@@ -62,7 +62,7 @@ export function create(options) {
62
62
  deleteCookie(reply, setCookie.name, setCookie.path);
63
63
  }
64
64
  if (error && throwOnFailure) {
65
- return reply.code(403).send({ error });
65
+ throw Object.assign(new Error(error), { statusCode: 403 });
66
66
  }
67
67
  };
68
68
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "altcha-lib",
3
- "version": "2.0.2",
3
+ "version": "2.1.0",
4
4
  "description": "A lightweight library for creating and verifying ALTCHA challenges on the server.",
5
5
  "author": {
6
6
  "name": "Daniel Regeci",
@@ -23,7 +23,7 @@
23
23
  "types": "./dist/index.d.ts",
24
24
  "type": "module",
25
25
  "scripts": {
26
- "build": "rimraf dist && tsc -b tsconfig.build.json tsconfig.cjs.json",
26
+ "build": "rimraf dist && tsc -b tsconfig.build.json tsconfig.cjs.json && echo '{\"type\":\"commonjs\"}' > dist/cjs/package.json",
27
27
  "lint": "eslint ./src/**/*",
28
28
  "format": "prettier --write './(src|tests)/**/*'",
29
29
  "test": "vitest --run",
@@ -111,10 +111,10 @@
111
111
  "cors": "^2.8.6",
112
112
  "eslint": "^10.0.3",
113
113
  "express": "^5.2.1",
114
- "fastify": "^5.8.2",
114
+ "fastify": "^5.8.5",
115
115
  "globals": "^17.4.0",
116
116
  "h3": "^2.0.1-rc.18",
117
- "hono": "^4.12.12",
117
+ "hono": "^4.12.14",
118
118
  "husky": "^9.1.7",
119
119
  "prettier": "^3.8.1",
120
120
  "rimraf": "^6.1.3",