@nest-boot/auth 7.0.0 → 7.2.0

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.
Files changed (80) hide show
  1. package/dist/adapters/mikro-orm-adapter.d.ts +23 -0
  2. package/dist/adapters/mikro-orm-adapter.js +155 -0
  3. package/dist/adapters/mikro-orm-adapter.js.map +1 -0
  4. package/dist/auth-module-options.interface.d.ts +12 -0
  5. package/dist/auth-module-options.interface.js.map +1 -0
  6. package/dist/auth.constants.d.ts +2 -4
  7. package/dist/auth.constants.js +3 -5
  8. package/dist/auth.constants.js.map +1 -1
  9. package/dist/auth.guard.d.ts +6 -35
  10. package/dist/auth.guard.js +15 -102
  11. package/dist/auth.guard.js.map +1 -1
  12. package/dist/auth.interceptor.d.ts +19 -0
  13. package/dist/auth.interceptor.js +97 -0
  14. package/dist/auth.interceptor.js.map +1 -0
  15. package/dist/auth.middleware.d.ts +13 -0
  16. package/dist/auth.middleware.js +64 -0
  17. package/dist/auth.middleware.js.map +1 -0
  18. package/dist/auth.module-definition.d.ts +1 -1
  19. package/dist/auth.module.d.ts +11 -1
  20. package/dist/auth.module.js +49 -13
  21. package/dist/auth.module.js.map +1 -1
  22. package/dist/auth.service.d.ts +3 -61
  23. package/dist/auth.service.js +5 -109
  24. package/dist/auth.service.js.map +1 -1
  25. package/dist/auth.transaction-context.d.ts +11 -0
  26. package/dist/auth.transaction-context.js +28 -0
  27. package/dist/auth.transaction-context.js.map +1 -0
  28. package/dist/decorators/current-session.decorator.d.ts +1 -0
  29. package/dist/decorators/current-session.decorator.js +15 -0
  30. package/dist/decorators/current-session.decorator.js.map +1 -0
  31. package/dist/decorators/current-user.decorator.d.ts +1 -1
  32. package/dist/decorators/current-user.decorator.js +9 -4
  33. package/dist/decorators/current-user.decorator.js.map +1 -1
  34. package/dist/decorators/index.d.ts +2 -3
  35. package/dist/decorators/index.js +2 -3
  36. package/dist/decorators/index.js.map +1 -1
  37. package/dist/decorators/public.decorator.d.ts +2 -0
  38. package/dist/decorators/public.decorator.js +8 -0
  39. package/dist/decorators/public.decorator.js.map +1 -0
  40. package/dist/entities/account.entity.d.ts +16 -0
  41. package/dist/entities/account.entity.js +87 -0
  42. package/dist/entities/account.entity.js.map +1 -0
  43. package/dist/entities/index.d.ts +3 -1
  44. package/dist/entities/index.js +3 -1
  45. package/dist/entities/index.js.map +1 -1
  46. package/dist/entities/session.entity.d.ts +11 -0
  47. package/dist/entities/session.entity.js +68 -0
  48. package/dist/entities/session.entity.js.map +1 -0
  49. package/dist/entities/user.entity.d.ts +5 -8
  50. package/dist/entities/user.entity.js +31 -40
  51. package/dist/entities/user.entity.js.map +1 -1
  52. package/dist/entities/verification.entity.d.ts +9 -0
  53. package/dist/entities/verification.entity.js +55 -0
  54. package/dist/entities/verification.entity.js.map +1 -0
  55. package/dist/index.d.ts +1 -2
  56. package/dist/index.js +1 -2
  57. package/dist/index.js.map +1 -1
  58. package/dist/tsconfig.build.tsbuildinfo +1 -1
  59. package/package.json +9 -17
  60. package/dist/decorators/can.decorator.d.ts +0 -1
  61. package/dist/decorators/can.decorator.js +0 -8
  62. package/dist/decorators/can.decorator.js.map +0 -1
  63. package/dist/decorators/current-personal-access-token.decorator.d.ts +0 -1
  64. package/dist/decorators/current-personal-access-token.decorator.js +0 -10
  65. package/dist/decorators/current-personal-access-token.decorator.js.map +0 -1
  66. package/dist/decorators/require-auth.decorator.d.ts +0 -1
  67. package/dist/decorators/require-auth.decorator.js +0 -8
  68. package/dist/decorators/require-auth.decorator.js.map +0 -1
  69. package/dist/entities/personal-access-token.entity.d.ts +0 -14
  70. package/dist/entities/personal-access-token.entity.js +0 -72
  71. package/dist/entities/personal-access-token.entity.js.map +0 -1
  72. package/dist/interfaces/auth-module-options.interface.d.ts +0 -10
  73. package/dist/interfaces/auth-module-options.interface.js.map +0 -1
  74. package/dist/interfaces/index.d.ts +0 -1
  75. package/dist/interfaces/index.js +0 -18
  76. package/dist/interfaces/index.js.map +0 -1
  77. package/dist/utils/random-string.util.d.ts +0 -6
  78. package/dist/utils/random-string.util.js +0 -26
  79. package/dist/utils/random-string.util.js.map +0 -1
  80. /package/dist/{interfaces/auth-module-options.interface.js → auth-module-options.interface.js} +0 -0
