@guren/server 1.0.0-rc.23 → 1.0.0-rc.24
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.
- package/dist/auth/index.js +1 -1
- package/dist/broadcasting/index.js +1 -1
- package/dist/{chunk-AFI3A6GB.js → chunk-44F7JQ7I.js} +9 -0
- package/dist/{chunk-BJXAHGDR.js → chunk-F3664MFN.js} +6 -6
- package/dist/{chunk-NFGDKY3L.js → chunk-IM6XKMP5.js} +3 -3
- package/dist/index.js +11 -15
- package/dist/runtime/index.js +1 -1
- package/package.json +3 -3
package/dist/auth/index.js
CHANGED
|
@@ -490,6 +490,14 @@ async function parseRequestPayload(ctx) {
|
|
|
490
490
|
}
|
|
491
491
|
return {};
|
|
492
492
|
}
|
|
493
|
+
function flattenRequestQueries(ctx) {
|
|
494
|
+
const queries = ctx.req.queries();
|
|
495
|
+
const flat = {};
|
|
496
|
+
for (const [key, values] of Object.entries(queries)) {
|
|
497
|
+
flat[key] = values.length === 1 ? values[0] : values;
|
|
498
|
+
}
|
|
499
|
+
return flat;
|
|
500
|
+
}
|
|
493
501
|
function formatValidationErrors(error, fallbackMessage = "The provided data is invalid.") {
|
|
494
502
|
const errors = {};
|
|
495
503
|
for (const issue of error.issues ?? []) {
|
|
@@ -927,6 +935,7 @@ function wrapChannel(name, channel) {
|
|
|
927
935
|
|
|
928
936
|
export {
|
|
929
937
|
parseRequestPayload,
|
|
938
|
+
flattenRequestQueries,
|
|
930
939
|
formatValidationErrors,
|
|
931
940
|
Channel,
|
|
932
941
|
PrivateChannel,
|
|
@@ -270,10 +270,10 @@ function getSessionFromContext(ctx) {
|
|
|
270
270
|
|
|
271
271
|
// src/auth/RequestAuthContext.ts
|
|
272
272
|
var RequestAuthContext = class {
|
|
273
|
-
constructor(manager, ctx,
|
|
273
|
+
constructor(manager, ctx, resolveSession, resolveGuard) {
|
|
274
274
|
this.manager = manager;
|
|
275
275
|
this.ctx = ctx;
|
|
276
|
-
this.
|
|
276
|
+
this.resolveSession = resolveSession;
|
|
277
277
|
this.resolveGuard = resolveGuard;
|
|
278
278
|
}
|
|
279
279
|
guardCache = /* @__PURE__ */ new Map();
|
|
@@ -286,7 +286,7 @@ var RequestAuthContext = class {
|
|
|
286
286
|
return this.guardCache.get(key);
|
|
287
287
|
}
|
|
288
288
|
session() {
|
|
289
|
-
return this.
|
|
289
|
+
return this.resolveSession();
|
|
290
290
|
}
|
|
291
291
|
async check() {
|
|
292
292
|
return this.guard().check();
|
|
@@ -705,16 +705,16 @@ var AuthManager = class {
|
|
|
705
705
|
}
|
|
706
706
|
createAuthContext(ctx, options = {}) {
|
|
707
707
|
const guardName = options.guard ?? this.defaultGuard;
|
|
708
|
-
const
|
|
708
|
+
const resolveSession = () => getSessionFromContext(ctx);
|
|
709
709
|
const guardFactory = (name) => {
|
|
710
710
|
const targetName = name ?? guardName;
|
|
711
711
|
return this.createGuard(targetName, {
|
|
712
712
|
ctx,
|
|
713
|
-
session,
|
|
713
|
+
session: resolveSession(),
|
|
714
714
|
manager: this
|
|
715
715
|
});
|
|
716
716
|
};
|
|
717
|
-
return new RequestAuthContext(this, ctx,
|
|
717
|
+
return new RequestAuthContext(this, ctx, resolveSession, guardFactory);
|
|
718
718
|
}
|
|
719
719
|
async attempt(name, ctx, credentials, remember) {
|
|
720
720
|
const guard = this.createAuthContext(ctx, { guard: name }).guard(name);
|
|
@@ -6,7 +6,7 @@ import standard from "figlet/importable-fonts/Standard.js";
|
|
|
6
6
|
// package.json
|
|
7
7
|
var package_default = {
|
|
8
8
|
name: "@guren/server",
|
|
9
|
-
version: "1.0.0-rc.
|
|
9
|
+
version: "1.0.0-rc.24",
|
|
10
10
|
type: "module",
|
|
11
11
|
license: "MIT",
|
|
12
12
|
repository: {
|
|
@@ -111,8 +111,8 @@ var package_default = {
|
|
|
111
111
|
test: "bun test"
|
|
112
112
|
},
|
|
113
113
|
dependencies: {
|
|
114
|
-
"@guren/inertia-client": "^1.0.0-rc.
|
|
115
|
-
"@guren/orm": "^1.0.0-rc.
|
|
114
|
+
"@guren/inertia-client": "^1.0.0-rc.23",
|
|
115
|
+
"@guren/orm": "^1.0.0-rc.25",
|
|
116
116
|
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
117
117
|
chalk: "^5.3.0",
|
|
118
118
|
consola: "^3.4.2",
|
package/dist/index.js
CHANGED
|
@@ -102,7 +102,7 @@ import {
|
|
|
102
102
|
logDevServerBanner,
|
|
103
103
|
parseImportMap,
|
|
104
104
|
startViteDevServer
|
|
105
|
-
} from "./chunk-
|
|
105
|
+
} from "./chunk-IM6XKMP5.js";
|
|
106
106
|
import {
|
|
107
107
|
API_TOKEN_KEY,
|
|
108
108
|
AuthManager,
|
|
@@ -155,7 +155,7 @@ import {
|
|
|
155
155
|
verifyEmailToken,
|
|
156
156
|
verifyOAuthState,
|
|
157
157
|
verifyPasswordResetToken
|
|
158
|
-
} from "./chunk-
|
|
158
|
+
} from "./chunk-F3664MFN.js";
|
|
159
159
|
import {
|
|
160
160
|
Gate,
|
|
161
161
|
Policy,
|
|
@@ -200,11 +200,12 @@ import {
|
|
|
200
200
|
RedisDriver as RedisDriver2,
|
|
201
201
|
createBroadcastManager,
|
|
202
202
|
createTypedBroadcaster,
|
|
203
|
+
flattenRequestQueries,
|
|
203
204
|
formatValidationErrors,
|
|
204
205
|
getBroadcastManager,
|
|
205
206
|
parseRequestPayload,
|
|
206
207
|
setBroadcastManager
|
|
207
|
-
} from "./chunk-
|
|
208
|
+
} from "./chunk-44F7JQ7I.js";
|
|
208
209
|
import {
|
|
209
210
|
CacheManager,
|
|
210
211
|
FileStore,
|
|
@@ -623,7 +624,7 @@ function createContractHandler(path, options, handler) {
|
|
|
623
624
|
if (params instanceof Response) {
|
|
624
625
|
return params;
|
|
625
626
|
}
|
|
626
|
-
const query = parseRouteSegment(options.query, ctx
|
|
627
|
+
const query = parseRouteSegment(options.query, flattenRequestQueries(ctx), 422);
|
|
627
628
|
if (query instanceof Response) {
|
|
628
629
|
return query;
|
|
629
630
|
}
|
|
@@ -699,10 +700,11 @@ function createContractValidationMiddleware(route) {
|
|
|
699
700
|
}
|
|
700
701
|
}
|
|
701
702
|
if (schemas.query) {
|
|
702
|
-
const
|
|
703
|
+
const query = flattenRequestQueries(c);
|
|
704
|
+
const result = parseRouteSegment(schemas.query, query, 422);
|
|
703
705
|
if (result instanceof Response) {
|
|
704
706
|
throw ValidationException.withMessages(
|
|
705
|
-
formatValidationErrors(schemas.query.safeParse(
|
|
707
|
+
formatValidationErrors(schemas.query.safeParse(query).error)
|
|
706
708
|
);
|
|
707
709
|
}
|
|
708
710
|
}
|
|
@@ -1793,6 +1795,8 @@ var Application = class {
|
|
|
1793
1795
|
}
|
|
1794
1796
|
if (this.options.auth) {
|
|
1795
1797
|
this.providerManager.register(AuthServiceProvider);
|
|
1798
|
+
} else {
|
|
1799
|
+
this.hono.use("*", attachAuthContext((ctx) => this.authManager.createAuthContext(ctx)));
|
|
1796
1800
|
}
|
|
1797
1801
|
this.providerManager.register(AuthorizationServiceProvider);
|
|
1798
1802
|
const userProviders = Array.isArray(this.options.providers) ? this.options.providers : [];
|
|
@@ -1851,9 +1855,6 @@ var Application = class {
|
|
|
1851
1855
|
async boot() {
|
|
1852
1856
|
this.mountSecurityDefaults();
|
|
1853
1857
|
await this.providerManager.registerAll();
|
|
1854
|
-
if (!this.options.auth) {
|
|
1855
|
-
this.hono.use("*", attachAuthContext((ctx) => this.authManager.createAuthContext(ctx)));
|
|
1856
|
-
}
|
|
1857
1858
|
await this.options.boot?.(this.hono);
|
|
1858
1859
|
await this.mountRoutes();
|
|
1859
1860
|
await this.mountMcpEndpoint();
|
|
@@ -2642,12 +2643,7 @@ var Controller = class {
|
|
|
2642
2643
|
}
|
|
2643
2644
|
/** Flatten query string arrays to scalar values for cleaner schema usage. */
|
|
2644
2645
|
flattenQueries() {
|
|
2645
|
-
|
|
2646
|
-
const flat = {};
|
|
2647
|
-
for (const [key, values] of Object.entries(queries)) {
|
|
2648
|
-
flat[key] = values.length === 1 ? values[0] : values;
|
|
2649
|
-
}
|
|
2650
|
-
return flat;
|
|
2646
|
+
return flattenRequestQueries(this.ctx);
|
|
2651
2647
|
}
|
|
2652
2648
|
// ─── Validation ─────────────────────────────────────────────────
|
|
2653
2649
|
/**
|
package/dist/runtime/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@guren/server",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.24",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -105,8 +105,8 @@
|
|
|
105
105
|
"test": "bun test"
|
|
106
106
|
},
|
|
107
107
|
"dependencies": {
|
|
108
|
-
"@guren/inertia-client": "^1.0.0-rc.
|
|
109
|
-
"@guren/orm": "^1.0.0-rc.
|
|
108
|
+
"@guren/inertia-client": "^1.0.0-rc.23",
|
|
109
|
+
"@guren/orm": "^1.0.0-rc.25",
|
|
110
110
|
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
111
111
|
"chalk": "^5.3.0",
|
|
112
112
|
"consola": "^3.4.2",
|