@arkstack/driver-h3 0.12.18 → 0.12.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.
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  /// <reference path="./app.d.ts" />
2
- import { a as Router, i as H3Middleware, n as H3DriverOptions, o as defaultErrorHandler, r as H3EventResponse, t as H3Driver } from "./index-BJ2iafCy.js";
2
+ import { a as Router, i as H3Middleware, n as H3DriverOptions, o as defaultErrorHandler, r as H3EventResponse, t as H3Driver } from "./index-DIJtwwZP.js";
3
3
  export { H3Driver, H3DriverOptions, H3EventResponse, H3Middleware, Router, defaultErrorHandler };
package/dist/index.js CHANGED
@@ -65,7 +65,7 @@ const defaultErrorHandler = async (err, event) => {
65
65
  });
66
66
  };
67
67
  //#endregion
68
- //#region ../http/dist/redirect-C1kZMywY.js
68
+ //#region ../http/dist/redirect-C1DNCiO9.js
69
69
  const unwrapRequestSource = (source) => {
70
70
  if (source.headers) return source;
71
71
  if (source.req) return source.req;
@@ -119,6 +119,8 @@ var Request$1 = class Request$1 extends Request {
119
119
  ip;
120
120
  source;
121
121
  user;
122
+ auth;
123
+ authUser;
122
124
  authToken;
123
125
  constructor(options = {}) {
124
126
  super(options);
@@ -128,6 +130,8 @@ var Request$1 = class Request$1 extends Request {
128
130
  if (this.path) this.path = options.path;
129
131
  this.ip = options.ip ?? null;
130
132
  this.user = options.user;
133
+ this.auth = options.auth;
134
+ this.authUser = options.authUser;
131
135
  this.authToken = options.authToken;
132
136
  this.source = options.source;
133
137
  globalThis.request = (key) => key ? this.input(key) : this;
@@ -143,6 +147,8 @@ var Request$1 = class Request$1 extends Request {
143
147
  path: request.path,
144
148
  ip: request.ip ?? null,
145
149
  user: request.user,
150
+ auth: request.auth,
151
+ authUser: request.authUser,
146
152
  authToken: request.authToken,
147
153
  source
148
154
  });
@@ -160,6 +166,31 @@ var Request$1 = class Request$1 extends Request {
160
166
  if (isRecord(this.source)) this.source.user = user;
161
167
  return this;
162
168
  }
169
+ setAuthentication(auth, user, token) {
170
+ this.auth = auth;
171
+ this.authUser = user;
172
+ this.authToken = token;
173
+ this.setUser(user);
174
+ if (isRecord(this.source)) {
175
+ this.source.auth = auth;
176
+ this.source.authUser = user;
177
+ this.source.authToken = token;
178
+ }
179
+ return this;
180
+ }
181
+ clearAuthentication() {
182
+ this.auth = void 0;
183
+ this.authUser = void 0;
184
+ this.authToken = void 0;
185
+ this.user = void 0;
186
+ if (isRecord(this.source)) {
187
+ this.source.auth = void 0;
188
+ this.source.authUser = void 0;
189
+ this.source.authToken = void 0;
190
+ this.source.user = void 0;
191
+ }
192
+ return this;
193
+ }
163
194
  };
164
195
  var FlashBag = class {
165
196
  bag = {};
@@ -1179,6 +1210,9 @@ definePlugin({
1179
1210
  registerResponseFlashSweep(ctx, session);
1180
1211
  return session;
1181
1212
  });
1213
+ bind(Request$1, ({ request, ctx }) => {
1214
+ return request instanceof Request$1 ? request : Request$1.from(request ?? ctx);
1215
+ });
1182
1216
  useHttpContext((context) => {
1183
1217
  const session = getSession(context.ctx);
1184
1218
  if (session) {
@@ -1,4 +1,4 @@
1
- import { i as H3Middleware } from "../index-BJ2iafCy.js";
1
+ import { i as H3Middleware } from "../index-DIJtwwZP.js";
2
2
  import * as _$h3 from "h3";
3
3
  import { EventHandlerRequest, H3Event } from "h3";
4
4
  import { NextFunction } from "clear-router/types/h3";
package/dist/types.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { n as MiddlewareConfig, t as Middleware } from "./types-yX_T9j5I.js";
1
+ import { n as MiddlewareConfig, t as Middleware } from "./types-DWUchLdg.js";
2
2
  export { Middleware, MiddlewareConfig };
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@arkstack/driver-h3",
3
- "version": "0.12.18",
3
+ "version": "0.12.20",
4
4
  "type": "module",
5
5
  "description": "H3 driver for Arkstack, providing H3-based runtime integration for the framework.",
6
6
  "homepage": "https://arkstack.toneflix.net",
7
7
  "repository": {
8
8
  "type": "git",
9
- "url": "git+https://github.com/arkstack-tmp/arkstack.git",
9
+ "url": "git+https://github.com/arkstack-hq/arkstack.git",
10
10
  "directory": "packages/driver-h3"
11
11
  },
12
12
  "keywords": [
@@ -38,15 +38,15 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "clear-router": "^2.8.6",
41
- "@resora/plugin-clear-router": "^1.0.45",
42
- "resora": "^1.3.13",
43
- "@arkstack/contract": "^0.12.18"
41
+ "@resora/plugin-clear-router": "^1.0.48",
42
+ "resora": "^1.3.16",
43
+ "@arkstack/contract": "^0.12.20"
44
44
  },
45
45
  "peerDependencies": {
46
46
  "h3": "2.0.1-rc.22",
47
- "@arkstack/auth": "^0.12.18",
48
- "@arkstack/foundry": "^0.12.18",
49
- "@arkstack/common": "^0.12.18"
47
+ "@arkstack/auth": "^0.12.20",
48
+ "@arkstack/foundry": "^0.12.20",
49
+ "@arkstack/common": "^0.12.20"
50
50
  },
51
51
  "peerDependenciesMeta": {
52
52
  "@arkstack/auth": {
@@ -1,86 +0,0 @@
1
- import { n as MiddlewareConfig, t as Middleware$2 } from "./types-yX_T9j5I.js";
2
- import { ArkstackKitDriver, ArkstackRouteListOptions, PromiseOrValue } from "@arkstack/contract";
3
- import { H3, H3Event, HTTPError, HTTPResponse } from "h3";
4
- import { Route } from "clear-router";
5
- import { Router } from "clear-router/h3";
6
- import { H3App, Handler, HttpContext, Middleware as Middleware$1 } from "clear-router/types/h3";
7
-
8
- //#region src/error-handler.d.ts
9
- declare const defaultErrorHandler: (err: HTTPError | Error | string, event: H3Event) => Promise<HTTPResponse | {
10
- error: boolean;
11
- message: string;
12
- status: "error";
13
- code: number;
14
- errors?: unknown;
15
- stack?: string;
16
- }>;
17
- //#endregion
18
- //#region src/Router.d.ts
19
- declare class Router$1 extends Router {
20
- static bind(app: H3): Promise<H3App>;
21
- static list(_options: ArkstackRouteListOptions | undefined, app: H3): Promise<Route<HttpContext, Middleware$1, Handler>[]>;
22
- }
23
- //#endregion
24
- //#region src/index.d.ts
25
- type H3Middleware = Middleware$1 | [Middleware$1, Record<string, any>];
26
- interface H3DriverOptions {
27
- bindRouter: (app: H3) => PromiseOrValue<void>;
28
- mountPublicAssets?: (app: H3, publicPath: string) => PromiseOrValue<void>;
29
- createApp?: () => H3;
30
- onError?: (err: Error | string, event: H3Event) => unknown;
31
- }
32
- declare class H3EventResponse {
33
- response: Response;
34
- status: number;
35
- statusText?: string;
36
- constructor(response: Response);
37
- get headers(): Headers;
38
- }
39
- /**
40
- * The H3Driver class implements the ArkstackKitDriver contract for the H3 framework.
41
- */
42
- declare class H3Driver extends ArkstackKitDriver<H3, H3Middleware> {
43
- readonly name = "h3";
44
- private readonly options;
45
- /**
46
- * Creates an instance of H3Driver.
47
- *
48
- * @param options
49
- */
50
- constructor(options: H3DriverOptions);
51
- /**
52
- * Creates an H3 application instance.
53
- *
54
- * @returns
55
- */
56
- createApp(): H3;
57
- /**
58
- * Mounts static assets from the specified public path to the H3 application.
59
- *
60
- * @param app
61
- * @param publicPath
62
- */
63
- mountPublicAssets(app: H3, publicPath: string): PromiseOrValue<void>;
64
- /**
65
- * Binds the router to the H3 application using the provided bindRouter function.
66
- *
67
- * @param app
68
- */
69
- bindRouter(app: H3): PromiseOrValue<void>;
70
- /**
71
- * Applies middleware to the H3 application.
72
- *
73
- * @param app
74
- * @param middleware
75
- */
76
- applyMiddleware(app: H3, middleware: H3Middleware | Middleware$2 | MiddlewareConfig): void;
77
- /**
78
- * Starts the H3 server on the specified port.
79
- *
80
- * @param app
81
- * @param port
82
- */
83
- start(app: H3, port: number): void;
84
- }
85
- //#endregion
86
- export { Router$1 as a, H3Middleware as i, H3DriverOptions as n, defaultErrorHandler as o, H3EventResponse as r, H3Driver as t };
@@ -1,18 +0,0 @@
1
- /// <reference path="./app.d.ts" />
2
- import { ArkstackKitDriver, ArkstackMiddlewareConfig, ArkstackRouteListOptions, PromiseOrValue } from "@arkstack/contract";
3
- import { H3, H3Event, HTTPError, HTTPResponse, Middleware } from "h3";
4
- import { Route } from "clear-router";
5
- import { Router } from "clear-router/h3";
6
- import { ClassMiddleware } from "clear-router/types/basic";
7
- import { H3App, Handler, HttpContext, Middleware as Middleware$1 } from "clear-router/types/h3";
8
-
9
- //#region dist/index-DIJtwwZP.d.ts
10
- //#endregion
11
- //#region src/index.d.ts
12
- type H3Middleware = Middleware$1 | [Middleware$1, Record<string, any>];
13
- //#endregion
14
- //#region src/types.d.ts
15
- type Middleware$2 = Middleware | ClassMiddleware<Middleware>;
16
- type MiddlewareConfig = ArkstackMiddlewareConfig<Middleware$2> | ArkstackMiddlewareConfig<H3Middleware>;
17
- //#endregion
18
- export { MiddlewareConfig as n, Middleware$2 as t };