@@ -1,4 +1,4 @@
1
- import { type AuthModuleOptions } from "./interfaces";
1
+ import { type AuthModuleOptions } from "./auth-module-options.interface";
2
2
  export declare const ConfigurableModuleClass: import("@nestjs/common").ConfigurableModuleCls<AuthModuleOptions, "register", "create", {
3
3
  isGlobal: boolean;
4
4
  }>, MODULE_OPTIONS_TOKEN: string | symbol;
@@ -1,3 +1,13 @@
1
+ import { MiddlewareConsumer, NestModule, OnModuleInit } from "@nestjs/common";
2
+ import { HttpAdapterHost } from "@nestjs/core";
3
+ import { Auth } from "better-auth";
1
4
  import { ConfigurableModuleClass } from "./auth.module-definition";
2
- export declare class AuthModule extends ConfigurableModuleClass {
5
+ import { AuthModuleOptions } from "./auth-module-options.interface";
6
+ export declare class AuthModule extends ConfigurableModuleClass implements NestModule, OnModuleInit {
7
+ private readonly adapterHost;
8
+ private readonly auth;
9
+ private readonly options;
10
+ constructor(adapterHost: HttpAdapterHost, auth: Auth, options: AuthModuleOptions);
11
+ configure(consumer: MiddlewareConsumer): void;
12
+ onModuleInit(): void;
3
13
  }
@@ -5,29 +5,65 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
6
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
7
  };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
8
14
  Object.defineProperty(exports, "__esModule", { value: true });
9
15
  exports.AuthModule = void 0;
10
- const request_context_1 = require("@nest-boot/request-context");
16
+ const core_1 = require("@mikro-orm/core");
11
17
  const common_1 = require("@nestjs/common");
12
- const core_1 = require("@nestjs/core");
13
- const auth_guard_1 = require("./auth.guard");
18
+ const core_2 = require("@nestjs/core");
19
+ const better_auth_1 = require("better-auth");
20
+ const node_1 = require("better-auth/node");
21
+ const mikro_orm_adapter_1 = require("./adapters/mikro-orm-adapter");
22
+ const auth_constants_1 = require("./auth.constants");
23
+ const auth_middleware_1 = require("./auth.middleware");
14
24
  const auth_module_definition_1 = require("./auth.module-definition");
15
25
  const auth_service_1 = require("./auth.service");
26
+ const authProvider = {
27
+ provide: auth_constants_1.AUTH_TOKEN,
28
+ inject: [auth_module_definition_1.MODULE_OPTIONS_TOKEN, core_1.MikroORM],
29
+ useFactory: (options, orm) => (0, better_auth_1.betterAuth)({
30
+ ...options,
31
+ database: (0, mikro_orm_adapter_1.mikroOrmAdapter)({
32
+ orm,
33
+ entities: options.entities,
34
+ }),
35
+ }),
36
+ };
16
37
  let AuthModule = class AuthModule extends auth_module_definition_1.ConfigurableModuleClass {
38
+ constructor(adapterHost, auth, options) {
39
+ super();
40
+ this.adapterHost = adapterHost;
41
+ this.auth = auth;
42
+ this.options = options;
43
+ }
44
+ configure(consumer) {
45
+ const proxy = consumer.apply(auth_middleware_1.AuthMiddleware);
46
+ if (this.options.middleware?.excludeRoutes) {
47
+ proxy.exclude(...this.options.middleware.excludeRoutes);
48
+ }
49
+ proxy.forRoutes(...(this.options.middleware?.includeRoutes ?? ["*"]));
50
+ }
51
+ onModuleInit() {
52
+ const httpAdapter = this.adapterHost.httpAdapter;
53
+ if (httpAdapter) {
54
+ const app = httpAdapter.getInstance();
55
+ app.all(this.options.basePath ?? "/api/auth/{*any}", (0, node_1.toNodeHandler)(this.auth));
56
+ }
57
+ }
17
58
  };
