@nest-boot/auth 7.13.6 → 8.0.0-beta.1
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 +2 -15
- package/dist/adapters/mikro-orm-adapter.js +13 -18
- package/dist/adapters/mikro-orm-adapter.js.map +1 -1
- package/dist/auth-module-options.interface.d.ts +3 -11
- package/dist/auth-module-options.interface.js +1 -2
- package/dist/auth.constants.d.ts +0 -2
- package/dist/auth.constants.js +2 -7
- package/dist/auth.constants.js.map +1 -1
- package/dist/auth.guard.d.ts +0 -20
- package/dist/auth.guard.js +12 -34
- package/dist/auth.guard.js.map +1 -1
- package/dist/auth.middleware.d.ts +4 -25
- package/dist/auth.middleware.js +19 -40
- package/dist/auth.middleware.js.map +1 -1
- package/dist/auth.module-definition.d.ts +1 -1
- package/dist/auth.module-definition.js +3 -7
- package/dist/auth.module-definition.js.map +1 -1
- package/dist/auth.module.d.ts +3 -27
- package/dist/auth.module.js +48 -71
- package/dist/auth.module.js.map +1 -1
- package/dist/auth.service.d.ts +200 -207
- package/dist/auth.service.js +6 -14
- package/dist/auth.service.js.map +1 -1
- package/dist/auth.transaction-context.d.ts +0 -20
- package/dist/auth.transaction-context.js +4 -26
- 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 +4 -8
- 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 +4 -8
- package/dist/decorators/current-user.decorator.js.map +1 -1
- package/dist/decorators/index.d.ts +3 -3
- package/dist/decorators/index.js +3 -19
- package/dist/decorators/index.js.map +1 -1
- package/dist/decorators/public.decorator.d.ts +1 -2
- package/dist/decorators/public.decorator.js +3 -8
- package/dist/decorators/public.decorator.js.map +1 -1
- package/dist/entities/account.entity.d.ts +1 -21
- package/dist/entities/account.entity.js +36 -40
- package/dist/entities/account.entity.js.map +1 -1
- package/dist/entities/index.d.ts +4 -4
- package/dist/entities/index.js +4 -20
- package/dist/entities/index.js.map +1 -1
- package/dist/entities/session.entity.d.ts +1 -16
- package/dist/entities/session.entity.js +27 -36
- package/dist/entities/session.entity.js.map +1 -1
- package/dist/entities/user.entity.d.ts +1 -15
- package/dist/entities/user.entity.js +23 -34
- package/dist/entities/user.entity.js.map +1 -1
- package/dist/entities/verification.entity.d.ts +1 -14
- package/dist/entities/verification.entity.js +20 -32
- package/dist/entities/verification.entity.js.map +1 -1
- package/dist/index.d.ts +9 -9
- package/dist/index.js +9 -25
- package/dist/index.js.map +1 -1
- package/dist/utils/assert-no-duplicate-generic-oauth-plugin.js +1 -4
- package/dist/utils/assert-no-duplicate-generic-oauth-plugin.js.map +1 -1
- package/dist/utils/create-email-and-password-config.d.ts +1 -1
- package/dist/utils/create-email-and-password-config.js +3 -6
- package/dist/utils/create-email-and-password-config.js.map +1 -1
- package/dist/utils/create-oidc-config.d.ts +1 -1
- package/dist/utils/create-oidc-config.js +12 -15
- package/dist/utils/create-oidc-config.js.map +1 -1
- package/dist/utils/create-social-provider-config.d.ts +2 -2
- package/dist/utils/create-social-provider-config.js +13 -16
- package/dist/utils/create-social-provider-config.js.map +1 -1
- package/dist/utils/create-social-providers-config.d.ts +1 -1
- package/dist/utils/create-social-providers-config.js +4 -7
- package/dist/utils/create-social-providers-config.js.map +1 -1
- package/dist/utils/estimate-entropy.d.ts +0 -7
- package/dist/utils/estimate-entropy.js +1 -11
- package/dist/utils/estimate-entropy.js.map +1 -1
- package/dist/utils/generic-oauth-provider-config.type.js +1 -2
- package/dist/utils/has-oidc-env-config.js +3 -6
- package/dist/utils/has-oidc-env-config.js.map +1 -1
- package/dist/utils/has-social-provider-credential-env-config.d.ts +1 -1
- package/dist/utils/has-social-provider-credential-env-config.js +3 -6
- package/dist/utils/has-social-provider-credential-env-config.js.map +1 -1
- package/dist/utils/has-social-provider-env-config.d.ts +1 -1
- package/dist/utils/has-social-provider-env-config.js +3 -6
- package/dist/utils/has-social-provider-env-config.js.map +1 -1
- package/dist/utils/is-env-true.js +1 -4
- package/dist/utils/is-env-true.js.map +1 -1
- package/dist/utils/oidc.constants.d.ts +1 -1
- package/dist/utils/oidc.constants.js +3 -6
- package/dist/utils/oidc.constants.js.map +1 -1
- package/dist/utils/resolve-oidc-prompt.d.ts +1 -1
- package/dist/utils/resolve-oidc-prompt.js +4 -7
- package/dist/utils/resolve-oidc-prompt.js.map +1 -1
- package/dist/utils/resolve-oidc-scopes.js +1 -4
- package/dist/utils/resolve-oidc-scopes.js.map +1 -1
- package/dist/utils/resolve-required-oidc-env.d.ts +1 -1
- package/dist/utils/resolve-required-oidc-env.js +1 -4
- package/dist/utils/resolve-required-oidc-env.js.map +1 -1
- package/dist/utils/resolve-required-social-provider-env.d.ts +1 -1
- package/dist/utils/resolve-required-social-provider-env.js +3 -6
- package/dist/utils/resolve-required-social-provider-env.js.map +1 -1
- package/dist/utils/resolve-secret.d.ts +1 -1
- package/dist/utils/resolve-secret.js +6 -9
- package/dist/utils/resolve-secret.js.map +1 -1
- package/dist/utils/resolve-social-provider-enabled.d.ts +1 -1
- package/dist/utils/resolve-social-provider-enabled.js +3 -6
- package/dist/utils/resolve-social-provider-enabled.js.map +1 -1
- package/dist/utils/social-provider.constants.js +1 -4
- package/dist/utils/social-provider.constants.js.map +1 -1
- package/package.json +40 -27
- package/dist/adapters/mikro-orm-adapter.spec.d.ts +0 -8
- package/dist/adapters/mikro-orm-adapter.spec.js +0 -417
- package/dist/adapters/mikro-orm-adapter.spec.js.map +0 -1
- package/dist/auth.guard.spec.d.ts +0 -1
- package/dist/auth.guard.spec.js +0 -87
- package/dist/auth.guard.spec.js.map +0 -1
- package/dist/auth.middleware.spec.d.ts +0 -1
- package/dist/auth.middleware.spec.js +0 -139
- package/dist/auth.middleware.spec.js.map +0 -1
- package/dist/auth.module.spec.d.ts +0 -1
- package/dist/auth.module.spec.js +0 -626
- package/dist/auth.module.spec.js.map +0 -1
- package/dist/auth.service.spec.d.ts +0 -1
- package/dist/auth.service.spec.js +0 -26
- package/dist/auth.service.spec.js.map +0 -1
- package/dist/auth.transaction-context.spec.d.ts +0 -1
- package/dist/auth.transaction-context.spec.js +0 -20
- package/dist/auth.transaction-context.spec.js.map +0 -1
- package/dist/decorators/auth.decorators.spec.d.ts +0 -1
- package/dist/decorators/auth.decorators.spec.js +0 -87
- package/dist/decorators/auth.decorators.spec.js.map +0 -1
- package/dist/entities/entities.spec.d.ts +0 -1
- package/dist/entities/entities.spec.js +0 -80
- package/dist/entities/entities.spec.js.map +0 -1
- package/dist/index.spec.d.ts +0 -1
- package/dist/index.spec.js +0 -73
- package/dist/index.spec.js.map +0 -1
- package/dist/tsconfig.build.tsbuildinfo +0 -1
- package/dist/utils/assert-no-duplicate-generic-oauth-plugin.spec.d.ts +0 -1
- package/dist/utils/assert-no-duplicate-generic-oauth-plugin.spec.js +0 -29
- package/dist/utils/assert-no-duplicate-generic-oauth-plugin.spec.js.map +0 -1
- package/dist/utils/create-email-and-password-config.spec.d.ts +0 -1
- package/dist/utils/create-email-and-password-config.spec.js +0 -81
- package/dist/utils/create-email-and-password-config.spec.js.map +0 -1
- package/dist/utils/create-oidc-config.spec.d.ts +0 -1
- package/dist/utils/create-oidc-config.spec.js +0 -73
- package/dist/utils/create-oidc-config.spec.js.map +0 -1
- package/dist/utils/create-social-provider-config.spec.d.ts +0 -1
- package/dist/utils/create-social-provider-config.spec.js +0 -139
- package/dist/utils/create-social-provider-config.spec.js.map +0 -1
- package/dist/utils/create-social-providers-config.spec.d.ts +0 -1
- package/dist/utils/create-social-providers-config.spec.js +0 -63
- package/dist/utils/create-social-providers-config.spec.js.map +0 -1
- package/dist/utils/estimate-entropy.spec.d.ts +0 -1
- package/dist/utils/estimate-entropy.spec.js +0 -13
- package/dist/utils/estimate-entropy.spec.js.map +0 -1
- package/dist/utils/has-oidc-env-config.spec.d.ts +0 -1
- package/dist/utils/has-oidc-env-config.spec.js +0 -23
- package/dist/utils/has-oidc-env-config.spec.js.map +0 -1
- package/dist/utils/has-social-provider-credential-env-config.spec.d.ts +0 -1
- package/dist/utils/has-social-provider-credential-env-config.spec.js +0 -33
- package/dist/utils/has-social-provider-credential-env-config.spec.js.map +0 -1
- package/dist/utils/has-social-provider-env-config.spec.d.ts +0 -1
- package/dist/utils/has-social-provider-env-config.spec.js +0 -34
- package/dist/utils/has-social-provider-env-config.spec.js.map +0 -1
- package/dist/utils/is-env-true.spec.d.ts +0 -1
- package/dist/utils/is-env-true.spec.js +0 -20
- package/dist/utils/is-env-true.spec.js.map +0 -1
- package/dist/utils/resolve-oidc-prompt.spec.d.ts +0 -1
- package/dist/utils/resolve-oidc-prompt.spec.js +0 -28
- package/dist/utils/resolve-oidc-prompt.spec.js.map +0 -1
- package/dist/utils/resolve-oidc-scopes.spec.d.ts +0 -1
- package/dist/utils/resolve-oidc-scopes.spec.js +0 -16
- package/dist/utils/resolve-oidc-scopes.spec.js.map +0 -1
- package/dist/utils/resolve-required-oidc-env.spec.d.ts +0 -1
- package/dist/utils/resolve-required-oidc-env.spec.js +0 -22
- package/dist/utils/resolve-required-oidc-env.spec.js.map +0 -1
- package/dist/utils/resolve-required-social-provider-env.spec.d.ts +0 -1
- package/dist/utils/resolve-required-social-provider-env.spec.js +0 -29
- package/dist/utils/resolve-required-social-provider-env.spec.js.map +0 -1
- package/dist/utils/resolve-secret.spec.d.ts +0 -1
- package/dist/utils/resolve-secret.spec.js +0 -34
- package/dist/utils/resolve-secret.spec.js.map +0 -1
- package/dist/utils/resolve-social-provider-enabled.spec.d.ts +0 -1
- package/dist/utils/resolve-social-provider-enabled.spec.js +0 -20
- package/dist/utils/resolve-social-provider-enabled.spec.js.map +0 -1
package/dist/auth.service.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -11,27 +10,20 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
10
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
11
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
12
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const common_1 = require("@nestjs/common");
|
|
17
|
-
const auth_constants_1 = require("./auth.constants");
|
|
18
|
-
/** Service exposing the better-auth API to the application. */
|
|
13
|
+
import { Inject } from "@nestjs/common";
|
|
14
|
+
import { AUTH_TOKEN } from "./auth.constants.js";
|
|
19
15
|
let AuthService = class AuthService {
|
|
20
|
-
|
|
21
|
-
* Creates a new AuthService instance.
|
|
22
|
-
* @param auth - The better-auth instance
|
|
23
|
-
*/
|
|
16
|
+
auth;
|
|
24
17
|
constructor(auth) {
|
|
25
18
|
this.auth = auth;
|
|
26
19
|
}
|
|
27
|
-
/** The better-auth API interface for session and user management. */
|
|
28
20
|
get api() {
|
|
29
21
|
return this.auth.api;
|
|
30
22
|
}
|
|
31
23
|
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
__param(0, (0, common_1.Inject)(auth_constants_1.AUTH_TOKEN)),
|
|
24
|
+
AuthService = __decorate([
|
|
25
|
+
__param(0, Inject(AUTH_TOKEN)),
|
|
35
26
|
__metadata("design:paramtypes", [Object])
|
|
36
27
|
], AuthService);
|
|
28
|
+
export { AuthService };
|
|
37
29
|
//# sourceMappingURL=auth.service.js.map
|
package/dist/auth.service.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.service.js","sourceRoot":"","sources":["../src/auth.service.ts"],"names":[],"mappings":"
|
|
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,24 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.AuthTransactionContext = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Stores key-value pairs for PostgreSQL transaction-level auth context.
|
|
6
|
-
*
|
|
7
|
-
* @remarks
|
|
8
|
-
* Values set here are emitted as `set_config('auth.<key>', '<value>', true)` SQL
|
|
9
|
-
* statements, enabling row-level security policies to access auth state.
|
|
10
|
-
*/
|
|
11
|
-
class AuthTransactionContext {
|
|
12
|
-
constructor() {
|
|
13
|
-
/** Internal storage for transaction context key-value pairs. @internal */
|
|
14
|
-
this.ctx = new Map();
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Sets a snake_case key-value pair in the transaction context.
|
|
18
|
-
* @param key - Must be a valid snake_case string
|
|
19
|
-
* @param value - The string value to associate with the key
|
|
20
|
-
* @returns This instance for chaining
|
|
21
|
-
*/
|
|
1
|
+
export class AuthTransactionContext {
|
|
2
|
+
ctx = new Map();
|
|
22
3
|
set(key, value) {
|
|
23
4
|
if (!/^[a-z]+(_[a-z]+)*$/.test(key)) {
|
|
24
5
|
throw new Error(`Key must only contain lowercase letters and underscores, cannot start/end with underscore, and cannot have consecutive underscores: ${key}`);
|
|
@@ -26,19 +7,16 @@ class AuthTransactionContext {
|
|
|
26
7
|
this.ctx.set(key, value);
|
|
27
8
|
return this;
|
|
28
9
|
}
|
|
29
|
-
/** Returns all stored key-value pairs as an array of `[key, value]` tuples. */
|
|
30
10
|
entries() {
|
|
31
11
|
return Array.from(this.ctx.entries());
|
|
32
12
|
}
|
|
33
|
-
/** Generates a SQL statement that sets all stored values as PostgreSQL transaction-local config variables. */
|
|
34
13
|
toSQL() {
|
|
35
|
-
return
|
|
14
|
+
return `SELECT ${Array.from(this.ctx.entries())
|
|
36
15
|
.map(([key, value]) => {
|
|
37
16
|
const escapedValue = value.replace(/'/g, "''");
|
|
38
|
-
return
|
|
17
|
+
return `set_config('auth.${key}', '${escapedValue}', true)`;
|
|
39
18
|
})
|
|
40
19
|
.join(",")};`;
|
|
41
20
|
}
|
|
42
21
|
}
|
|
43
|
-
exports.AuthTransactionContext = AuthTransactionContext;
|
|
44
22
|
//# sourceMappingURL=auth.transaction-context.js.map
|
|
@@ -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,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const common_1 = require("@nestjs/common");
|
|
6
|
-
const session_entity_1 = require("../entities/session.entity");
|
|
7
|
-
/** Parameter decorator that injects the current {@link BaseSession} from the request context. */
|
|
8
|
-
exports.CurrentSession = (0, common_1.createParamDecorator)(() => request_context_1.RequestContext.get(session_entity_1.BaseSession));
|
|
1
|
+
import { RequestContext } from "@nest-boot/request-context";
|
|
2
|
+
import { createParamDecorator } from "@nestjs/common";
|
|
3
|
+
import { BaseSession } from "../entities/session.entity.js";
|
|
4
|
+
export const CurrentSession = createParamDecorator(() => RequestContext.get(BaseSession));
|
|
9
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":"
|
|
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,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const common_1 = require("@nestjs/common");
|
|
6
|
-
const user_entity_1 = require("../entities/user.entity");
|
|
7
|
-
/** Parameter decorator that injects the current {@link BaseUser} from the request context. */
|
|
8
|
-
exports.CurrentUser = (0, common_1.createParamDecorator)(() => request_context_1.RequestContext.get(user_entity_1.BaseUser));
|
|
1
|
+
import { RequestContext } from "@nest-boot/request-context";
|
|
2
|
+
import { createParamDecorator } from "@nestjs/common";
|
|
3
|
+
import { BaseUser } from "../entities/user.entity.js";
|
|
4
|
+
export const CurrentUser = createParamDecorator(() => RequestContext.get(BaseUser));
|
|
9
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":"
|
|
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,3 +1,3 @@
|
|
|
1
|
-
export * from "./current-session.decorator";
|
|
2
|
-
export * from "./current-user.decorator";
|
|
3
|
-
export * from "./public.decorator";
|
|
1
|
+
export * from "./current-session.decorator.js";
|
|
2
|
+
export * from "./current-user.decorator.js";
|
|
3
|
+
export * from "./public.decorator.js";
|
package/dist/decorators/index.js
CHANGED
|
@@ -1,20 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./current-session.decorator"), exports);
|
|
18
|
-
__exportStar(require("./current-user.decorator"), exports);
|
|
19
|
-
__exportStar(require("./public.decorator"), exports);
|
|
1
|
+
export * from "./current-session.decorator.js";
|
|
2
|
+
export * from "./current-user.decorator.js";
|
|
3
|
+
export * from "./public.decorator.js";
|
|
20
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAC;AAC/C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC"}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { IS_PUBLIC_KEY } from "../auth.constants";
|
|
2
|
-
/** Decorator that marks a route as public, bypassing the {@link AuthGuard}. */
|
|
1
|
+
import { IS_PUBLIC_KEY } from "../auth.constants.js";
|
|
3
2
|
export declare const Public: (value?: boolean) => import("@nestjs/common").CustomDecorator<typeof IS_PUBLIC_KEY>;
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const common_1 = require("@nestjs/common");
|
|
5
|
-
const auth_constants_1 = require("../auth.constants");
|
|
6
|
-
/** Decorator that marks a route as public, bypassing the {@link AuthGuard}. */
|
|
7
|
-
const Public = (value = true) => (0, common_1.SetMetadata)(auth_constants_1.IS_PUBLIC_KEY, value);
|
|
8
|
-
exports.Public = Public;
|
|
1
|
+
import { SetMetadata } from "@nestjs/common";
|
|
2
|
+
import { IS_PUBLIC_KEY } from "../auth.constants.js";
|
|
3
|
+
export const Public = (value = true) => SetMetadata(IS_PUBLIC_KEY, value);
|
|
9
4
|
//# sourceMappingURL=public.decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public.decorator.js","sourceRoot":"","sources":["../../src/decorators/public.decorator.ts"],"names":[],"mappings":"
|
|
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
|
-
import { BaseEntity, 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
|
-
*/
|
|
1
|
+
import { BaseEntity, type Opt } from "@mikro-orm/core";
|
|
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
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -8,90 +7,87 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
this.createdAt = new Date();
|
|
29
|
-
/** Timestamp of the last update. */
|
|
30
|
-
this.updatedAt = new Date();
|
|
31
|
-
}
|
|
10
|
+
import { BaseEntity, Cascade, t } from "@mikro-orm/core";
|
|
11
|
+
import { Entity, ManyToOne, PrimaryKey, Property, } from "@mikro-orm/decorators/legacy";
|
|
12
|
+
import { randomUUID } from "crypto";
|
|
13
|
+
let BaseAccount = class BaseAccount extends BaseEntity {
|
|
14
|
+
id = randomUUID();
|
|
15
|
+
accountId;
|
|
16
|
+
providerId;
|
|
17
|
+
userId;
|
|
18
|
+
accessToken;
|
|
19
|
+
refreshToken;
|
|
20
|
+
idToken;
|
|
21
|
+
accessTokenExpiresAt;
|
|
22
|
+
refreshTokenExpiresAt;
|
|
23
|
+
scope;
|
|
24
|
+
password;
|
|
25
|
+
createdAt = new Date();
|
|
26
|
+
updatedAt = new Date();
|
|
32
27
|
};
|
|
33
|
-
exports.BaseAccount = BaseAccount;
|
|
34
28
|
__decorate([
|
|
35
|
-
|
|
29
|
+
PrimaryKey({ type: t.uuid }),
|
|
36
30
|
__metadata("design:type", Object)
|
|
37
31
|
], BaseAccount.prototype, "id", void 0);
|
|
38
32
|
__decorate([
|
|
39
|
-
|
|
33
|
+
Property({ type: t.text }),
|
|
40
34
|
__metadata("design:type", String)
|
|
41
35
|
], BaseAccount.prototype, "accountId", void 0);
|
|
42
36
|
__decorate([
|
|
43
|
-
|
|
37
|
+
Property({ type: t.text }),
|
|
44
38
|
__metadata("design:type", String)
|
|
45
39
|
], BaseAccount.prototype, "providerId", void 0);
|
|
46
40
|
__decorate([
|
|
47
|
-
|
|
41
|
+
ManyToOne({
|
|
42
|
+
entity: () => "User",
|
|
48
43
|
fieldName: "user_id",
|
|
49
44
|
mapToPk: true,
|
|
50
|
-
cascade: [
|
|
45
|
+
cascade: [Cascade.REMOVE],
|
|
51
46
|
}),
|
|
52
47
|
__metadata("design:type", String)
|
|
53
48
|
], BaseAccount.prototype, "userId", void 0);
|
|
54
49
|
__decorate([
|
|
55
|
-
|
|
50
|
+
Property({ type: t.text, nullable: true }),
|
|
56
51
|
__metadata("design:type", Object)
|
|
57
52
|
], BaseAccount.prototype, "accessToken", void 0);
|
|
58
53
|
__decorate([
|
|
59
|
-
|
|
54
|
+
Property({ type: t.text, nullable: true }),
|
|
60
55
|
__metadata("design:type", Object)
|
|
61
56
|
], BaseAccount.prototype, "refreshToken", void 0);
|
|
62
57
|
__decorate([
|
|
63
|
-
|
|
58
|
+
Property({ type: t.text, nullable: true }),
|
|
64
59
|
__metadata("design:type", Object)
|
|
65
60
|
], BaseAccount.prototype, "idToken", void 0);
|
|
66
61
|
__decorate([
|
|
67
|
-
|
|
62
|
+
Property({ type: t.datetime, nullable: true }),
|
|
68
63
|
__metadata("design:type", Object)
|
|
69
64
|
], BaseAccount.prototype, "accessTokenExpiresAt", void 0);
|
|
70
65
|
__decorate([
|
|
71
|
-
|
|
66
|
+
Property({ type: t.datetime, nullable: true }),
|
|
72
67
|
__metadata("design:type", Object)
|
|
73
68
|
], BaseAccount.prototype, "refreshTokenExpiresAt", void 0);
|
|
74
69
|
__decorate([
|
|
75
|
-
|
|
70
|
+
Property({ type: t.text, nullable: true }),
|
|
76
71
|
__metadata("design:type", Object)
|
|
77
72
|
], BaseAccount.prototype, "scope", void 0);
|
|
78
73
|
__decorate([
|
|
79
|
-
|
|
74
|
+
Property({ type: t.text, nullable: true }),
|
|
80
75
|
__metadata("design:type", Object)
|
|
81
76
|
], BaseAccount.prototype, "password", void 0);
|
|
82
77
|
__decorate([
|
|
83
|
-
|
|
78
|
+
Property({ type: t.datetime, defaultRaw: "now()" }),
|
|
84
79
|
__metadata("design:type", Object)
|
|
85
80
|
], BaseAccount.prototype, "createdAt", void 0);
|
|
86
81
|
__decorate([
|
|
87
|
-
|
|
88
|
-
type:
|
|
82
|
+
Property({
|
|
83
|
+
type: t.datetime,
|
|
89
84
|
defaultRaw: "now()",
|
|
90
85
|
onUpdate: () => new Date(),
|
|
91
86
|
}),
|
|
92
87
|
__metadata("design:type", Object)
|
|
93
88
|
], BaseAccount.prototype, "updatedAt", void 0);
|
|
94
|
-
|
|
95
|
-
|
|
89
|
+
BaseAccount = __decorate([
|
|
90
|
+
Entity({ abstract: true })
|
|
96
91
|
], BaseAccount);
|
|
92
|
+
export { BaseAccount };
|
|
97
93
|
//# sourceMappingURL=account.entity.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.entity.js","sourceRoot":"","sources":["../../src/entities/account.entity.ts"],"names":[],"mappings":"
|
|
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;IAI1B,YAAY,CAAe;IAI3B,OAAO,CAAe;IAItB,oBAAoB,CAAa;IAIjC,qBAAqB,CAAa;IAIlC,KAAK,CAAe;IAIpB,QAAQ,CAAe;IAIvB,SAAS,GAAc,IAAI,IAAI,EAAE,CAAC;IAQlC,SAAS,GAAc,IAAI,IAAI,EAAE,CAAC;CACnC,CAAA;AA1DC;IADC,UAAU,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;;uCACE;AAI/B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;;8CACR;AAInB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;;+CACP;AASpB;IANC,SAAS,CAAC;QACT,MAAM,EAAE,GAAG,EAAE,CAAC,MAAa;QAC3B,SAAS,EAAE,SAAS;QACpB,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC;KAC1B,CAAC;;2CACc;AAIhB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;gDACjB;AAI1B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;iDAChB;AAI3B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;4CACrB;AAItB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;yDACd;AAIjC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;0DACb;AAIlC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,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"}
|
package/dist/entities/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from "./account.entity";
|
|
2
|
-
export * from "./session.entity";
|
|
3
|
-
export * from "./user.entity";
|
|
4
|
-
export * from "./verification.entity";
|
|
1
|
+
export * from "./account.entity.js";
|
|
2
|
+
export * from "./session.entity.js";
|
|
3
|
+
export * from "./user.entity.js";
|
|
4
|
+
export * from "./verification.entity.js";
|
package/dist/entities/index.js
CHANGED
|
@@ -1,21 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./account.entity"), exports);
|
|
18
|
-
__exportStar(require("./session.entity"), exports);
|
|
19
|
-
__exportStar(require("./user.entity"), exports);
|
|
20
|
-
__exportStar(require("./verification.entity"), exports);
|
|
1
|
+
export * from "./account.entity.js";
|
|
2
|
+
export * from "./session.entity.js";
|
|
3
|
+
export * from "./user.entity.js";
|
|
4
|
+
export * from "./verification.entity.js";
|
|
21
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/entities/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/entities/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC"}
|
|
@@ -1,26 +1,11 @@
|
|
|
1
|
-
import { BaseEntity, 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
|
-
*/
|
|
1
|
+
import { BaseEntity, type Opt } from "@mikro-orm/core";
|
|
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
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -8,71 +7,63 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
constructor() {
|
|
24
|
-
super(...arguments);
|
|
25
|
-
/** Primary key (UUID v4, auto-generated). */
|
|
26
|
-
this.id = (0, crypto_1.randomUUID)();
|
|
27
|
-
/** Timestamp when the session was created. */
|
|
28
|
-
this.createdAt = new Date();
|
|
29
|
-
/** Timestamp of the last update. */
|
|
30
|
-
this.updatedAt = new Date();
|
|
31
|
-
}
|
|
10
|
+
import { BaseEntity, Cascade, t } from "@mikro-orm/core";
|
|
11
|
+
import { Entity, ManyToOne, PrimaryKey, Property, Unique, } from "@mikro-orm/decorators/legacy";
|
|
12
|
+
import { randomUUID } from "crypto";
|
|
13
|
+
let BaseSession = class BaseSession extends BaseEntity {
|
|
14
|
+
id = randomUUID();
|
|
15
|
+
token;
|
|
16
|
+
userId;
|
|
17
|
+
expiresAt;
|
|
18
|
+
ipAddress;
|
|
19
|
+
userAgent;
|
|
20
|
+
createdAt = new Date();
|
|
21
|
+
updatedAt = new Date();
|
|
32
22
|
};
|
|
33
|
-
exports.BaseSession = BaseSession;
|
|
34
23
|
__decorate([
|
|
35
|
-
|
|
24
|
+
PrimaryKey({ type: t.uuid }),
|
|
36
25
|
__metadata("design:type", Object)
|
|
37
26
|
], BaseSession.prototype, "id", void 0);
|
|
38
27
|
__decorate([
|
|
39
|
-
|
|
40
|
-
|
|
28
|
+
Property({ type: t.text }),
|
|
29
|
+
Unique(),
|
|
41
30
|
__metadata("design:type", String)
|
|
42
31
|
], BaseSession.prototype, "token", void 0);
|
|
43
32
|
__decorate([
|
|
44
|
-
|
|
33
|
+
ManyToOne({
|
|
34
|
+
entity: () => "User",
|
|
45
35
|
fieldName: "user_id",
|
|
46
36
|
mapToPk: true,
|
|
47
|
-
cascade: [
|
|
37
|
+
cascade: [Cascade.REMOVE],
|
|
48
38
|
}),
|
|
49
39
|
__metadata("design:type", String)
|
|
50
40
|
], BaseSession.prototype, "userId", void 0);
|
|
51
41
|
__decorate([
|
|
52
|
-
|
|
42
|
+
Property({ type: t.datetime }),
|
|
53
43
|
__metadata("design:type", Date)
|
|
54
44
|
], BaseSession.prototype, "expiresAt", void 0);
|
|
55
45
|
__decorate([
|
|
56
|
-
|
|
46
|
+
Property({ type: t.text, nullable: true }),
|
|
57
47
|
__metadata("design:type", Object)
|
|
58
48
|
], BaseSession.prototype, "ipAddress", void 0);
|
|
59
49
|
__decorate([
|
|
60
|
-
|
|
50
|
+
Property({ type: t.text, nullable: true }),
|
|
61
51
|
__metadata("design:type", Object)
|
|
62
52
|
], BaseSession.prototype, "userAgent", void 0);
|
|
63
53
|
__decorate([
|
|
64
|
-
|
|
54
|
+
Property({ type: t.datetime, defaultRaw: "now()" }),
|
|
65
55
|
__metadata("design:type", Object)
|
|
66
56
|
], BaseSession.prototype, "createdAt", void 0);
|
|
67
57
|
__decorate([
|
|
68
|
-
|
|
69
|
-
type:
|
|
58
|
+
Property({
|
|
59
|
+
type: t.datetime,
|
|
70
60
|
defaultRaw: "now()",
|
|
71
61
|
onUpdate: () => new Date(),
|
|
72
62
|
}),
|
|
73
63
|
__metadata("design:type", Object)
|
|
74
64
|
], BaseSession.prototype, "updatedAt", void 0);
|
|
75
|
-
|
|
76
|
-
|
|
65
|
+
BaseSession = __decorate([
|
|
66
|
+
Entity({ abstract: true })
|
|
77
67
|
], BaseSession);
|
|
68
|
+
export { BaseSession };
|
|
78
69
|
//# sourceMappingURL=session.entity.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.entity.js","sourceRoot":"","sources":["../../src/entities/session.entity.ts"],"names":[],"mappings":"
|
|
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,UAAU,EAAE,MAAM,QAAQ,CAAC;AAU7B,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,UAAU;IAGzC,EAAE,GAAgB,UAAU,EAAE,CAAC;IAK/B,KAAK,CAAU;IASf,MAAM,CAAU;IAIhB,SAAS,CAAQ;IAIjB,SAAS,CAAe;IAIxB,SAAS,CAAe;IAIxB,SAAS,GAAc,IAAI,IAAI,EAAE,CAAC;IAQlC,SAAS,GAAc,IAAI,IAAI,EAAE,CAAC;CACnC,CAAA;AAvCC;IADC,UAAU,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;;uCACE;AAK/B;IAFC,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAC1B,MAAM,EAAE;;0CACM;AASf;IANC,SAAS,CAAC;QACT,MAAM,EAAE,GAAG,EAAE,CAAC,MAAa;QAC3B,SAAS,EAAE,SAAS;QACpB,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC;KAC1B,CAAC;;2CACc;AAIhB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;8BACnB,IAAI;8CAAC;AAIjB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;8CACnB;AAIxB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,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"}
|