@kanjijs/auth 0.2.0-beta.12 → 0.2.0-beta.14

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,27 @@
1
+ import { type DynamicModule } from "@kanjijs/core";
2
+ import type { MiddlewareHandler } from "hono";
3
+ import type { AuthConfig } from "@auth/core";
4
+ export declare const AUTH_USER_KEY = "kanjijs.auth.user";
5
+ export declare const AUTH_SESSION_KEY = "kanjijs.auth.session";
6
+ /**
7
+ * Configure Auth.js middleware.
8
+ * This middleware initializes Auth.js and automatically populates the session/user.
9
+ *
10
+ * Usage:
11
+ * @Use(auth({ ...authConfig }))
12
+ */
13
+ export declare function auth(config: AuthConfig): MiddlewareHandler;
14
+ /**
15
+ * Middleware: Require Authentication
16
+ * Returns 401 if no user is found in context.
17
+ * MUST be used AFTER auth() middleware.
18
+ */
19
+ export declare const requireAuth: MiddlewareHandler;
20
+ /**
21
+ * Factory: Require Role
22
+ * Checks user.role against required role.
23
+ */
24
+ export declare function requireRole(role: string): MiddlewareHandler;
25
+ export declare class AuthModule {
26
+ static forRoot(config: AuthConfig): DynamicModule;
27
+ }
package/dist/index.js CHANGED
@@ -1298,7 +1298,7 @@ class ModuleCompiler {
1298
1298
  const paramTypes = Reflect.getMetadata("design:paramtypes", clazz) || [];
1299
1299
  const injectionTokens = MetadataStorage.getInjections(clazz) || new Map;
1300
1300
  dependencies = paramTypes.map((t, i) => injectionTokens.get(i) || t);
1301
- } else if ("useFactory" in provider && provider.useFactory) {
1301
+ } else if ("useFactory" in provider) {
1302
1302
  targetName = provider.provide?.name || String(provider.provide);
1303
1303
  dependencies = provider.inject || [];
1304
1304
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kanjijs/auth",
3
- "version": "0.2.0-beta.12",
3
+ "version": "0.2.0-beta.14",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "files": [
@@ -9,7 +9,7 @@
9
9
  "LICENSE"
10
10
  ],
11
11
  "scripts": {
12
- "build": "bun build src/index.ts --outdir dist --target bun",
12
+ "build": "bun build src/index.ts --outdir dist --target bun && tsc --emitDeclarationOnly --declaration --outDir dist",
13
13
  "test": "bun test"
14
14
  },
15
15
  "dependencies": {
@@ -18,7 +18,7 @@
18
18
  "hono": "^4.0.0"
19
19
  },
20
20
  "peerDependencies": {
21
- "@kanjijs/core": "^0.2.0-beta.12"
21
+ "@kanjijs/core": "^0.2.0-beta.14"
22
22
  },
23
23
  "devDependencies": {
24
24
  "typescript": "^5.0.0",