18
59
  exports.AuthModule = AuthModule;
19
60
  exports.AuthModule = AuthModule = __decorate([
20
61
  (0, common_1.Module)({
21
- imports: [request_context_1.RequestContextModule],
22
- providers: [
23
- {
24
- provide: core_1.APP_GUARD,
25
- useClass: auth_guard_1.AuthGuard,
26
- },
27
- auth_service_1.AuthService,
28
- core_1.Reflector,
29
- ],
62
+ providers: [authProvider, auth_service_1.AuthService],
30
63
  exports: [auth_service_1.AuthService],
31
- })
64
+ }),
65
+ __param(1, (0, common_1.Inject)(auth_constants_1.AUTH_TOKEN)),
66
+ __param(2, (0, common_1.Inject)(auth_module_definition_1.MODULE_OPTIONS_TOKEN)),
67
+ __metadata("design:paramtypes", [core_2.HttpAdapterHost, Object, Object])
32
68
  ], AuthModule);
33
69
  //# sourceMappingURL=auth.module.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth.module.js","sourceRoot":"","sources":["../src/auth.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,gEAAkE;AAClE,2CAAwC;AACxC,uCAAoD;AAEpD,6CAAyC;AACzC,qEAAmE;AACnE,iDAA6C;AActC,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,gDAAuB;CAAG,CAAA;AAA7C,gCAAU;qBAAV,UAAU;IAZtB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,sCAAoB,CAAC;QAC/B,SAAS,EAAE;YACT;gBACE,OAAO,EAAE,gBAAS;gBAClB,QAAQ,EAAE,sBAAS;aACpB;YACD,0BAAW;YACX,gBAAS;SACV;QACD,OAAO,EAAE,CAAC,0BAAW,CAAC;KACvB,CAAC;GACW,UAAU,CAAmC"}
