@nest-boot/auth 8.0.0-beta.0 → 8.0.0-beta.2
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/adapters/mikro-orm-adapter.d.ts +0 -13
- package/dist/adapters/mikro-orm-adapter.js +9 -9
- package/dist/adapters/mikro-orm-adapter.js.map +1 -1
- package/dist/auth-module-options.interface.d.ts +0 -9
- package/dist/auth.constants.d.ts +0 -2
- package/dist/auth.constants.js +0 -2
- package/dist/auth.constants.js.map +1 -1
- package/dist/auth.guard.d.ts +0 -20
- package/dist/auth.guard.js +0 -20
- package/dist/auth.guard.js.map +1 -1
- package/dist/auth.middleware.d.ts +0 -21
- package/dist/auth.middleware.js +0 -21
- package/dist/auth.middleware.js.map +1 -1
- package/dist/auth.module.d.ts +0 -24
- package/dist/auth.module.js +0 -24
- package/dist/auth.module.js.map +1 -1
- package/dist/auth.service.d.ts +0 -7
- package/dist/auth.service.js +0 -6
- package/dist/auth.service.js.map +1 -1
- package/dist/auth.transaction-context.d.ts +0 -20
- package/dist/auth.transaction-context.js +2 -18
- package/dist/auth.transaction-context.js.map +1 -1
- package/dist/decorators/current-session.decorator.d.ts +0 -1
- package/dist/decorators/current-session.decorator.js +0 -1
- package/dist/decorators/current-session.decorator.js.map +1 -1
- package/dist/decorators/current-user.decorator.d.ts +0 -1
- package/dist/decorators/current-user.decorator.js +0 -1
- package/dist/decorators/current-user.decorator.js.map +1 -1
- package/dist/decorators/public.decorator.d.ts +0 -1
- package/dist/decorators/public.decorator.js +0 -1
- package/dist/decorators/public.decorator.js.map +1 -1
- package/dist/entities/account.entity.d.ts +0 -20
- package/dist/entities/account.entity.js +0 -20
- package/dist/entities/account.entity.js.map +1 -1
- package/dist/entities/session.entity.d.ts +0 -15
- package/dist/entities/session.entity.js +0 -15
- package/dist/entities/session.entity.js.map +1 -1
- package/dist/entities/user.entity.d.ts +0 -14
- package/dist/entities/user.entity.js +0 -14
- package/dist/entities/user.entity.js.map +1 -1
- package/dist/entities/verification.entity.d.ts +0 -13
- package/dist/entities/verification.entity.js +0 -13
- package/dist/entities/verification.entity.js.map +1 -1
- package/dist/utils/estimate-entropy.d.ts +0 -7
- package/dist/utils/estimate-entropy.js +0 -7
- package/dist/utils/estimate-entropy.js.map +1 -1
- package/dist/utils/resolve-secret.js +3 -3
- package/dist/utils/resolve-secret.js.map +1 -1
- package/package.json +35 -20
|
@@ -2,26 +2,13 @@ import { type EntityClass, type MikroORM } from "@mikro-orm/core";
|
|
|
2
2
|
import { type DBAdapterDebugLogOption, Where } from "better-auth/adapters";
|
|
3
3
|
import { BaseAccount, BaseSession, BaseUser, BaseVerification } from "../entities/index.js";
|
|
4
4
|
export interface MikroOrmAdapterConfig {
|
|
5
|
-
/**
|
|
6
|
-
* The MikroORM instance.
|
|
7
|
-
*/
|
|
8
5
|
orm: MikroORM;
|
|
9
|
-
/**
|
|
10
|
-
* The entities to use for the adapter.
|
|
11
|
-
*/
|
|
12
6
|
entities: {
|
|
13
|
-
/** Account entity class. */
|
|
14
7
|
account: EntityClass<BaseAccount>;
|
|
15
|
-
/** Session entity class. */
|
|
16
8
|
session: EntityClass<BaseSession>;
|
|
17
|
-
/** User entity class. */
|
|
18
9
|
user: EntityClass<BaseUser>;
|
|
19
|
-
/** Verification entity class. */
|
|
20
10
|
verification: EntityClass<BaseVerification>;
|
|
21
11
|
};
|
|
22
|
-
/**
|
|
23
|
-
* Helps you debug issues with the adapter.
|
|
24
|
-
*/
|
|
25
12
|
debugLogs?: DBAdapterDebugLogOption;
|
|
26
13
|
}
|
|
27
14
|
export declare function convertWhereToMikroOrm(where: Required<Where>[]): Record<string, unknown>;
|
|
@@ -101,15 +101,15 @@ export const mikroOrmAdapter = ({ orm, entities, ...config }) => {
|
|
|
101
101
|
};
|
|
102
102
|
return createAdapterFactory({
|
|
103
103
|
config: {
|
|
104
|
-
adapterId: "mikro-orm-adapter",
|
|
105
|
-
adapterName: "MikroORM Adapter",
|
|
106
|
-
usePlural: false,
|
|
107
|
-
debugLogs: config.debugLogs ?? false,
|
|
108
|
-
supportsJSON: true,
|
|
109
|
-
supportsDates: true,
|
|
110
|
-
supportsBooleans: true,
|
|
111
|
-
supportsNumericIds: true,
|
|
112
|
-
disableIdGeneration: true,
|
|
104
|
+
adapterId: "mikro-orm-adapter",
|
|
105
|
+
adapterName: "MikroORM Adapter",
|
|
106
|
+
usePlural: false,
|
|
107
|
+
debugLogs: config.debugLogs ?? false,
|
|
108
|
+
supportsJSON: true,
|
|
109
|
+
supportsDates: true,
|
|
110
|
+
supportsBooleans: true,
|
|
111
|
+
supportsNumericIds: true,
|
|
112
|
+
disableIdGeneration: true,
|
|
113
113
|
...config,
|
|
114
114
|
},
|
|
115
115
|
adapter: () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mikro-orm-adapter.js","sourceRoot":"","sources":["../../src/adapters/mikro-orm-adapter.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,oBAAoB,GAGrB,MAAM,sBAAsB,CAAC;AAiC9B,MAAM,UAAU,sBAAsB,CAAC,KAAwB;IAC7D,MAAM,UAAU,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE;QAC1D,QAAQ,QAAQ,EAAE,CAAC;YACjB,KAAK,IAAI;gBACP,OAAO;oBACL,CAAC,KAAK,CAAC,EAAE;wBACP,GAAG,EAAE,KAAK;qBACX;iBACF,CAAC;YACJ,KAAK,IAAI;gBACP,OAAO;oBACL,CAAC,KAAK,CAAC,EAAE;wBACP,GAAG,EAAE,KAAK;qBACX;iBACF,CAAC;YACJ,KAAK,IAAI;gBACP,OAAO;oBACL,CAAC,KAAK,CAAC,EAAE;wBACP,GAAG,EAAE,KAAK;qBACX;iBACF,CAAC;YACJ,KAAK,KAAK;gBACR,OAAO;oBACL,CAAC,KAAK,CAAC,EAAE;wBACP,IAAI,EAAE,KAAK;qBACZ;iBACF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J,CAAC;aACF,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -2,23 +2,14 @@ import { Type } from "@nestjs/common";
|
|
|
2
2
|
import type { RouteInfo } from "@nestjs/common/interfaces/middleware/middleware-configuration.interface.js";
|
|
3
3
|
import { BetterAuthOptions } from "better-auth";
|
|
4
4
|
import { MikroOrmAdapterConfig } from "./adapters/mikro-orm-adapter.js";
|
|
5
|
-
/** Options for configuring auth middleware route registration. */
|
|
6
5
|
export interface AuthModuleMiddlewareOptions {
|
|
7
|
-
/** Whether to register the auth middleware (defaults to true). */
|
|
8
6
|
register?: boolean;
|
|
9
|
-
/** Routes to include in auth middleware processing. */
|
|
10
7
|
includeRoutes?: (string | RouteInfo | Type)[];
|
|
11
|
-
/** Routes to exclude from auth middleware processing. */
|
|
12
8
|
excludeRoutes?: (string | RouteInfo)[];
|
|
13
9
|
}
|
|
14
|
-
/** Configuration options for the AuthModule. */
|
|
15
10
|
export interface AuthModuleOptions extends Omit<BetterAuthOptions, "database"> {
|
|
16
|
-
/** Base path for the auth API endpoints. */
|
|
17
11
|
basePath?: string;
|
|
18
|
-
/** Entity classes used for authentication. */
|
|
19
12
|
entities: MikroOrmAdapterConfig["entities"];
|
|
20
|
-
/** Middleware registration options. */
|
|
21
13
|
middleware?: AuthModuleMiddlewareOptions;
|
|
22
|
-
/** Callback invoked after successful authentication. */
|
|
23
14
|
onAuthenticated?: () => void | Promise<void>;
|
|
24
15
|
}
|
package/dist/auth.constants.d.ts
CHANGED
package/dist/auth.constants.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/** Injection token for the better-auth instance. */
|
|
2
1
|
export const AUTH_TOKEN = Symbol("AUTH");
|
|
3
|
-
/** Metadata key used by the {@link Public} decorator to mark public routes. */
|
|
4
2
|
export const IS_PUBLIC_KEY = Symbol("IS_PUBLIC_KEY");
|
|
5
3
|
//# sourceMappingURL=auth.constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.constants.js","sourceRoot":"","sources":["../src/auth.constants.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"auth.constants.js","sourceRoot":"","sources":["../src/auth.constants.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;AAGzC,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC"}
|
package/dist/auth.guard.d.ts
CHANGED
|
@@ -1,28 +1,8 @@
|
|
|
1
1
|
import { type CanActivate, type ExecutionContext } from "@nestjs/common";
|
|
2
2
|
import { Reflector } from "@nestjs/core";
|
|
3
|
-
/**
|
|
4
|
-
* Guard that enforces authentication on routes.
|
|
5
|
-
*
|
|
6
|
-
* @remarks
|
|
7
|
-
* Allows access if the route is marked with {@link Public}, otherwise
|
|
8
|
-
* requires a valid session in the request context.
|
|
9
|
-
*/
|
|
10
3
|
export declare class AuthGuard implements CanActivate {
|
|
11
4
|
protected readonly reflector: Reflector;
|
|
12
|
-
/** Creates a new AuthGuard instance.
|
|
13
|
-
* @param reflector - NestJS reflector for reading route metadata
|
|
14
|
-
*/
|
|
15
5
|
constructor(reflector: Reflector);
|
|
16
|
-
/**
|
|
17
|
-
* Determines whether the current route is marked as public.
|
|
18
|
-
* @param context - The execution context of the current request
|
|
19
|
-
* @returns True when authentication should be skipped
|
|
20
|
-
*/
|
|
21
6
|
protected isPublic(context: ExecutionContext): boolean;
|
|
22
|
-
/**
|
|
23
|
-
* Determines whether the current request is allowed to proceed.
|
|
24
|
-
* @param context - The execution context of the current request
|
|
25
|
-
* @returns A NestJS guard activation result
|
|
26
|
-
*/
|
|
27
7
|
canActivate(context: ExecutionContext): ReturnType<CanActivate["canActivate"]>;
|
|
28
8
|
}
|
package/dist/auth.guard.js
CHANGED
|
@@ -12,37 +12,17 @@ import { Injectable, } from "@nestjs/common";
|
|
|
12
12
|
import { Reflector } from "@nestjs/core";
|
|
13
13
|
import { IS_PUBLIC_KEY } from "./auth.constants.js";
|
|
14
14
|
import { BaseSession } from "./entities/session.entity.js";
|
|
15
|
-
/**
|
|
16
|
-
* Guard that enforces authentication on routes.
|
|
17
|
-
*
|
|
18
|
-
* @remarks
|
|
19
|
-
* Allows access if the route is marked with {@link Public}, otherwise
|
|
20
|
-
* requires a valid session in the request context.
|
|
21
|
-
*/
|
|
22
15
|
let AuthGuard = class AuthGuard {
|
|
23
16
|
reflector;
|
|
24
|
-
/** Creates a new AuthGuard instance.
|
|
25
|
-
* @param reflector - NestJS reflector for reading route metadata
|
|
26
|
-
*/
|
|
27
17
|
constructor(reflector) {
|
|
28
18
|
this.reflector = reflector;
|
|
29
19
|
}
|
|
30
|
-
/**
|
|
31
|
-
* Determines whether the current route is marked as public.
|
|
32
|
-
* @param context - The execution context of the current request
|
|
33
|
-
* @returns True when authentication should be skipped
|
|
34
|
-
*/
|
|
35
20
|
isPublic(context) {
|
|
36
21
|
return !!this.reflector.getAllAndOverride(IS_PUBLIC_KEY, [
|
|
37
22
|
context.getHandler(),
|
|
38
23
|
context.getClass(),
|
|
39
24
|
]);
|
|
40
25
|
}
|
|
41
|
-
/**
|
|
42
|
-
* Determines whether the current request is allowed to proceed.
|
|
43
|
-
* @param context - The execution context of the current request
|
|
44
|
-
* @returns A NestJS guard activation result
|
|
45
|
-
*/
|
|
46
26
|
canActivate(context) {
|
|
47
27
|
if (this.isPublic(context)) {
|
|
48
28
|
return true;
|
package/dist/auth.guard.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.guard.js","sourceRoot":"","sources":["../src/auth.guard.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAGL,UAAU,GACX,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"auth.guard.js","sourceRoot":"","sources":["../src/auth.guard.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAGL,UAAU,GACX,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAUpD,IAAM,SAAS,GAAf,MAAM,SAAS;IAIW;IAA/B,YAA+B,SAAoB;QAApB,cAAS,GAAT,SAAS,CAAW;IAAG,CAAC;IAO7C,QAAQ,CAAC,OAAyB;QAC1C,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,aAAa,EAAE;YACvD,OAAO,CAAC,UAAU,EAAE;YACpB,OAAO,CAAC,QAAQ,EAAE;SACnB,CAAC,CAAC;IACL,CAAC;IAOD,WAAW,CACT,OAAyB;QAEzB,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAC3C,CAAC;CACF,CAAA;AAhCY,SAAS;IADrB,UAAU,EAAE;qCAK+B,SAAS;GAJxC,SAAS,CAgCrB"}
|
|
@@ -3,32 +3,11 @@ import { type NestMiddleware } from "@nestjs/common";
|
|
|
3
3
|
import { type NextFunction, type Request, type Response } from "express";
|
|
4
4
|
import { AuthService } from "./auth.service.js";
|
|
5
5
|
import { type AuthModuleOptions } from "./auth-module-options.interface.js";
|
|
6
|
-
/**
|
|
7
|
-
* Middleware that resolves the current user and session from the request.
|
|
8
|
-
*
|
|
9
|
-
* @remarks
|
|
10
|
-
* Extracts the session token from headers via the better-auth API,
|
|
11
|
-
* loads the corresponding user and session entities, and stores
|
|
12
|
-
* them in the {@link RequestContext}.
|
|
13
|
-
*/
|
|
14
6
|
export declare class AuthMiddleware implements NestMiddleware {
|
|
15
7
|
private readonly options;
|
|
16
8
|
private readonly authService;
|
|
17
9
|
private readonly em;
|
|
18
|
-
/**
|
|
19
|
-
* Creates a new AuthMiddleware instance.
|
|
20
|
-
* @param options - Auth module configuration options
|
|
21
|
-
* @param authService - Service exposing the better-auth API
|
|
22
|
-
* @param em - MikroORM entity manager for loading user/session entities
|
|
23
|
-
*/
|
|
24
10
|
constructor(options: AuthModuleOptions, authService: AuthService, em: EntityManager);
|
|
25
|
-
/** Retrieves the session from the request headers via the better-auth API. */
|
|
26
11
|
private getSession;
|
|
27
|
-
/**
|
|
28
|
-
* Resolves authentication state and attaches user/session to the request context.
|
|
29
|
-
* @param req - Express request object
|
|
30
|
-
* @param res - Express response object
|
|
31
|
-
* @param next - Express next function
|
|
32
|
-
*/
|
|
33
12
|
use(req: Request, res: Response, next: NextFunction): Promise<void>;
|
|
34
13
|
}
|
package/dist/auth.middleware.js
CHANGED
|
@@ -16,30 +16,15 @@ import { Inject, Injectable, } from "@nestjs/common";
|
|
|
16
16
|
import { MODULE_OPTIONS_TOKEN } from "./auth.module-definition.js";
|
|
17
17
|
import { AuthService } from "./auth.service.js";
|
|
18
18
|
import { BaseSession, BaseUser } from "./entities/index.js";
|
|
19
|
-
/**
|
|
20
|
-
* Middleware that resolves the current user and session from the request.
|
|
21
|
-
*
|
|
22
|
-
* @remarks
|
|
23
|
-
* Extracts the session token from headers via the better-auth API,
|
|
24
|
-
* loads the corresponding user and session entities, and stores
|
|
25
|
-
* them in the {@link RequestContext}.
|
|
26
|
-
*/
|
|
27
19
|
let AuthMiddleware = class AuthMiddleware {
|
|
28
20
|
options;
|
|
29
21
|
authService;
|
|
30
22
|
em;
|
|
31
|
-
/**
|
|
32
|
-
* Creates a new AuthMiddleware instance.
|
|
33
|
-
* @param options - Auth module configuration options
|
|
34
|
-
* @param authService - Service exposing the better-auth API
|
|
35
|
-
* @param em - MikroORM entity manager for loading user/session entities
|
|
36
|
-
*/
|
|
37
23
|
constructor(options, authService, em) {
|
|
38
24
|
this.options = options;
|
|
39
25
|
this.authService = authService;
|
|
40
26
|
this.em = em;
|
|
41
27
|
}
|
|
42
|
-
/** Retrieves the session from the request headers via the better-auth API. */
|
|
43
28
|
async getSession(req) {
|
|
44
29
|
return await this.authService.api.getSession({
|
|
45
30
|
headers: Object.entries(req.headers).reduce((headers, [key, value]) => {
|
|
@@ -57,12 +42,6 @@ let AuthMiddleware = class AuthMiddleware {
|
|
|
57
42
|
}, new Headers()),
|
|
58
43
|
});
|
|
59
44
|
}
|
|
60
|
-
/**
|
|
61
|
-
* Resolves authentication state and attaches user/session to the request context.
|
|
62
|
-
* @param req - Express request object
|
|
63
|
-
* @param res - Express response object
|
|
64
|
-
* @param next - Express next function
|
|
65
|
-
*/
|
|
66
45
|
async use(req, res, next) {
|
|
67
46
|
const data = await this.getSession(req);
|
|
68
47
|
if (!data) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.middleware.js","sourceRoot":"","sources":["../src/auth.middleware.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EACL,MAAM,EACN,UAAU,GAGX,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"auth.middleware.js","sourceRoot":"","sources":["../src/auth.middleware.ts"],"names":[],"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.ts
CHANGED
|
@@ -4,36 +4,12 @@ import { type Auth } from "better-auth";
|
|
|
4
4
|
import { AuthMiddleware } from "./auth.middleware.js";
|
|
5
5
|
import { ASYNC_OPTIONS_TYPE, ConfigurableModuleClass, OPTIONS_TYPE } from "./auth.module-definition.js";
|
|
6
6
|
import { type AuthModuleOptions } from "./auth-module-options.interface.js";
|
|
7
|
-
/**
|
|
8
|
-
* Authentication module based on better-auth.
|
|
9
|
-
*
|
|
10
|
-
* @remarks
|
|
11
|
-
* Provides authentication services including session management, middleware registration,
|
|
12
|
-
* and MikroORM-based persistence via the better-auth adapter.
|
|
13
|
-
*/
|
|
14
7
|
export declare class AuthModule extends ConfigurableModuleClass {
|
|
15
8
|
private readonly auth;
|
|
16
9
|
private readonly options;
|
|
17
10
|
private readonly middlewareManager;
|
|
18
11
|
private readonly authMiddleware;
|
|
19
|
-
/**
|
|
20
|
-
* Registers the AuthModule with the given options.
|
|
21
|
-
* @param options - Configuration options including secret and middleware settings
|
|
22
|
-
* @returns Dynamic module configuration
|
|
23
|
-
*/
|
|
24
12
|
static forRoot(options: typeof OPTIONS_TYPE): DynamicModule;
|
|
25
|
-
/**
|
|
26
|
-
* Registers the AuthModule asynchronously with factory functions.
|
|
27
|
-
* @param options - Async configuration options
|
|
28
|
-
* @returns Dynamic module configuration
|
|
29
|
-
*/
|
|
30
13
|
static forRootAsync(options: typeof ASYNC_OPTIONS_TYPE): DynamicModule;
|
|
31
|
-
/**
|
|
32
|
-
* Creates a new AuthModule instance.
|
|
33
|
-
* @param auth - The better-auth instance
|
|
34
|
-
* @param options - Auth module configuration options
|
|
35
|
-
* @param middlewareManager - Middleware manager for registering auth middleware
|
|
36
|
-
* @param authMiddleware - The auth middleware instance
|
|
37
|
-
*/
|
|
38
14
|
constructor(auth: Auth, options: AuthModuleOptions, middlewareManager: MiddlewareManager, authMiddleware: AuthMiddleware);
|
|
39
15
|
}
|
package/dist/auth.module.js
CHANGED
|
@@ -28,41 +28,17 @@ import { createOidcConfig } from "./utils/create-oidc-config.js";
|
|
|
28
28
|
import { createSocialProvidersConfig } from "./utils/create-social-providers-config.js";
|
|
29
29
|
import { isEnvTrue } from "./utils/is-env-true.js";
|
|
30
30
|
import { resolveSecret } from "./utils/resolve-secret.js";
|
|
31
|
-
/**
|
|
32
|
-
* Authentication module based on better-auth.
|
|
33
|
-
*
|
|
34
|
-
* @remarks
|
|
35
|
-
* Provides authentication services including session management, middleware registration,
|
|
36
|
-
* and MikroORM-based persistence via the better-auth adapter.
|
|
37
|
-
*/
|
|
38
31
|
let AuthModule = class AuthModule extends ConfigurableModuleClass {
|
|
39
32
|
auth;
|
|
40
33
|
options;
|
|
41
34
|
middlewareManager;
|
|
42
35
|
authMiddleware;
|
|
43
|
-
/**
|
|
44
|
-
* Registers the AuthModule with the given options.
|
|
45
|
-
* @param options - Configuration options including secret and middleware settings
|
|
46
|
-
* @returns Dynamic module configuration
|
|
47
|
-
*/
|
|
48
36
|
static forRoot(options) {
|
|
49
37
|
return super.forRoot(options);
|
|
50
38
|
}
|
|
51
|
-
/**
|
|
52
|
-
* Registers the AuthModule asynchronously with factory functions.
|
|
53
|
-
* @param options - Async configuration options
|
|
54
|
-
* @returns Dynamic module configuration
|
|
55
|
-
*/
|
|
56
39
|
static forRootAsync(options) {
|
|
57
40
|
return super.forRootAsync(options);
|
|
58
41
|
}
|
|
59
|
-
/**
|
|
60
|
-
* Creates a new AuthModule instance.
|
|
61
|
-
* @param auth - The better-auth instance
|
|
62
|
-
* @param options - Auth module configuration options
|
|
63
|
-
* @param middlewareManager - Middleware manager for registering auth middleware
|
|
64
|
-
* @param authMiddleware - The auth middleware instance
|
|
65
|
-
*/
|
|
66
42
|
constructor(auth, options, middlewareManager, authMiddleware) {
|
|
67
43
|
super();
|
|
68
44
|
this.auth = auth;
|
package/dist/auth.module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.module.js","sourceRoot":"","sources":["../src/auth.module.ts"],"names":[],"mapp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,CAAC;yBACnB;wBACD,QAAQ,EAAE,eAAe,CAAC;4BACxB,GAAG;4BACH,QAAQ,EAAE,OAAO,CAAC,QAAQ;yBAC3B,CAAC;qBACH,CAAC,CAAC;gBACL,CAAC;aACF;SACF;QACD,OAAO,EAAE,CAAC,WAAW,CAAC;KACvB,CAAC;IA8BG,WAAA,MAAM,CAAC,UAAU,CAAC,CAAA;IAElB,WAAA,MAAM,CAAC,oBAAoB,CAAC,CAAA;qDAEO,iBAAiB;QACpB,cAAc;GAlCtC,UAAU,CA+DtB"}
|
package/dist/auth.service.d.ts
CHANGED
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
import { type Auth } from "better-auth";
|
|
2
|
-
/** Service exposing the better-auth API to the application. */
|
|
3
2
|
export declare class AuthService {
|
|
4
|
-
/** @internal */
|
|
5
3
|
private readonly auth;
|
|
6
|
-
/**
|
|
7
|
-
* Creates a new AuthService instance.
|
|
8
|
-
* @param auth - The better-auth instance
|
|
9
|
-
*/
|
|
10
4
|
constructor(auth: Auth);
|
|
11
|
-
/** The better-auth API interface for session and user management. */
|
|
12
5
|
get api(): import("better-auth").InferAPI<{
|
|
13
6
|
readonly ok: import("better-auth").StrictEndpoint<"/ok", {
|
|
14
7
|
method: "GET";
|
package/dist/auth.service.js
CHANGED
|
@@ -12,17 +12,11 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
12
12
|
};
|
|
13
13
|
import { Inject } from "@nestjs/common";
|
|
14
14
|
import { AUTH_TOKEN } from "./auth.constants.js";
|
|
15
|
-
/** Service exposing the better-auth API to the application. */
|
|
16
15
|
let AuthService = class AuthService {
|
|
17
16
|
auth;
|
|
18
|
-
/**
|
|
19
|
-
* Creates a new AuthService instance.
|
|
20
|
-
* @param auth - The better-auth instance
|
|
21
|
-
*/
|
|
22
17
|
constructor(auth) {
|
|
23
18
|
this.auth = auth;
|
|
24
19
|
}
|
|
25
|
-
/** The better-auth API interface for session and user management. */
|
|
26
20
|
get api() {
|
|
27
21
|
return this.auth.api;
|
|
28
22
|
}
|
package/dist/auth.service.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.service.js","sourceRoot":"","sources":["../src/auth.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGxC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"auth.service.js","sourceRoot":"","sources":["../src/auth.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGxC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGjD,IAAa,WAAW,GAAxB,MAAa,WAAW;IAQH;IAHnB,YAGmB,IAAU;QAAV,SAAI,GAAJ,IAAI,CAAM;IAC1B,CAAC;IAGJ,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;IACvB,CAAC;CACF,CAAA;AAfY,WAAW;IAMnB,WAAA,MAAM,CAAC,UAAU,CAAC,CAAA;;GANV,WAAW,CAevB"}
|
|
@@ -1,30 +1,10 @@
|
|
|
1
|
-
/** Union of all lowercase letter characters (a–z). */
|
|
2
1
|
export type LowercaseLetter = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z";
|
|
3
|
-
/** Characters allowed in snake_case identifiers (lowercase letters and underscore). */
|
|
4
2
|
export type ValidChar = LowercaseLetter | "_";
|
|
5
|
-
/** Recursively validates that a string contains only valid snake_case characters. */
|
|
6
3
|
export type IsValidSnakeCase<S extends string> = S extends `${infer First}${infer Rest}` ? First extends ValidChar ? IsValidSnakeCase<Rest> : false : true;
|
|
7
|
-
/** Ensures a string literal is a valid snake_case identifier. */
|
|
8
4
|
export type SnakeCase<S extends string> = S extends "" ? never : S extends `_${string}` | `${string}_` ? never : S extends `${string}__${string}` ? never : IsValidSnakeCase<S> extends true ? S : never;
|
|
9
|
-
/**
|
|
10
|
-
* Stores key-value pairs for PostgreSQL transaction-level auth context.
|
|
11
|
-
*
|
|
12
|
-
* @remarks
|
|
13
|
-
* Values set here are emitted as `set_config('auth.<key>', '<value>', true)` SQL
|
|
14
|
-
* statements, enabling row-level security policies to access auth state.
|
|
15
|
-
*/
|
|
16
5
|
export declare class AuthTransactionContext {
|
|
17
|
-
/** Internal storage for transaction context key-value pairs. @internal */
|
|
18
6
|
private readonly ctx;
|
|
19
|
-
/**
|
|
20
|
-
* Sets a snake_case key-value pair in the transaction context.
|
|
21
|
-
* @param key - Must be a valid snake_case string
|
|
22
|
-
* @param value - The string value to associate with the key
|
|
23
|
-
* @returns This instance for chaining
|
|
24
|
-
*/
|
|
25
7
|
set<S extends string>(key: SnakeCase<S>, value: string): this;
|
|
26
|
-
/** Returns all stored key-value pairs as an array of `[key, value]` tuples. */
|
|
27
8
|
entries(): [string, string][];
|
|
28
|
-
/** Generates a SQL statement that sets all stored values as PostgreSQL transaction-local config variables. */
|
|
29
9
|
toSQL(): string;
|
|
30
10
|
}
|
|
@@ -1,19 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Stores key-value pairs for PostgreSQL transaction-level auth context.
|
|
3
|
-
*
|
|
4
|
-
* @remarks
|
|
5
|
-
* Values set here are emitted as `set_config('auth.<key>', '<value>', true)` SQL
|
|
6
|
-
* statements, enabling row-level security policies to access auth state.
|
|
7
|
-
*/
|
|
8
1
|
export class AuthTransactionContext {
|
|
9
|
-
/** Internal storage for transaction context key-value pairs. @internal */
|
|
10
2
|
ctx = new Map();
|
|
11
|
-
/**
|
|
12
|
-
* Sets a snake_case key-value pair in the transaction context.
|
|
13
|
-
* @param key - Must be a valid snake_case string
|
|
14
|
-
* @param value - The string value to associate with the key
|
|
15
|
-
* @returns This instance for chaining
|
|
16
|
-
*/
|
|
17
3
|
set(key, value) {
|
|
18
4
|
if (!/^[a-z]+(_[a-z]+)*$/.test(key)) {
|
|
19
5
|
throw new Error(`Key must only contain lowercase letters and underscores, cannot start/end with underscore, and cannot have consecutive underscores: ${key}`);
|
|
@@ -21,16 +7,14 @@ export class AuthTransactionContext {
|
|
|
21
7
|
this.ctx.set(key, value);
|
|
22
8
|
return this;
|
|
23
9
|
}
|
|
24
|
-
/** Returns all stored key-value pairs as an array of `[key, value]` tuples. */
|
|
25
10
|
entries() {
|
|
26
11
|
return Array.from(this.ctx.entries());
|
|
27
12
|
}
|
|
28
|
-
/** Generates a SQL statement that sets all stored values as PostgreSQL transaction-local config variables. */
|
|
29
13
|
toSQL() {
|
|
30
|
-
return
|
|
14
|
+
return `SELECT ${Array.from(this.ctx.entries())
|
|
31
15
|
.map(([key, value]) => {
|
|
32
16
|
const escapedValue = value.replace(/'/g, "''");
|
|
33
|
-
return
|
|
17
|
+
return `set_config('auth.${key}', '${escapedValue}', true)`;
|
|
34
18
|
})
|
|
35
19
|
.join(",")};`;
|
|
36
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.transaction-context.js","sourceRoot":"","sources":["../src/auth.transaction-context.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"auth.transaction-context.js","sourceRoot":"","sources":["../src/auth.transaction-context.ts"],"names":[],"mappings":"AA0DA,MAAM,OAAO,sBAAsB;IAEhB,GAAG,GAAG,IAAI,GAAG,EAAkB,CAAC;IAQjD,GAAG,CAAmB,GAAiB,EAAE,KAAa;QACpD,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YACpC,MAAM,IAAI,KAAK,CACb,uIAAuI,GAAG,EAAE,CAC7I,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IAGD,OAAO;QACL,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;IACxC,CAAC;IAGD,KAAK;QACH,OAAiB,UAAU,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;aACtD,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;YACpB,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAC/C,OAAiB,oBAAoB,GAAG,OAAO,YAAY,UAAU,CAAC;QACxE,CAAC,CAAC;aACD,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IAClB,CAAC;CACF"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { RequestContext } from "@nest-boot/request-context";
|
|
2
2
|
import { createParamDecorator } from "@nestjs/common";
|
|
3
3
|
import { BaseSession } from "../entities/session.entity.js";
|
|
4
|
-
/** Parameter decorator that injects the current {@link BaseSession} from the request context. */
|
|
5
4
|
export const CurrentSession = createParamDecorator(() => RequestContext.get(BaseSession));
|
|
6
5
|
//# sourceMappingURL=current-session.decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"current-session.decorator.js","sourceRoot":"","sources":["../../src/decorators/current-session.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEtD,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"current-session.decorator.js","sourceRoot":"","sources":["../../src/decorators/current-session.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEtD,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAG5D,MAAM,CAAC,MAAM,cAAc,GAAG,oBAAoB,CAAC,GAAG,EAAE,CACtD,cAAc,CAAC,GAAG,CAAC,WAAW,CAAC,CAChC,CAAC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { RequestContext } from "@nest-boot/request-context";
|
|
2
2
|
import { createParamDecorator } from "@nestjs/common";
|
|
3
3
|
import { BaseUser } from "../entities/user.entity.js";
|
|
4
|
-
/** Parameter decorator that injects the current {@link BaseUser} from the request context. */
|
|
5
4
|
export const CurrentUser = createParamDecorator(() => RequestContext.get(BaseUser));
|
|
6
5
|
//# sourceMappingURL=current-user.decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"current-user.decorator.js","sourceRoot":"","sources":["../../src/decorators/current-user.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"current-user.decorator.js","sourceRoot":"","sources":["../../src/decorators/current-user.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAGtD,MAAM,CAAC,MAAM,WAAW,GAAG,oBAAoB,CAAC,GAAG,EAAE,CACnD,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC,CAC7B,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { SetMetadata } from "@nestjs/common";
|
|
2
2
|
import { IS_PUBLIC_KEY } from "../auth.constants.js";
|
|
3
|
-
/** Decorator that marks a route as public, bypassing the {@link AuthGuard}. */
|
|
4
3
|
export const Public = (value = true) => SetMetadata(IS_PUBLIC_KEY, value);
|
|
5
4
|
//# sourceMappingURL=public.decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public.decorator.js","sourceRoot":"","sources":["../../src/decorators/public.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"public.decorator.js","sourceRoot":"","sources":["../../src/decorators/public.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGrD,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KAAK,GAAG,IAAI,EAAE,EAAE,CAAC,WAAW,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC"}
|
|
@@ -1,36 +1,16 @@
|
|
|
1
1
|
import { BaseEntity, type Opt } from "@mikro-orm/core";
|
|
2
|
-
/**
|
|
3
|
-
* Abstract base entity for OAuth/credential account records.
|
|
4
|
-
*
|
|
5
|
-
* @remarks
|
|
6
|
-
* Maps to the better-auth `account` model. Each account links a provider
|
|
7
|
-
* (e.g. Google, GitHub, credentials) to a {@link BaseUser}.
|
|
8
|
-
*/
|
|
9
2
|
export declare abstract class BaseAccount extends BaseEntity {
|
|
10
|
-
/** Primary key (UUID v4, auto-generated). */
|
|
11
3
|
id: Opt<string>;
|
|
12
|
-
/** Provider-scoped account identifier. */
|
|
13
4
|
accountId: string;
|
|
14
|
-
/** Authentication provider identifier (e.g. `"google"`, `"credential"`). */
|
|
15
5
|
providerId: string;
|
|
16
|
-
/** Foreign key referencing the owning {@link BaseUser}. */
|
|
17
6
|
userId: string;
|
|
18
|
-
/** OAuth access token, if available. */
|
|
19
7
|
accessToken?: Opt<string>;
|
|
20
|
-
/** OAuth refresh token, if available. */
|
|
21
8
|
refreshToken?: Opt<string>;
|
|
22
|
-
/** OpenID Connect ID token, if available. */
|
|
23
9
|
idToken?: Opt<string>;
|
|
24
|
-
/** Expiration timestamp of the access token. */
|
|
25
10
|
accessTokenExpiresAt?: Opt<Date>;
|
|
26
|
-
/** Expiration timestamp of the refresh token. */
|
|
27
11
|
refreshTokenExpiresAt?: Opt<Date>;
|
|
28
|
-
/** OAuth scopes granted to this account. */
|
|
29
12
|
scope?: Opt<string>;
|
|
30
|
-
/** Hashed password for credential-based accounts. */
|
|
31
13
|
password?: Opt<string>;
|
|
32
|
-
/** Timestamp when the account was created. */
|
|
33
14
|
createdAt: Opt<Date>;
|
|
34
|
-
/** Timestamp of the last update. */
|
|
35
15
|
updatedAt: Opt<Date>;
|
|
36
16
|
}
|
|
@@ -10,39 +10,19 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
10
10
|
import { BaseEntity, Cascade, t } from "@mikro-orm/core";
|
|
11
11
|
import { Entity, ManyToOne, PrimaryKey, Property, } from "@mikro-orm/decorators/legacy";
|
|
12
12
|
import { randomUUID } from "crypto";
|
|
13
|
-
/**
|
|
14
|
-
* Abstract base entity for OAuth/credential account records.
|
|
15
|
-
*
|
|
16
|
-
* @remarks
|
|
17
|
-
* Maps to the better-auth `account` model. Each account links a provider
|
|
18
|
-
* (e.g. Google, GitHub, credentials) to a {@link BaseUser}.
|
|
19
|
-
*/
|
|
20
13
|
let BaseAccount = class BaseAccount extends BaseEntity {
|
|
21
|
-
/** Primary key (UUID v4, auto-generated). */
|
|
22
14
|
id = randomUUID();
|
|
23
|
-
/** Provider-scoped account identifier. */
|
|
24
15
|
accountId;
|
|
25
|
-
/** Authentication provider identifier (e.g. `"google"`, `"credential"`). */
|
|
26
16
|
providerId;
|
|
27
|
-
/** Foreign key referencing the owning {@link BaseUser}. */
|
|
28
17
|
userId;
|
|
29
|
-
/** OAuth access token, if available. */
|
|
30
18
|
accessToken;
|
|
31
|
-
/** OAuth refresh token, if available. */
|
|
32
19
|
refreshToken;
|
|
33
|
-
/** OpenID Connect ID token, if available. */
|
|
34
20
|
idToken;
|
|
35
|
-
/** Expiration timestamp of the access token. */
|
|
36
21
|
accessTokenExpiresAt;
|
|
37
|
-
/** Expiration timestamp of the refresh token. */
|
|
38
22
|
refreshTokenExpiresAt;
|
|
39
|
-
/** OAuth scopes granted to this account. */
|
|
40
23
|
scope;
|
|
41
|
-
/** Hashed password for credential-based accounts. */
|
|
42
24
|
password;
|
|
43
|
-
/** Timestamp when the account was created. */
|
|
44
25
|
createdAt = new Date();
|
|
45
|
-
/** Timestamp of the last update. */
|
|
46
26
|
updatedAt = new Date();
|
|
47
27
|
};
|
|
48
28
|
__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.entity.js","sourceRoot":"","sources":["../../src/entities/account.entity.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAY,CAAC,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EACL,MAAM,EACN,SAAS,EACT,UAAU,EACV,QAAQ,GACT,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"account.entity.js","sourceRoot":"","sources":["../../src/entities/account.entity.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAY,CAAC,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EACL,MAAM,EACN,SAAS,EACT,UAAU,EACV,QAAQ,GACT,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAU7B,IAAe,WAAW,GAA1B,MAAe,WAAY,SAAQ,UAAU;IAGlD,EAAE,GAAgB,UAAU,EAAE,CAAC;IAI/B,SAAS,CAAU;IAInB,UAAU,CAAU;IASpB,MAAM,CAAU;IAIhB,WAAW,CAAe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AI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;0CACvB;AAIpB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;6CACpB;AAIvB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC;;8CAClB;AAQlC;IALC,QAAQ,CAAC;QACR,IAAI,EAAE,CAAC,CAAC,QAAQ;QAChB,UAAU,EAAE,OAAO;QACnB,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE;KAC3B,CAAC;;8CACgC;AA5Dd,WAAW;IADhC,MAAM,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;GACL,WAAW,CA6DhC"}
|
|
@@ -1,26 +1,11 @@
|
|
|
1
1
|
import { BaseEntity, type Opt } from "@mikro-orm/core";
|
|
2
|
-
/**
|
|
3
|
-
* Abstract base entity for user session records.
|
|
4
|
-
*
|
|
5
|
-
* @remarks
|
|
6
|
-
* Maps to the better-auth `session` model. Each session is tied to a
|
|
7
|
-
* {@link BaseUser} and identified by a unique token.
|
|
8
|
-
*/
|
|
9
2
|
export declare class BaseSession extends BaseEntity {
|
|
10
|
-
/** Primary key (UUID v4, auto-generated). */
|
|
11
3
|
id: Opt<string>;
|
|
12
|
-
/** Unique session token used for authentication. */
|
|
13
4
|
token: string;
|
|
14
|
-
/** Foreign key referencing the owning {@link BaseUser}. */
|
|
15
5
|
userId: string;
|
|
16
|
-
/** Timestamp when the session expires. */
|
|
17
6
|
expiresAt: Date;
|
|
18
|
-
/** IP address of the client that created or last used this session. */
|
|
19
7
|
ipAddress?: Opt<string>;
|
|
20
|
-
/** User-Agent header from the client that created or last used this session. */
|
|
21
8
|
userAgent?: Opt<string>;
|
|
22
|
-
/** Timestamp when the session was created. */
|
|
23
9
|
createdAt: Opt<Date>;
|
|
24
|
-
/** Timestamp of the last update. */
|
|
25
10
|
updatedAt: Opt<Date>;
|
|
26
11
|
}
|
|
@@ -10,29 +10,14 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
10
10
|
import { BaseEntity, Cascade, t } from "@mikro-orm/core";
|
|
11
11
|
import { Entity, ManyToOne, PrimaryKey, Property, Unique, } from "@mikro-orm/decorators/legacy";
|
|
12
12
|
import { randomUUID } from "crypto";
|
|
13
|
-
/**
|
|
14
|
-
* Abstract base entity for user session records.
|
|
15
|
-
*
|
|
16
|
-
* @remarks
|
|
17
|
-
* Maps to the better-auth `session` model. Each session is tied to a
|
|
18
|
-
* {@link BaseUser} and identified by a unique token.
|
|
19
|
-
*/
|
|
20
13
|
let BaseSession = class BaseSession extends BaseEntity {
|
|
21
|
-
/** Primary key (UUID v4, auto-generated). */
|
|
22
14
|
id = randomUUID();
|
|
23
|
-
/** Unique session token used for authentication. */
|
|
24
15
|
token;
|
|
25
|
-
/** Foreign key referencing the owning {@link BaseUser}. */
|
|
26
16
|
userId;
|
|
27
|
-
/** Timestamp when the session expires. */
|
|
28
17
|
expiresAt;
|
|
29
|
-
/** IP address of the client that created or last used this session. */
|
|
30
18
|
ipAddress;
|
|
31
|
-
/** User-Agent header from the client that created or last used this session. */
|
|
32
19
|
userAgent;
|
|
33
|
-
/** Timestamp when the session was created. */
|
|
34
20
|
createdAt = new Date();
|
|
35
|
-
/** Timestamp of the last update. */
|
|
36
21
|
updatedAt = new Date();
|
|
37
22
|
};
|
|
38
23
|
__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.entity.js","sourceRoot":"","sources":["../../src/entities/session.entity.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAY,CAAC,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EACL,MAAM,EACN,SAAS,EACT,UAAU,EACV,QAAQ,EACR,MAAM,GACP,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,UAA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AAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;8CACnB;AAIxB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC;;8CAClB;AAQlC;IALC,QAAQ,CAAC;QACR,IAAI,EAAE,CAAC,CAAC,QAAQ;QAChB,UAAU,EAAE,OAAO;QACnB,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE;KAC3B,CAAC;;8CACgC;AAzCvB,WAAW;IADvB,MAAM,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;GACd,WAAW,CA0CvB"}
|
|
@@ -1,24 +1,10 @@
|
|
|
1
1
|
import { BaseEntity, type Opt } from "@mikro-orm/core";
|
|
2
|
-
/**
|
|
3
|
-
* Abstract base entity for user records.
|
|
4
|
-
*
|
|
5
|
-
* @remarks
|
|
6
|
-
* Maps to the better-auth `user` model. Provides core identity fields
|
|
7
|
-
* such as name, email, and avatar, intended to be extended by the application.
|
|
8
|
-
*/
|
|
9
2
|
export declare class BaseUser extends BaseEntity {
|
|
10
|
-
/** Primary key (UUID v4, auto-generated). */
|
|
11
3
|
id: Opt<string>;
|
|
12
|
-
/** Display name of the user. */
|
|
13
4
|
name: string;
|
|
14
|
-
/** Unique email address of the user. */
|
|
15
5
|
email: string;
|
|
16
|
-
/** Whether the email address has been verified. */
|
|
17
6
|
emailVerified: boolean;
|
|
18
|
-
/** URL of the user's avatar image. */
|
|
19
7
|
image?: Opt<string>;
|
|
20
|
-
/** Timestamp when the user was created. */
|
|
21
8
|
createdAt: Opt<Date>;
|
|
22
|
-
/** Timestamp of the last update. */
|
|
23
9
|
updatedAt: Opt<Date>;
|
|
24
10
|
}
|
|
@@ -10,27 +10,13 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
10
10
|
import { BaseEntity, t } from "@mikro-orm/core";
|
|
11
11
|
import { Entity, PrimaryKey, Property, Unique, } from "@mikro-orm/decorators/legacy";
|
|
12
12
|
import { randomUUID } from "crypto";
|
|
13
|
-
/**
|
|
14
|
-
* Abstract base entity for user records.
|
|
15
|
-
*
|
|
16
|
-
* @remarks
|
|
17
|
-
* Maps to the better-auth `user` model. Provides core identity fields
|
|
18
|
-
* such as name, email, and avatar, intended to be extended by the application.
|
|
19
|
-
*/
|
|
20
13
|
let BaseUser = class BaseUser extends BaseEntity {
|
|
21
|
-
/** Primary key (UUID v4, auto-generated). */
|
|
22
14
|
id = randomUUID();
|
|
23
|
-
/** Display name of the user. */
|
|
24
15
|
name;
|
|
25
|
-
/** Unique email address of the user. */
|
|
26
16
|
email;
|
|
27
|
-
/** Whether the email address has been verified. */
|
|
28
17
|
emailVerified;
|
|
29
|
-
/** URL of the user's avatar image. */
|
|
30
18
|
image;
|
|
31
|
-
/** Timestamp when the user was created. */
|
|
32
19
|
createdAt = new Date();
|
|
33
|
-
/** Timestamp of the last update. */
|
|
34
20
|
updatedAt = new Date();
|
|
35
21
|
};
|
|
36
22
|
__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.entity.js","sourceRoot":"","sources":["../../src/entities/user.entity.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAY,CAAC,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EACL,MAAM,EACN,UAAU,EACV,QAAQ,EACR,MAAM,GACP,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"user.entity.js","sourceRoot":"","sources":["../../src/entities/user.entity.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAY,CAAC,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EACL,MAAM,EACN,UAAU,EACV,QAAQ,EACR,MAAM,GACP,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CA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|
|
5
|
-
* @remarks
|
|
6
|
-
* Used for email verification tokens, password reset tokens, and similar
|
|
7
|
-
* time-limited verification flows managed by better-auth.
|
|
8
|
-
*/
|
|
9
2
|
export declare abstract class BaseVerification extends BaseEntity {
|
|
10
|
-
/** Primary key (UUID v4, auto-generated). */
|
|
11
3
|
id: Opt<string>;
|
|
12
|
-
/** Identifier associated with this verification (e.g. email address). */
|
|
13
4
|
identifier: string;
|
|
14
|
-
/** Verification token value. */
|
|
15
5
|
value: string;
|
|
16
|
-
/** Timestamp when this verification expires. */
|
|
17
6
|
expiresAt: Date;
|
|
18
|
-
/** Timestamp when the verification was created. */
|
|
19
7
|
createdAt: Opt<Date>;
|
|
20
|
-
/** Timestamp of the last update. */
|
|
21
8
|
updatedAt: Opt<Date>;
|
|
22
9
|
}
|
|
@@ -10,25 +10,12 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
10
10
|
import { BaseEntity, t } from "@mikro-orm/core";
|
|
11
11
|
import { Entity, PrimaryKey, Property } from "@mikro-orm/decorators/legacy";
|
|
12
12
|
import { randomUUID } from "crypto";
|
|
13
|
-
/**
|
|
14
|
-
* Abstract base entity for verification records.
|
|
15
|
-
*
|
|
16
|
-
* @remarks
|
|
17
|
-
* Used for email verification tokens, password reset tokens, and similar
|
|
18
|
-
* time-limited verification flows managed by better-auth.
|
|
19
|
-
*/
|
|
20
13
|
let BaseVerification = class BaseVerification extends BaseEntity {
|
|
21
|
-
/** Primary key (UUID v4, auto-generated). */
|
|
22
14
|
id = randomUUID();
|
|
23
|
-
/** Identifier associated with this verification (e.g. email address). */
|
|
24
15
|
identifier;
|
|
25
|
-
/** Verification token value. */
|
|
26
16
|
value;
|
|
27
|
-
/** Timestamp when this verification expires. */
|
|
28
17
|
expiresAt;
|
|
29
|
-
/** Timestamp when the verification was created. */
|
|
30
18
|
createdAt = new Date();
|
|
31
|
-
/** Timestamp of the last update. */
|
|
32
19
|
updatedAt = new Date();
|
|
33
20
|
};
|
|
34
21
|
__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verification.entity.js","sourceRoot":"","sources":["../../src/entities/verification.entity.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAY,CAAC,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"verification.entity.js","sourceRoot":"","sources":["../../src/entities/verification.entity.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAY,CAAC,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAU7B,IAAe,gBAAgB,GAA/B,MAAe,gBAAiB,SAAQ,UAAU;IAGvD,EAAE,GAAgB,UAAU,EAAE,CAAC;IAI/B,UAAU,CAAU;IAIpB,KAAK,CAAU;IAIf,SAAS,CAAQ;IAIjB,SAAS,GAAc,IAAI,IAAI,EAAE,CAAC;IAQlC,SAAS,GAAc,IAAI,IAAI,EAAE,CAAC;CACnC,CAAA;AAzBC;IADC,UAAU,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;;4CACE;AAI/B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;;oDACP;AAIpB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;;+CACZ;AAIf;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;8BACnB,IAAI;mDAAC;AAIjB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC;;mDAClB;AAQlC;IALC,QAAQ,CAAC;QACR,IAAI,EAAE,CAAC,CAAC,QAAQ;QAChB,UAAU,EAAE,OAAO;QACnB,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE;KAC3B,CAAC;;mDACgC;AA3Bd,gBAAgB;IADrC,MAAM,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;GACL,gBAAgB,CA4BrC"}
|
|
@@ -1,8 +1 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Estimates the entropy of a string in bits.
|
|
3
|
-
* This is a simple approximation that helps detect low-entropy secrets.
|
|
4
|
-
*
|
|
5
|
-
* @param str - The string to estimate entropy for
|
|
6
|
-
* @returns The estimated entropy in bits
|
|
7
|
-
*/
|
|
8
1
|
export declare function estimateEntropy(str: string): number;
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Estimates the entropy of a string in bits.
|
|
3
|
-
* This is a simple approximation that helps detect low-entropy secrets.
|
|
4
|
-
*
|
|
5
|
-
* @param str - The string to estimate entropy for
|
|
6
|
-
* @returns The estimated entropy in bits
|
|
7
|
-
*/
|
|
8
1
|
export function estimateEntropy(str) {
|
|
9
2
|
const unique = new Set(str).size;
|
|
10
3
|
if (unique === 0)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"estimate-entropy.js","sourceRoot":"","sources":["../../src/utils/estimate-entropy.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"estimate-entropy.js","sourceRoot":"","sources":["../../src/utils/estimate-entropy.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,eAAe,CAAC,GAAW;IACzC,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;IACjC,IAAI,MAAM,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IAC3B,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -5,19 +5,19 @@ export function resolveSecret(options) {
|
|
|
5
5
|
throw new Error("Auth secret is required.\n" +
|
|
6
6
|
"Set AUTH_SECRET or APP_SECRET environment variable, or pass a secret option.\n" +
|
|
7
7
|
"Generate a secure secret with:\n" +
|
|
8
|
-
" node -e \"console.log(
|
|
8
|
+
" node --input-type=module -e \"import { randomBytes } from 'node:crypto'; console.log(randomBytes(32).toString('base64url'))\"");
|
|
9
9
|
}
|
|
10
10
|
if (secret.length < 32) {
|
|
11
11
|
throw new Error("Auth secret must be at least 32 characters long.\n" +
|
|
12
12
|
"Set AUTH_SECRET or APP_SECRET environment variable, or pass a secret option.\n" +
|
|
13
13
|
"Generate a secure secret with:\n" +
|
|
14
|
-
" node -e \"console.log(
|
|
14
|
+
" node --input-type=module -e \"import { randomBytes } from 'node:crypto'; console.log(randomBytes(32).toString('base64url'))\"");
|
|
15
15
|
}
|
|
16
16
|
if (estimateEntropy(secret) < 120) {
|
|
17
17
|
throw new Error("Auth secret appears low-entropy.\n" +
|
|
18
18
|
"Use a randomly generated secret for production.\n" +
|
|
19
19
|
"Generate a secure secret with:\n" +
|
|
20
|
-
" node -e \"console.log(
|
|
20
|
+
" node --input-type=module -e \"import { randomBytes } from 'node:crypto'; console.log(randomBytes(32).toString('base64url'))\"");
|
|
21
21
|
}
|
|
22
22
|
return secret;
|
|
23
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-secret.js","sourceRoot":"","sources":["../../src/utils/resolve-secret.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,MAAM,UAAU,aAAa,CAAC,OAA0B;IACtD,MAAM,MAAM,GACV,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC;IAEtE,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CACb,4BAA4B;YAC1B,gFAAgF;YAChF,kCAAkC;YAClC,
|
|
1
|
+
{"version":3,"file":"resolve-secret.js","sourceRoot":"","sources":["../../src/utils/resolve-secret.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,MAAM,UAAU,aAAa,CAAC,OAA0B;IACtD,MAAM,MAAM,GACV,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC;IAEtE,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CACb,4BAA4B;YAC1B,gFAAgF;YAChF,kCAAkC;YAClC,iIAAiI,CACpI,CAAC;IACJ,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CACb,oDAAoD;YAClD,gFAAgF;YAChF,kCAAkC;YAClC,iIAAiI,CACpI,CAAC;IACJ,CAAC;IAED,IAAI,eAAe,CAAC,MAAM,CAAC,GAAG,GAAG,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CACb,oCAAoC;YAClC,mDAAmD;YACnD,kCAAkC;YAClC,iIAAiI,CACpI,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nest-boot/auth",
|
|
3
|
-
"version": "8.0.0-beta.
|
|
3
|
+
"version": "8.0.0-beta.2",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/nest-boot/nest-boot.git",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
},
|
|
15
15
|
"homepage": "",
|
|
16
16
|
"license": "MIT",
|
|
17
|
-
"main": "dist/index.js",
|
|
18
|
-
"types": "dist/index.d.ts",
|
|
17
|
+
"main": "./dist/index.js",
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
19
|
"directories": {
|
|
20
20
|
"lib": "dist"
|
|
21
21
|
},
|
|
@@ -23,37 +23,39 @@
|
|
|
23
23
|
"dist"
|
|
24
24
|
],
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@mikro-orm/core": "7.1.
|
|
27
|
-
"@mikro-orm/decorators": "7.1.
|
|
28
|
-
"@nestjs/common": "
|
|
29
|
-
"@nestjs/config": "
|
|
30
|
-
"@nestjs/core": "
|
|
31
|
-
"@nestjs/testing": "
|
|
26
|
+
"@mikro-orm/core": "7.1.14",
|
|
27
|
+
"@mikro-orm/decorators": "7.1.14",
|
|
28
|
+
"@nestjs/common": "^12.0.1",
|
|
29
|
+
"@nestjs/config": "^12.0.0",
|
|
30
|
+
"@nestjs/core": "^12.0.1",
|
|
31
|
+
"@nestjs/testing": "^12.0.1",
|
|
32
32
|
"@types/express": "^5.0.3",
|
|
33
33
|
"@types/node": "^26.0.0",
|
|
34
|
+
"@vitest/coverage-v8": "^4.1.11",
|
|
34
35
|
"better-auth": "^1.4.10",
|
|
35
36
|
"express": "^5.1.0",
|
|
36
37
|
"reflect-metadata": "^0.2.2",
|
|
37
38
|
"rxjs": "^7.8.2",
|
|
38
39
|
"typescript": "^6.0.3",
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"@nest-boot/eslint-
|
|
42
|
-
"@nest-boot/middleware": "^8.0.0-beta.
|
|
43
|
-
"@nest-boot/
|
|
44
|
-
"@nest-boot/
|
|
40
|
+
"vite-tsconfig-paths": "^5.1.4",
|
|
41
|
+
"vitest": "^4.1.11",
|
|
42
|
+
"@nest-boot/eslint-config": "^8.0.0-beta.2",
|
|
43
|
+
"@nest-boot/middleware": "^8.0.0-beta.2",
|
|
44
|
+
"@nest-boot/eslint-plugin": "^8.0.0-beta.2",
|
|
45
|
+
"@nest-boot/request-context": "^8.0.0-beta.2",
|
|
46
|
+
"@nest-boot/tsconfig": "^8.0.0-beta.2"
|
|
45
47
|
},
|
|
46
48
|
"peerDependencies": {
|
|
47
49
|
"@mikro-orm/core": "^7.0.0",
|
|
48
50
|
"@mikro-orm/decorators": "^7.0.0",
|
|
49
|
-
"@nestjs/common": "^12.0.0
|
|
50
|
-
"@nestjs/core": "^12.0.0
|
|
51
|
+
"@nestjs/common": "^12.0.0",
|
|
52
|
+
"@nestjs/core": "^12.0.0",
|
|
51
53
|
"better-auth": "^1.4.10",
|
|
52
54
|
"express": "^5.0.0",
|
|
53
55
|
"reflect-metadata": "^0.2.2",
|
|
54
56
|
"rxjs": "^7.0.0",
|
|
55
|
-
"@nest-boot/middleware": "^8.0.0-beta.
|
|
56
|
-
"@nest-boot/request-context": "^8.0.0-beta.
|
|
57
|
+
"@nest-boot/middleware": "^8.0.0-beta.2",
|
|
58
|
+
"@nest-boot/request-context": "^8.0.0-beta.2"
|
|
57
59
|
},
|
|
58
60
|
"publishConfig": {
|
|
59
61
|
"access": "public"
|
|
@@ -65,12 +67,25 @@
|
|
|
65
67
|
]
|
|
66
68
|
},
|
|
67
69
|
"type": "module",
|
|
70
|
+
"engines": {
|
|
71
|
+
"node": ">=26.0.0"
|
|
72
|
+
},
|
|
73
|
+
"exports": {
|
|
74
|
+
".": {
|
|
75
|
+
"types": "./dist/index.d.ts",
|
|
76
|
+
"import": "./dist/index.js"
|
|
77
|
+
},
|
|
78
|
+
"./package.json": "./package.json"
|
|
79
|
+
},
|
|
68
80
|
"scripts": {
|
|
69
81
|
"build": "tsc -p tsconfig.build.json",
|
|
70
82
|
"clean": "rm -rf .nx && rm -rf node_modules && rm -rf dist",
|
|
71
83
|
"dev": "tsc -w -p tsconfig.build.json",
|
|
72
84
|
"lint": "eslint \"{src,test}/**/*.ts\"",
|
|
73
85
|
"lint:fix": "eslint \"{src,test}/**/*.ts\" --fix",
|
|
74
|
-
"test": "vitest run"
|
|
86
|
+
"test": "vitest run",
|
|
87
|
+
"test:cov": "vitest run --coverage",
|
|
88
|
+
"test:watch": "vitest",
|
|
89
|
+
"test:debug": "vitest --inspect-brk --no-file-parallelism"
|
|
75
90
|
}
|
|
76
91
|
}
|