@lastshotlabs/bunshot 0.0.19 → 0.0.20

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,5 @@
1
1
  export { connectMongo, connectAuthMongo, connectAppMongo, disconnectMongo, authConnection, appConnection, mongoose } from "../lib/mongo";
2
2
  export { mongoAuthAdapter } from "../adapters/mongoAuth";
3
3
  export { AuthUser } from "../models/AuthUser";
4
+ export { zodToMongoose } from "../lib/zodToMongoose";
5
+ export type { ZodToMongooseConfig, ZodToMongooseRefConfig } from "../lib/zodToMongoose";
@@ -1,3 +1,4 @@
1
1
  export { connectMongo, connectAuthMongo, connectAppMongo, disconnectMongo, authConnection, appConnection, mongoose } from "../lib/mongo";
2
2
  export { mongoAuthAdapter } from "../adapters/mongoAuth";
3
3
  export { AuthUser } from "../models/AuthUser";
4
+ export { zodToMongoose } from "../lib/zodToMongoose";
@@ -15,17 +15,32 @@ export const cors = async (req, next) => {
15
15
  };
16
16
  function corsHeaders(requestOrigin) {
17
17
  let allowOrigin;
18
+ let withCredentials = false;
18
19
  if (_allowedOrigins === "*") {
19
20
  allowOrigin = "*";
20
21
  }
21
22
  else {
22
23
  const origins = Array.isArray(_allowedOrigins) ? _allowedOrigins : [_allowedOrigins];
23
- allowOrigin = requestOrigin && origins.includes(requestOrigin) ? requestOrigin : origins[0];
24
+ // Filter out "*" wildcard is incompatible with credentials
25
+ const specific = origins.filter((o) => o !== "*");
26
+ if (requestOrigin && specific.includes(requestOrigin)) {
27
+ allowOrigin = requestOrigin;
28
+ withCredentials = true;
29
+ }
30
+ else if (origins.includes("*")) {
31
+ // Fallback: reflect the request origin so credentials still work
32
+ allowOrigin = requestOrigin ?? "*";
33
+ withCredentials = !!requestOrigin;
34
+ }
35
+ else {
36
+ allowOrigin = specific[0] ?? "*";
37
+ }
24
38
  }
25
39
  return {
26
40
  "Access-Control-Allow-Origin": allowOrigin,
27
41
  "Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",
28
- "Access-Control-Allow-Headers": "Content-Type, Authorization",
42
+ "Access-Control-Allow-Headers": "Content-Type, Authorization, x-user-token, x-csrf-token, x-refresh-token",
43
+ ...(withCredentials ? { "Access-Control-Allow-Credentials": "true" } : {}),
29
44
  ...(allowOrigin !== "*" ? { Vary: "Origin" } : {}),
30
45
  };
31
46
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lastshotlabs/bunshot",
3
- "version": "0.0.19",
3
+ "version": "0.0.20",
4
4
  "description": "Batteries-included Bun + Hono API framework — auth, sessions, rate limiting, WebSocket, queues, and OpenAPI docs out of the box",
5
5
  "repository": {
6
6
  "type": "git",
@@ -52,7 +52,8 @@
52
52
  "start": "bun src/index.ts",
53
53
  "readme": "bun docs/build-readme.ts",
54
54
  "readme:npm": "bun docs/build-readme.ts npm",
55
- "test": "bun test tests/unit tests/integration",
55
+ "test": "bun test tests/unit tests/integration && bun test tests/isolated",
56
+ "test:isolated": "bun test tests/isolated",
56
57
  "test:coverage": "bun test --coverage tests/unit tests/integration",
57
58
  "test:docker:up": "docker compose -f docker-compose.test.yml up -d --wait",
58
59
  "test:docker:down": "docker compose -f docker-compose.test.yml down",
@@ -61,6 +62,7 @@
61
62
  "test:coverage:full": "bun run test:docker:up && bun test --coverage --config bunfig.ci.toml tests/unit tests/integration tests/docker; bun run test:docker:down"
62
63
  },
63
64
  "dependencies": {
65
+ "@asteasolutions/zod-to-openapi": "^8.4.1",
64
66
  "@hono/zod-openapi": "1.2.2",
65
67
  "@scalar/hono-api-reference": "0.10.0",
66
68
  "arctic": "^3.7.0",