1
+ {"version":3,"file":"auth.module.js","sourceRoot":"","sources":["../src/auth.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,0CAA2C;AAC3C,2CAOwB;AACxB,uCAA+C;AAC/C,6CAA+C;AAC/C,2CAAiD;AAGjD,oEAA+D;AAC/D,qDAA8C;AAC9C,uDAAmD;AACnD,qEAGkC;AAClC,iDAA6C;AAG7C,MAAM,YAAY,GAAa;IAC7B,OAAO,EAAE,2BAAU;IACnB,MAAM,EAAE,CAAC,6CAAo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tB,IAAA,eAAM,EAAC;QACN,SAAS,EAAE,CAAC,YAAY,EAAE,0BAAW,CAAC;QACtC,OAAO,EAAE,CAAC,0BAAW,CAAC;KACvB,CAAC;IAOG,WAAA,IAAA,eAAM,EAAC,2BAAU,CAAC,CAAA;IAElB,WAAA,IAAA,eAAM,EAAC,6CAAoB,CAAC,CAAA;qCAHC,sBAAe;GALpC,UAAU,CAoCtB"}
@@ -1,63 +1,5 @@
1
- import { EntityManager } from "@mikro-orm/core";
2
- import { HashService } from "@nest-boot/hash";
3
- import { PersonalAccessToken, User } from "./entities";
4
- import { AuthModuleOptions } from "./interfaces";
5
- /**
6
- * Service responsible for handling authentication-related operations.
7
- */
1
+ import { Auth } from "better-auth";
8
2
  export declare class AuthService {
9
- private readonly em;
10
- private readonly hashService;
11
- private readonly options;
12
- private readonly User;
13
- private readonly PersonalAccessToken;
14
- private readonly expiresIn?;
15
- /**
16
- * Constructs a new instance of the AuthService class.
17
- * @param em The EntityManager instance.
18
- * @param hashService The HashService instance.
19
- * @param options The options for the Auth module.
20
- */
21
- constructor(em: EntityManager, hashService: HashService, options: AuthModuleOptions);
22
- /**
23
- * Attempts to authenticate a user with the provided email and password.
24
- * @param email The user's email.
25
- * @param password The user's password.
26
- * @returns The authenticated user if successful, otherwise null.
27
- */
28
- attempt(email: string, password: string): Promise<import("@mikro-orm/core").Loaded<User, never, "*", never> | null>;
29
- /**
30
- * Retrieves a personal access token by its token value.
31
- * @param token The token value.
32
- * @returns The personal access token if found, otherwise null.
33
- */
34
- getToken(token: string): Promise<PersonalAccessToken | null>;
35
- /**
36
- * Creates a new personal access token for a user.
37
- * @param user The user for whom the token is created.
38
- * @param name The name of the token.
39
- * @param permissions The permissions associated with the token.
40
- * @param expiresIn The expiration time for the token.
41
- * @returns An object containing the token and the personal access token entity.
42
- */
43
- createToken(user: User, name: string, permissions?: string[], expiresIn?: number): Promise<{
44
- token: string;
45
- personalAccessToken: PersonalAccessToken;
46
- }>;
47
- /**
48
- * Deletes a personal access token.
49
- * @param personalAccessToken - The personal access token to be deleted.
50
- * @returns A Promise that resolves when the token is successfully deleted.
51
- */
52
- deleteToken(personalAccessToken: PersonalAccessToken): Promise<void>;
53
- /**
54
- * Registers a new user.
55
- * @param name The user's name.
56
- * @param email The user's email.
57
- * @param password The user's password.
58
- * @param permissions The permissions associated with the user.
59
- * @returns The registered user.
60
- */
61
- register(name: string, email: string, password: string, permissions?: string[]): Promise<User>;
62
- updateLastUsedAt(personalAccessToken: PersonalAccessToken): Promise<void>;
3
+ readonly auth: Auth;
4
+ constructor(auth: Auth);
63
5
  }
@@ -13,120 +13,16 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.AuthService = void 0;
16
- const core_1 = require("@mikro-orm/core");
17
- const hash_1 = require("@nest-boot/hash");
18
16
  const common_1 = require("@nestjs/common");
19
- const auth_module_definition_1 = require("./auth.module-definition");
20
- const entities_1 = require("./entities");
21
- const random_string_util_1 = require("./utils/random-string.util");
22
- /**
23
- * Service responsible for handling authentication-related operations.
24
- */
17
+ const auth_constants_1 = require("./auth.constants");
25
18
  let AuthService = class AuthService {
26
- /**
27
- * Constructs a new instance of the AuthService class.
28
- * @param em The EntityManager instance.
29
- * @param hashService The HashService instance.
30
- * @param options The options for the Auth module.
31
- */
32
- constructor(em, hashService, options) {
33
- this.em = em;
34
- this.hashService = hashService;
35
- this.options = options;
36
- this.User = this.options?.entities?.User ?? entities_1.User;
37
- this.PersonalAccessToken =
38
- this.options?.entities?.PersonalAccessToken ?? entities_1.PersonalAccessToken;
39
- this.expiresIn = this.options?.expiresIn;
40
- }
41
- /**
42
- * Attempts to authenticate a user with the provided email and password.
43
- * @param email The user's email.
44
- * @param password The user's password.
45
- * @returns The authenticated user if successful, otherwise null.
46
- */
47
- async attempt(email, password) {
48
- const user = await this.em.findOne(this.User, { email }, { filters: false });
49
- if (
50
- // eslint-disable-next-line @typescript-eslint/prefer-optional-chain
51
- user === null ||
52
- user.password === null ||
53
- !(await this.hashService.verify(user.password, password))) {
54
- return null;
55
- }
56
- return user;
57
- }
58
- /**
59
- * Retrieves a personal access token by its token value.
60
- * @param token The token value.
61
- * @returns The personal access token if found, otherwise null.
62
- */
63
- async getToken(token) {
64
- return await this.em.findOne(this.PersonalAccessToken, {
65
- token,
66
- }, { populate: ["user"] });
67
- }
68
- /**
69
- * Creates a new personal access token for a user.
70
- * @param user The user for whom the token is created.
71
- * @param name The name of the token.
72
- * @param permissions The permissions associated with the token.
73
- * @param expiresIn The expiration time for the token.
74
- * @returns An object containing the token and the personal access token entity.
75
- */
76
- async createToken(user, name, permissions = ["*"], expiresIn) {
77
- const token = (0, random_string_util_1.randomString)(48);
78
- expiresIn = expiresIn ?? this.expiresIn;
79
- const personalAccessToken = this.em.create(this.PersonalAccessToken, {
80
- user,
81
- name,
82
- token,
83
- permissions,
84
- expiresAt: typeof expiresIn !== "undefined"
85
- ? new Date(Date.now() + expiresIn)
86
- : null,
87
- });
88
- await this.em.persistAndFlush(personalAccessToken);
89
- return { token, personalAccessToken };
90
- }
91
- /**
92
- * Deletes a personal access token.
93
- * @param personalAccessToken - The personal access token to be deleted.
94
- * @returns A Promise that resolves when the token is successfully deleted.
95
- */
96
- async deleteToken(personalAccessToken) {
97
- await this.em.remove(personalAccessToken).flush();
98
- }
99
- /**
100
- * Registers a new user.
101
- * @param name The user's name.
102
- * @param email The user's email.
103
- * @param password The user's password.
104
- * @param permissions The permissions associated with the user.
105
- * @returns The registered user.
106
- */
107
- async register(name, email, password, permissions = []) {
108
- const hashedPassword = await this.hashService.create(password);
109
- const user = this.em.create(this.User, {
110
- name,
111
- email,
112
- password: hashedPassword,
113
- permissions,
114
- createdAt: new Date(),
115
- updatedAt: new Date(),
116
- });
117
- await this.em.persistAndFlush(user);
118
- return user;
119
- }
120
- async updateLastUsedAt(personalAccessToken) {
121
- personalAccessToken.lastUsedAt = new Date();
122
- await this.em.flush();
19
+ constructor(auth) {
20
+ this.auth = auth;
123
21
  }
124
22
  };
125
23
  exports.AuthService = AuthService;
126
24
  exports.AuthService = AuthService = __decorate([
127
- (0, common_1.Injectable)(),
128
- __param(2, (0, common_1.Inject)(auth_module_definition_1.MODULE_OPTIONS_TOKEN)),
129
- __metadata("design:paramtypes", [core_1.EntityManager,
130
- hash_1.HashService, Object])
25
+ __param(0, (0, common_1.Inject)(auth_constants_1.AUTH_TOKEN)),
26
+ __metadata("design:paramtypes", [Object])
131
27
  ], AuthService);
132
28
  //# sourceMappingURL=auth.service.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth.service.js","sourceRoot":"","sources":["../src/auth.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,0CAA6D;AAC7D,0CAA8C;AAC9C,2CAAoD;AAEpD,qEAAgE;AAChE,yCAAuD;AAEvD,mEAA0D;AAE1D;;GAEG;AAEI,IAAM,WAAW,GAAjB,MAAM,WAAW;IAMtB;;;;;OAKG;IACH,YACmB,EAAiB,EACjB,WAAwB,EAExB,OAA0B;QAH1B,OAAE,GAAF,EAAE,CAAe;QACjB,gBAAW,GAAX,WAAW,CAAa;QAExB,YAAO,GAAP,OAAO,CAAmB;QAE3C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,IAAI,eAAI,CAAC;QACjD,IAAI,CAAC,mBAAmB;YACtB,IAAI,CAAC,OAAO,EAAE,QAAQ,EAAE,mBAAmB,IAAI,8BAAmB,CAAC;QAErE,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC;IAC3C,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,OAAO,CAAC,KAAa,EAAE,QAAgB;QAC3C,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,OAAO,CAChC,IAAI,CAAC,IAAI,EACT,EAAE,KAAK,EAAE,EACT,EAAE,OAAO,EAAE,KAAK,EAAE,CACnB,CAAC;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vB"}
@@ -0,0 +1,11 @@
1
+ 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";
2
+ type ValidChar = LowercaseLetter | "_";
3
+ type IsValidSnakeCase<S extends string> = S extends `${infer First}${infer Rest}` ? First extends ValidChar ? IsValidSnakeCase<Rest> : false : true;
4
+ type SnakeCase<S extends string> = S extends "" ? never : S extends `_${string}` | `${string}_` ? never : S extends `${string}__${string}` ? never : IsValidSnakeCase<S> extends true ? S : never;
5
+ export declare class AuthTransactionContext {
6
+ private readonly ctx;
7
+ set<S extends string>(key: SnakeCase<S>, value: string): this;
8
+ entries(): [string, string][];
9
+ toSQL(): string;
10
+ }
11
+ export {};
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AuthTransactionContext = void 0;
4
+ class AuthTransactionContext {
5
+ constructor() {
6
+ this.ctx = new Map();
7
+ }
8
+ set(key, value) {
9
+ if (!/^[a-z]+(_[a-z]+)*$/.test(key)) {
10
+ throw new Error(`Key must only contain lowercase letters and underscores, cannot start/end with underscore, and cannot have consecutive underscores: ${key}`);
11
+ }
12
+ this.ctx.set(key, value);
13
+ return this;
14
+ }
15
+ entries() {
16
+ return Array.from(this.ctx.entries());
17
+ }
18
+ toSQL() {
19
+ return /* SQL */ `SELECT ${Array.from(this.ctx.entries())
20
+ .map(([key, value]) => {
21
+ const escapedValue = value.replace(/'/g, "''");
22
+ return /* SQL */ `set_config('auth.${key}', '${escapedValue}', true)`;
23
+ })
24
+ .join(",")};`;
25
+ }
26
+ }
27
+ exports.AuthTransactionContext = AuthTransactionContext;
28
+ //# sourceMappingURL=auth.transaction-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.transaction-context.js","sourceRoot":"","sources":["../src/auth.transaction-context.ts"],"names":[],"mappings":";;;AA+CA,MAAa,sBAAsB;IAAnC;QACmB,QAAG,GAAG,IAAI,GAAG,EAAkB,CAAC;IAwBnD,CAAC;IAtBC,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;IAED,OAAO;QACL,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;IACxC,CAAC;IAED,KAAK;QACH,OAAO,SAAS,CAAC,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,OAAO,SAAS,CAAC,oBAAoB,GAAG,OAAO,YAAY,UAAU,CAAC;QACxE,CAAC,CAAC;aACD,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IAClB,CAAC;CACF;AAzBD,wDAyBC"}
@@ -0,0 +1 @@
1
+ export declare const CurrentSession: (...dataOrPipes: unknown[]) => ParameterDecorator;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CurrentSession = void 0;
4
+ const common_1 = require("@nestjs/common");
5
+ exports.CurrentSession = (0, common_1.createParamDecorator)((data, context) => {
6
+ let res;
7
+ if (context.getType() === "graphql") {
8
+ res = context.getArgByIndex(2).req.res;
9
+ }
10
+ else {
11
+ res = context.switchToHttp().getResponse();
12
+ }
13
+ return res.locals.session;
14
+ });
15
+ //# sourceMappingURL=current-session.decorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"current-session.decorator.js","sourceRoot":"","sources":["../../src/decorators/current-session.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAAwE;AAG3D,QAAA,cAAc,GAAG,IAAA,6BAAoB,EAChD,CAAC,IAAa,EAAE,OAAyB,EAAE,EAAE;IAC3C,IAAI,GAAa,CAAC;IAElB,IAAI,OAAO,CAAC,OAAO,EAAa,KAAK,SAAS,EAAE,CAAC;QAC/C,GAAG,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IACzC,CAAC;SAAM,CAAC;QACN,GAAG,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,WAAW,EAAE,CAAC;IAC7C,CAAC;IAED,OAAO,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC;AAC5B,CAAC,CACF,CAAC"}
@@ -1 +1 @@
1
- export declare const CurrentUser: (...dataOrPipes: any[]) => ParameterDecorator;
1
+ export declare const CurrentUser: (...dataOrPipes: unknown[]) => ParameterDecorator;
@@ -1,10 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CurrentUser = void 0;
4
- const request_context_1 = require("@nest-boot/request-context");
5
4
  const common_1 = require("@nestjs/common");
6
- const auth_constants_1 = require("../auth.constants");
7
- exports.CurrentUser = (0, common_1.createParamDecorator)(() => {
8
- return request_context_1.RequestContext.get(auth_constants_1.AUTH_USER);
5
+ exports.CurrentUser = (0, common_1.createParamDecorator)((data, context) => {
6
+ let res;
7
+ if (context.getType() === "graphql") {
8
+ res = context.getArgByIndex(2).req.res;
9
+ }
10
+ else {
11
+ res = context.switchToHttp().getResponse();
12
+ }
13
+ return res.locals.user;
9
14
  });
10
15
  //# 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,gEAA4D;AAC5D,2CAAsD;AAEtD,sDAA8C;AAEjC,QAAA,WAAW,GAAG,IAAA,6BAAoB,EAAC,GAAG,EAAE;IACnD,OAAO,gCAAc,CAAC,GAAG,CAAC,0BAAS,CAAC,CAAC;AACvC,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"current-user.decorator.js","sourceRoot":"","sources":["../../src/decorators/current-user.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAAwE;AAG3D,QAAA,WAAW,GAAG,IAAA,6BAAoB,EAC7C,CAAC,IAAa,EAAE,OAAyB,EAAE,EAAE;IAC3C,IAAI,GAAa,CAAC;IAElB,IAAI,OAAO,CAAC,OAAO,EAAa,KAAK,SAAS,EAAE,CAAC;QAC/C,GAAG,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IACzC,CAAC;SAAM,CAAC;QACN,GAAG,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,WAAW,EAAE,CAAC;IAC7C,CAAC;IAED,OAAO,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC;AACzB,CAAC,CACF,CAAC"}
@@ -1,4 +1,3 @@
1
- export * from "./can.decorator";
2
- export * from "./current-personal-access-token.decorator";
1
+ export * from "./current-session.decorator";
3
2
  export * from "./current-user.decorator";
4
- export * from "./require-auth.decorator";
3
+ export * from "./public.decorator";
@@ -14,8 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./can.decorator"), exports);
18
- __exportStar(require("./current-personal-access-token.decorator"), exports);
17
+ __exportStar(require("./current-session.decorator"), exports);
19
18
  __exportStar(require("./current-user.decorator"), exports);
20
- __exportStar(require("./require-auth.decorator"), exports);
19
+ __exportStar(require("./public.decorator"), exports);
21
20
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC;AAChC,4EAA0D;AAC1D,2DAAyC;AACzC,2DAAyC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8DAA4C;AAC5C,2DAAyC;AACzC,qDAAmC"}
@@ -0,0 +1,2 @@
1
+ import { IS_PUBLIC_KEY } from "../auth.constants";
2
+ export declare const Public: (value?: boolean) => import("@nestjs/common").CustomDecorator<typeof IS_PUBLIC_KEY>;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Public = void 0;
4
+ const common_1 = require("@nestjs/common");
5
+ const auth_constants_1 = require("../auth.constants");
6
+ const Public = (value = true) => (0, common_1.SetMetadata)(auth_constants_1.IS_PUBLIC_KEY, value);
7
+ exports.Public = Public;
8
+ //# sourceMappingURL=public.decorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"public.decorator.js","sourceRoot":"","sources":["../../src/decorators/public.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAA6C;AAE7C,sDAAkD;AAE3C,MAAM,MAAM,GAAG,CAAC,KAAK,GAAG,IAAI,EAAE,EAAE,CAAC,IAAA,oBAAW,EAAC,8BAAa,EAAE,KAAK,CAAC,CAAC;AAA7D,QAAA,MAAM,UAAuD"}
@@ -0,0 +1,16 @@
1
+ import { BaseEntity, Opt } from "@mikro-orm/core";
2
+ export declare abstract class BaseAccount extends BaseEntity {
3
+ id: Opt<string>;
4
+ accountId: string;
5
+ providerId: string;
6
+ userId: string;
7
+ accessToken?: Opt<string>;
8
+ refreshToken?: Opt<string>;
9
+ idToken?: Opt<string>;
10
+ accessTokenExpiresAt?: Opt<Date>;
11
+ refreshTokenExpiresAt?: Opt<Date>;
12
+ scope?: Opt<string>;
13
+ password?: Opt<string>;
14
+ createdAt: Opt<Date>;
15
+ updatedAt: Opt<Date>;
16
+ }
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.BaseAccount = void 0;
13
+ const core_1 = require("@mikro-orm/core");
14
+ const crypto_1 = require("crypto");
15
+ let BaseAccount = class BaseAccount extends core_1.BaseEntity {
16
+ constructor() {
17
+ super(...arguments);
18
+ this.id = (0, crypto_1.randomUUID)();
19
+ this.createdAt = new Date();
20
+ this.updatedAt = new Date();
21
+ }
22
+ };
23
+ exports.BaseAccount = BaseAccount;
24
+ __decorate([
25
+ (0, core_1.PrimaryKey)({ type: core_1.t.uuid }),
26
+ __metadata("design:type", Object)
27
+ ], BaseAccount.prototype, "id", void 0);
28
+ __decorate([
29
+ (0, core_1.Property)({ type: core_1.t.text }),
30
+ __metadata("design:type", String)
31
+ ], BaseAccount.prototype, "accountId", void 0);
32
+ __decorate([
33
+ (0, core_1.Property)({ type: core_1.t.text }),
34
+ __metadata("design:type", String)
35
+ ], BaseAccount.prototype, "providerId", void 0);
36
+ __decorate([
37
+ (0, core_1.ManyToOne)(() => "User", {
38
+ fieldName: "user_id",
39
+ mapToPk: true,
40
+ cascade: [core_1.Cascade.REMOVE],
41
+ }),
42
+ __metadata("design:type", String)
43
+ ], BaseAccount.prototype, "userId", void 0);
44
+ __decorate([
45
+ (0, core_1.Property)({ type: core_1.t.text, nullable: true }),
46
+ __metadata("design:type", Object)
47
+ ], BaseAccount.prototype, "accessToken", void 0);
48
+ __decorate([
49
+ (0, core_1.Property)({ type: core_1.t.text, nullable: true }),
50
+ __metadata("design:type", Object)
51
+ ], BaseAccount.prototype, "refreshToken", void 0);
52
+ __decorate([
53
+ (0, core_1.Property)({ type: core_1.t.text, nullable: true }),
54
+ __metadata("design:type", Object)
55
+ ], BaseAccount.prototype, "idToken", void 0);
56
+ __decorate([
57
+ (0, core_1.Property)({ type: core_1.t.datetime, nullable: true }),
58
+ __metadata("design:type", Object)
59
+ ], BaseAccount.prototype, "accessTokenExpiresAt", void 0);
60
+ __decorate([
61
+ (0, core_1.Property)({ type: core_1.t.datetime, nullable: true }),
62
+ __metadata("design:type", Object)
63
+ ], BaseAccount.prototype, "refreshTokenExpiresAt", void 0);
64
+ __decorate([
65
+ (0, core_1.Property)({ type: core_1.t.text, nullable: true }),
66
+ __metadata("design:type", Object)
67
+ ], BaseAccount.prototype, "scope", void 0);
68
+ __decorate([
69
+ (0, core_1.Property)({ type: core_1.t.text, nullable: true }),
70
+ __metadata("design:type", Object)
71
+ ], BaseAccount.prototype, "password", void 0);
72
+ __decorate([
73
+ (0, core_1.Property)({ type: core_1.t.datetime, defaultRaw: "now()" }),
74
+ __metadata("design:type", Object)
75
+ ], BaseAccount.prototype, "createdAt", void 0);
76
+ __decorate([
77
+ (0, core_1.Property)({
78
+ type: core_1.t.datetime,
79
+ defaultRaw: "now()",
80
+ onUpdate: () => new Date(),
81
+ }),
82
+ __metadata("design:type", Object)
83
+ ], BaseAccount.prototype, "updatedAt", void 0);
84
+ exports.BaseAccount = BaseAccount = __decorate([
85
+ (0, core_1.Entity)({ abstract: true })
86
+ ], BaseAccount);
87
+ //# sourceMappingURL=account.entity.js.map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AI,EAAE,CAAC;;yDACd;AAGjC;IADC,IAAA,eAAQ,EAAC,EAAE,IAAI,EAAE,QAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;0DACb;AAGlC;IADC,IAAA,eAAQ,EAAC,EAAE,IAAI,EAAE,QAAC,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;0CACvB;AAGpB;IADC,IAAA,eAAQ,EAAC,EAAE,IAAI,EAAE,QAAC,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;6CACpB;AAGvB;IADC,IAAA,eAAQ,EAAC,EAAE,IAAI,EAAE,QAAC,CAAC,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC;;8CAClB;AAOlC;IALC,IAAA,eAAQ,EAAC;QACR,IAAI,EAAE,QAAC,CAAC,QAAQ;QAChB,UAAU,EAAE,OAAO;QACnB,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE;KAC3B,CAAC;;8CACgC;sBA9Cd,WAAW;IADhC,IAAA,aAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;GACL,WAAW,CA+ChC"}
@@ -1,2 +1,4 @@
1
- export * from "./personal-access-token.entity";
1
+ export * from "./account.entity";
2
+ export * from "./session.entity";
2
3
  export * from "./user.entity";
4
+ export * from "./verification.entity";
@@ -14,6 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./personal-access-token.entity"), exports);
17
+ __exportStar(require("./account.entity"), exports);
18
+ __exportStar(require("./session.entity"), exports);
18
19
  __exportStar(require("./user.entity"), exports);
20
+ __exportStar(require("./verification.entity"), exports);
19
21
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/entities/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iEAA+C;AAC/C,gDAA8B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/entities/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC;AACjC,mDAAiC;AACjC,gDAA8B;AAC9B,wDAAsC"}
@@ -0,0 +1,11 @@
1
+ import { BaseEntity, Opt } from "@mikro-orm/core";
2
+ export declare abstract class BaseSession extends BaseEntity {
3
+ id: Opt<string>;
4
+ token: string;
5
+ userId: string;
6
+ expiresAt: Date;
7
+ ipAddress?: Opt<string>;
8
+ userAgent?: Opt<string>;
9
+ createdAt: Opt<Date>;
10
+ updatedAt: Opt<Date>;
11
+ }