@anarchitects/auth-nest 0.0.1 → 0.4.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/README.md +117 -14
- package/package.json +5 -2
- package/src/application/application.module.d.ts +6 -6
- package/src/application/application.module.js +10 -10
- package/src/application/application.module.js.map +1 -1
- package/src/infrastructure-mailer/mailer.module.d.ts +1 -1
- package/src/infrastructure-mailer/mailer.module.js +6 -6
- package/src/infrastructure-mailer/mailer.module.js.map +1 -1
- package/src/infrastructure-persistence/index.d.ts +1 -0
- package/src/infrastructure-persistence/index.js +1 -0
- package/src/infrastructure-persistence/index.js.map +1 -1
- package/src/infrastructure-persistence/migrations/{1720200000000-create-invalidated-tokens-cache.table.d.ts → 1720200000000-create-auth-schema.d.ts} +1 -1
- package/src/infrastructure-persistence/migrations/1720200000000-create-auth-schema.js +312 -0
- package/src/infrastructure-persistence/migrations/1720200000000-create-auth-schema.js.map +1 -0
- package/src/infrastructure-persistence/persistence.module.d.ts +1 -1
- package/src/infrastructure-persistence/persistence.module.js +11 -11
- package/src/infrastructure-persistence/persistence.module.js.map +1 -1
- package/src/presentation/controllers/auth.controller.d.ts +9 -27
- package/src/presentation/controllers/auth.controller.js +18 -30
- package/src/presentation/controllers/auth.controller.js.map +1 -1
- package/src/presentation/presentation.module.d.ts +1 -1
- package/src/presentation/presentation.module.js +5 -5
- package/src/presentation/presentation.module.js.map +1 -1
- package/src/infrastructure-persistence/migrations/1720200000000-create-invalidated-tokens-cache.table.js +0 -29
- package/src/infrastructure-persistence/migrations/1720200000000-create-invalidated-tokens-cache.table.js.map +0 -1
package/README.md
CHANGED
|
@@ -4,10 +4,11 @@ NestJS services, controllers, and infrastructure for the Anarchitecture authenti
|
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
-
- Application layer
|
|
8
|
-
- Presentation
|
|
9
|
-
- Infrastructure persistence
|
|
10
|
-
-
|
|
7
|
+
- **Application layer** – `JwtAuthService`, `BcryptHashService`, JWT Passport strategy, CASL-based `PoliciesService` and `AbilityFactory` encapsulating business rules for tokens, passwords, and fine-grained access control.
|
|
8
|
+
- **Presentation layer** – `AuthController` exposing REST handlers for the full auth lifecycle, `PoliciesGuard` and `@Policies()` decorator for route-level authorization.
|
|
9
|
+
- **Infrastructure persistence** – `PersistenceModule` with TypeORM entities and repositories (users, roles, permissions, invalidated tokens). Configurable adapters to swap implementations while preserving the application contract.
|
|
10
|
+
- **Infrastructure mailer** – `MailerModule` with a `NodeMailerAdapter` wrapping `@nestjs-modules/mailer` for email delivery.
|
|
11
|
+
- **Config** – Typed `authConfig` namespace using `@nestjs/config` with an `InjectAuthConfig()` helper decorator.
|
|
11
12
|
|
|
12
13
|
## Installation
|
|
13
14
|
|
|
@@ -19,8 +20,62 @@ yarn add @anarchitects/auth-nest
|
|
|
19
20
|
|
|
20
21
|
Peer requirements:
|
|
21
22
|
|
|
22
|
-
- `@nestjs/common`, `@nestjs/core`, `@nestjs/jwt`, `@nestjs/typeorm`
|
|
23
|
+
- `@nestjs/common`, `@nestjs/core`, `@nestjs/jwt`, `@nestjs/typeorm`, `@nestjs/config`, `@nestjs/passport`
|
|
23
24
|
- `@anarchitects/auth-ts` for DTOs and shared models
|
|
25
|
+
- `@casl/ability` for RBAC policy evaluation
|
|
26
|
+
- `@nestjs-modules/mailer` (when using the mailer module)
|
|
27
|
+
|
|
28
|
+
## Subpath exports
|
|
29
|
+
|
|
30
|
+
| Import path | Contents |
|
|
31
|
+
| ---------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
32
|
+
| `@anarchitects/auth-nest/application` | `AuthApplicationModule`, `AuthService`, `JwtAuthService`, `HashService`, `BcryptHashService`, `PoliciesService`, `AbilityFactory`, `JwtStrategy` |
|
|
33
|
+
| `@anarchitects/auth-nest/presentation` | `AuthPresentationModule`, `AuthController`, `PoliciesGuard`, `@Policies()` decorator |
|
|
34
|
+
| `@anarchitects/auth-nest/infrastructure-persistence` | `AuthPersistenceModule`, `AuthUserRepository`, `TypeormAuthUserRepository`, migration |
|
|
35
|
+
| `@anarchitects/auth-nest/infrastructure-mailer` | `AuthMailerModule`, `MailerAdapter`, `NodeMailerAdapter` |
|
|
36
|
+
| `@anarchitects/auth-nest/config` | `authConfig`, `AuthConfig` type, `InjectAuthConfig()` |
|
|
37
|
+
|
|
38
|
+
## Configuration
|
|
39
|
+
|
|
40
|
+
The library reads configuration through `@nestjs/config` using a namespaced `authConfig` registered under the key `auth`. Set the following environment variables to customise behaviour:
|
|
41
|
+
|
|
42
|
+
| Variable | Description | Default |
|
|
43
|
+
| --------------------------- | ------------------------------------------------------------------------------------ | ------------------------ |
|
|
44
|
+
| `AUTH_JWT_SECRET` | Secret key used to sign and verify JWTs. **Must** be overridden in production. | `default_jwt_secret` |
|
|
45
|
+
| `AUTH_JWT_EXPIRATION` | Token lifetime (e.g. `3600s`, `15m`, `1d`). | `3600s` |
|
|
46
|
+
| `AUTH_JWT_AUDIENCE` | Expected `aud` claim in the JWT. | `your_audience` |
|
|
47
|
+
| `AUTH_JWT_ISSUER` | Expected `iss` claim in the JWT. | `your_issuer` |
|
|
48
|
+
| `AUTH_ENCRYPTION_ALGORITHM` | Password hashing algorithm (`bcrypt`). | `bcrypt` |
|
|
49
|
+
| `AUTH_ENCRYPTION_KEY` | Symmetric key for additional encryption needs. **Must** be overridden in production. | `default_encryption_key` |
|
|
50
|
+
|
|
51
|
+
> **Security note:** The defaults for `AUTH_JWT_SECRET` and `AUTH_ENCRYPTION_KEY` are intentionally insecure placeholders. Always provide strong, unique values in any deployed environment.
|
|
52
|
+
|
|
53
|
+
### Injecting the config
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
import { InjectAuthConfig, AuthConfig } from '@anarchitects/auth-nest/config';
|
|
57
|
+
|
|
58
|
+
@Injectable()
|
|
59
|
+
export class MyService {
|
|
60
|
+
constructor(@InjectAuthConfig() private readonly config: AuthConfig) {}
|
|
61
|
+
|
|
62
|
+
someMethod() {
|
|
63
|
+
const secret = this.config.jwtSecret;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Make sure to import `authConfig` into your module's `ConfigModule`:
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
import { ConfigModule } from '@nestjs/config';
|
|
72
|
+
import { authConfig } from '@anarchitects/auth-nest/config';
|
|
73
|
+
|
|
74
|
+
@Module({
|
|
75
|
+
imports: [ConfigModule.forRoot({ load: [authConfig] })],
|
|
76
|
+
})
|
|
77
|
+
export class AppModule {}
|
|
78
|
+
```
|
|
24
79
|
|
|
25
80
|
## Usage
|
|
26
81
|
|
|
@@ -28,18 +83,26 @@ Peer requirements:
|
|
|
28
83
|
|
|
29
84
|
```ts
|
|
30
85
|
import { Module } from '@nestjs/common';
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
86
|
+
import { ConfigModule } from '@nestjs/config';
|
|
87
|
+
import { authConfig } from '@anarchitects/auth-nest/config';
|
|
88
|
+
import { AuthApplicationModule } from '@anarchitects/auth-nest/application';
|
|
89
|
+
import { AuthPersistenceModule } from '@anarchitects/auth-nest/infrastructure-persistence';
|
|
90
|
+
import { AuthPresentationModule } from '@anarchitects/auth-nest/presentation';
|
|
91
|
+
import { AuthMailerModule } from '@anarchitects/auth-nest/infrastructure-mailer';
|
|
34
92
|
|
|
35
93
|
@Module({
|
|
36
94
|
imports: [
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
95
|
+
ConfigModule.forRoot({ load: [authConfig] }),
|
|
96
|
+
AuthApplicationModule.register({
|
|
97
|
+
authStrategies: ['jwt'],
|
|
98
|
+
encryption: {
|
|
99
|
+
algorithm: 'bcrypt',
|
|
100
|
+
key: process.env.AUTH_ENCRYPTION_KEY!,
|
|
101
|
+
},
|
|
40
102
|
}),
|
|
41
|
-
|
|
42
|
-
|
|
103
|
+
AuthPersistenceModule.register({ persistence: 'typeorm' }),
|
|
104
|
+
AuthPresentationModule,
|
|
105
|
+
AuthMailerModule,
|
|
43
106
|
],
|
|
44
107
|
})
|
|
45
108
|
export class AuthApiModule {}
|
|
@@ -68,9 +131,47 @@ export class AuthController {
|
|
|
68
131
|
```ts
|
|
69
132
|
import { TypeormAuthUserRepository } from '@anarchitects/auth-nest/infrastructure-persistence';
|
|
70
133
|
|
|
71
|
-
await authUserRepository.invalidateTokens(
|
|
134
|
+
await authUserRepository.invalidateTokens(
|
|
135
|
+
[hashedAccessToken, hashedRefreshToken],
|
|
136
|
+
userId,
|
|
137
|
+
);
|
|
72
138
|
```
|
|
73
139
|
|
|
140
|
+
### Route-level authorization with policies
|
|
141
|
+
|
|
142
|
+
```ts
|
|
143
|
+
import { Controller, Get, UseGuards } from '@nestjs/common';
|
|
144
|
+
import { PoliciesGuard, Policies } from '@anarchitects/auth-nest/presentation';
|
|
145
|
+
|
|
146
|
+
@Controller('admin')
|
|
147
|
+
@UseGuards(PoliciesGuard)
|
|
148
|
+
export class AdminController {
|
|
149
|
+
@Get()
|
|
150
|
+
@Policies({ action: 'manage', subject: 'User' })
|
|
151
|
+
getAdminDashboard() {
|
|
152
|
+
return { status: 'ok' };
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## REST endpoints
|
|
158
|
+
|
|
159
|
+
The `AuthController` exposes the following routes (all prefixed with `/auth`):
|
|
160
|
+
|
|
161
|
+
| Method | Path | Description |
|
|
162
|
+
| ------- | ------------------------------- | -------------------------------------- |
|
|
163
|
+
| `POST` | `/auth/register` | Register a new user |
|
|
164
|
+
| `PATCH` | `/auth/activate` | Activate a user account |
|
|
165
|
+
| `POST` | `/auth/login` | Log in and receive JWT tokens |
|
|
166
|
+
| `POST` | `/auth/logout` | Log out and invalidate tokens |
|
|
167
|
+
| `PATCH` | `/auth/change-password/:userId` | Change password for a user |
|
|
168
|
+
| `POST` | `/auth/forgot-password` | Request a password-reset email |
|
|
169
|
+
| `POST` | `/auth/reset-password` | Reset password with token |
|
|
170
|
+
| `POST` | `/auth/verify-email` | Verify an email address |
|
|
171
|
+
| `PATCH` | `/auth/update-email/:userId` | Update email for a user |
|
|
172
|
+
| `POST` | `/auth/refresh-tokens/:userId` | Refresh access/refresh tokens |
|
|
173
|
+
| `GET` | `/auth/me` | Get logged-in user info and RBAC rules |
|
|
174
|
+
|
|
74
175
|
## Nx scripts
|
|
75
176
|
|
|
76
177
|
- `nx build auth-nest` – bundle the Nest library.
|
|
@@ -82,6 +183,8 @@ await authUserRepository.invalidateTokens([hashedAccessToken, hashedRefreshToken
|
|
|
82
183
|
- DTO shapes live in `@anarchitects/auth-ts`; update the contract and regenerate DTOs before extending this library.
|
|
83
184
|
- Default persistence is TypeORM with schema-qualified tables (see `libs/auth/nest/src/infrastructure-persistence`).
|
|
84
185
|
- Invalidated tokens use an unlogged cache table for quick revocation lookups.
|
|
186
|
+
- Route schemas are defined in `@anarchitects/auth-ts/dtos` and imported into controller `@RouteSchema` decorators — do not define inline schemas.
|
|
187
|
+
- OpenAPI metadata (`operationId`, `tags`) is assigned in `tools/api-specs/route-metadata.ts`, not in controllers.
|
|
85
188
|
|
|
86
189
|
## License
|
|
87
190
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anarchitects/auth-nest",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"types": "./src/index.d.ts",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"tslib": "^2.3.0",
|
|
9
9
|
"@nestjs/common": "^11.0.0",
|
|
10
10
|
"@nestjs/jwt": "^11.0.1",
|
|
11
|
-
"@anarchitects/auth-ts": "0.
|
|
11
|
+
"@anarchitects/auth-ts": "0.1.3",
|
|
12
12
|
"bcrypt": "^6.0.0",
|
|
13
13
|
"@nestjs/passport": "^11.0.5",
|
|
14
14
|
"passport-jwt": "^4.0.1",
|
|
@@ -37,6 +37,9 @@
|
|
|
37
37
|
],
|
|
38
38
|
"presentation": [
|
|
39
39
|
"src/presentation/index.d.ts"
|
|
40
|
+
],
|
|
41
|
+
"config": [
|
|
42
|
+
"src/config/index.d.ts"
|
|
40
43
|
]
|
|
41
44
|
}
|
|
42
45
|
},
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
+
import { AuthConfig } from '../config';
|
|
2
|
+
import { ConfigurableModuleClass, OPTIONS_TYPE } from './application.module-definition';
|
|
1
3
|
import { AuthService } from './services/auth.service';
|
|
2
|
-
import { JwtAuthService } from './services/jwt-auth.service';
|
|
3
4
|
import { BcryptHashService } from './services/bcrypt-hash.service';
|
|
4
|
-
import { ConfigurableModuleClass, OPTIONS_TYPE } from './application.module-definition';
|
|
5
5
|
import { HashService } from './services/hash.service';
|
|
6
|
-
import {
|
|
7
|
-
import { JwtStrategy } from './strategies/jwt/strategy';
|
|
6
|
+
import { JwtAuthService } from './services/jwt-auth.service';
|
|
8
7
|
import { PoliciesService } from './services/policies.service';
|
|
9
|
-
|
|
8
|
+
import { JwtStrategy } from './strategies/jwt/strategy';
|
|
9
|
+
export declare class AuthApplicationModule extends ConfigurableModuleClass {
|
|
10
10
|
private options;
|
|
11
11
|
private authConfig;
|
|
12
12
|
constructor(options: string | symbol, authConfig: AuthConfig);
|
|
13
13
|
static forRoot(options: typeof OPTIONS_TYPE): {
|
|
14
14
|
imports: import("@nestjs/common").DynamicModule[];
|
|
15
|
-
providers: (typeof
|
|
15
|
+
providers: (typeof BcryptHashService | typeof JwtAuthService | typeof PoliciesService | typeof JwtStrategy | {
|
|
16
16
|
provide: typeof HashService;
|
|
17
17
|
useExisting: typeof BcryptHashService;
|
|
18
18
|
} | {
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.AuthApplicationModule = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const common_1 = require("@nestjs/common");
|
|
6
|
+
const jwt_1 = require("@nestjs/jwt");
|
|
7
|
+
const config_1 = require("../config");
|
|
8
|
+
const application_module_definition_1 = require("./application.module-definition");
|
|
6
9
|
const auth_service_1 = require("./services/auth.service");
|
|
7
|
-
const jwt_auth_service_1 = require("./services/jwt-auth.service");
|
|
8
10
|
const bcrypt_hash_service_1 = require("./services/bcrypt-hash.service");
|
|
9
|
-
const application_module_definition_1 = require("./application.module-definition");
|
|
10
11
|
const hash_service_1 = require("./services/hash.service");
|
|
11
|
-
const
|
|
12
|
-
const config_1 = require("../config");
|
|
13
|
-
const strategy_1 = require("./strategies/jwt/strategy");
|
|
12
|
+
const jwt_auth_service_1 = require("./services/jwt-auth.service");
|
|
14
13
|
const policies_service_1 = require("./services/policies.service");
|
|
15
|
-
|
|
14
|
+
const strategy_1 = require("./strategies/jwt/strategy");
|
|
15
|
+
let AuthApplicationModule = class AuthApplicationModule extends application_module_definition_1.ConfigurableModuleClass {
|
|
16
16
|
constructor(options, authConfig) {
|
|
17
17
|
super();
|
|
18
18
|
this.options = options;
|
|
@@ -63,11 +63,11 @@ let ApplicationModule = class ApplicationModule extends application_module_defin
|
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
65
|
};
|
|
66
|
-
exports.
|
|
67
|
-
exports.
|
|
66
|
+
exports.AuthApplicationModule = AuthApplicationModule;
|
|
67
|
+
exports.AuthApplicationModule = AuthApplicationModule = tslib_1.__decorate([
|
|
68
68
|
(0, common_1.Module)({}),
|
|
69
69
|
tslib_1.__param(0, (0, common_1.Inject)(application_module_definition_1.AUTH_APPLICATION_MODULE_OPTIONS)),
|
|
70
70
|
tslib_1.__param(1, (0, config_1.InjectAuthConfig)()),
|
|
71
71
|
tslib_1.__metadata("design:paramtypes", [Object, Object])
|
|
72
|
-
],
|
|
72
|
+
], AuthApplicationModule);
|
|
73
73
|
//# sourceMappingURL=application.module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application.module.js","sourceRoot":"","sources":["../../../../../../libs/auth/nest/src/application/application.module.ts"],"names":[],"mappings":";;;;AAAA,2CAAgD;AAChD,
|
|
1
|
+
{"version":3,"file":"application.module.js","sourceRoot":"","sources":["../../../../../../libs/auth/nest/src/application/application.module.ts"],"names":[],"mappings":";;;;AAAA,2CAAgD;AAChD,qCAAwC;AACxC,sCAAyD;AACzD,mFAIyC;AACzC,0DAAsD;AACtD,wEAAmE;AACnE,0DAAsD;AACtD,kEAA6D;AAC7D,kEAA8D;AAC9D,wDAAwD;AAGjD,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,uDAAuB;IAChE,YACmD,OAAwB,EAC7C,UAAsB;QAElD,KAAK,EAAE,CAAC;QAHyC,YAAO,GAAP,OAAO,CAAiB;QAC7C,eAAU,GAAV,UAAU,CAAY;IAGpD,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,OAA4B;QACzC,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;QAC/C,MAAM,OAAO,GAAG,EAAE,CAAC;QACnB,MAAM,SAAS,GAAG,EAAE,CAAC;QACrB,MAAM,OAAO,GAAG,EAAE,CAAC;QACnB,SAAS,CAAC,IAAI,CAAC,kCAAe,CAAC,CAAC;QAChC,QAAQ,UAAU,CAAC,SAAS,EAAE,CAAC;YAC7B,KAAK,QAAQ;gBACX,SAAS,CAAC,IAAI,CAAC,uCAAiB,EAAE;oBAChC,OAAO,EAAE,0BAAW;oBACpB,WAAW,EAAE,uCAAiB;iBAC/B,CAAC,CAAC;gBACH,OAAO,CAAC,IAAI,CAAC,0BAAW,CAAC,CAAC;gBAC1B,MAAM;YACR,KAAK,QAAQ;gBACX,gEAAgE;gBAChE,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;YAC3D;gBACE,MAAM,IAAI,KAAK,CACb,qCAAqC,UAAU,CAAC,SAAS,EAAE,CAC5D,CAAC;QACN,CAAC;QACD,IAAI,cAAc,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YACnC,OAAO,CAAC,IAAI,CACV,eAAS,CAAC,aAAa,CAAC;gBACtB,UAAU,EAAE,CAAC,UAAsB,EAAE,EAAE,CAAC,CAAC;oBACvC,MAAM,EAAE,UAAU,CAAC,SAAS;oBAC5B,WAAW,EAAE;wBACX,SAAS,EAAE,QAAQ,CAAC,UAAU,CAAC,aAAa,EAAE,EAAE,CAAC;wBACjD,QAAQ,EAAE,UAAU,CAAC,WAAW;wBAChC,MAAM,EAAE,UAAU,CAAC,SAAS;qBAC7B;iBACF,CAAC;aACH,CAAC,CACH,CAAC;YACF,SAAS,CAAC,IAAI,CAAC,iCAAc,EAAE,sBAAW,EAAE;gBAC1C,OAAO,EAAE,0BAAW;gBACpB,WAAW,EAAE,iCAAc;aAC5B,CAAC,CAAC;YACH,OAAO,CAAC,IAAI,CAAC,0BAAW,CAAC,CAAC;QAC5B,CAAC;QACD,OAAO;YACL,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;YACzB,OAAO;YACP,SAAS;YACT,OAAO;SACR,CAAC;IACJ,CAAC;CACF,CAAA;AAxDY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,eAAM,EAAC,EAAE,CAAC;IAGN,mBAAA,IAAA,eAAM,EAAC,+DAA+B,CAAC,CAAA;IACvC,mBAAA,IAAA,yBAAgB,GAAE,CAAA;;GAHV,qBAAqB,CAwDjC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare class
|
|
1
|
+
export declare class AuthMailerModule {
|
|
2
2
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.AuthMailerModule = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const common_1 = require("@nestjs/common");
|
|
6
|
-
const node_mailer_adapter_1 = require("./adapters/node-mailer.adapter");
|
|
7
6
|
const mailer_adapter_1 = require("./adapters/mailer.adapter");
|
|
8
|
-
|
|
7
|
+
const node_mailer_adapter_1 = require("./adapters/node-mailer.adapter");
|
|
8
|
+
let AuthMailerModule = class AuthMailerModule {
|
|
9
9
|
};
|
|
10
|
-
exports.
|
|
11
|
-
exports.
|
|
10
|
+
exports.AuthMailerModule = AuthMailerModule;
|
|
11
|
+
exports.AuthMailerModule = AuthMailerModule = tslib_1.__decorate([
|
|
12
12
|
(0, common_1.Module)({
|
|
13
13
|
providers: [
|
|
14
14
|
node_mailer_adapter_1.NodeMailerAdapter,
|
|
@@ -19,5 +19,5 @@ exports.MailerModule = MailerModule = tslib_1.__decorate([
|
|
|
19
19
|
],
|
|
20
20
|
exports: [mailer_adapter_1.MailerAdapter],
|
|
21
21
|
})
|
|
22
|
-
],
|
|
22
|
+
], AuthMailerModule);
|
|
23
23
|
//# sourceMappingURL=mailer.module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mailer.module.js","sourceRoot":"","sources":["../../../../../../libs/auth/nest/src/infrastructure-mailer/mailer.module.ts"],"names":[],"mappings":";;;;AAAA,2CAAwC;AACxC,
|
|
1
|
+
{"version":3,"file":"mailer.module.js","sourceRoot":"","sources":["../../../../../../libs/auth/nest/src/infrastructure-mailer/mailer.module.ts"],"names":[],"mappings":";;;;AAAA,2CAAwC;AACxC,8DAA0D;AAC1D,wEAAmE;AAY5D,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;CAAG,CAAA;AAAnB,4CAAgB;2BAAhB,gBAAgB;IAV5B,IAAA,eAAM,EAAC;QACN,SAAS,EAAE;YACT,uCAAiB;YACjB;gBACE,OAAO,EAAE,8BAAa;gBACtB,WAAW,EAAE,uCAAiB;aAC/B;SACF;QACD,OAAO,EAAE,CAAC,8BAAa,CAAC;KACzB,CAAC;GACW,gBAAgB,CAAG"}
|
|
@@ -3,4 +3,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
tslib_1.__exportStar(require("./persistence.module"), exports);
|
|
5
5
|
tslib_1.__exportStar(require("./repositories/auth-user.repository"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./migrations/1720200000000-create-auth-schema"), exports);
|
|
6
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../libs/auth/nest/src/infrastructure-persistence/index.ts"],"names":[],"mappings":";;;AAAA,+DAAqC;AACrC,8EAAoD"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../libs/auth/nest/src/infrastructure-persistence/index.ts"],"names":[],"mappings":";;;AAAA,+DAAqC;AACrC,8EAAoD;AACpD,wFAA8D"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
2
|
-
export declare class
|
|
2
|
+
export declare class CreateAuthSchema1720200000000 implements MigrationInterface {
|
|
3
3
|
name: string;
|
|
4
4
|
up(queryRunner: QueryRunner): Promise<void>;
|
|
5
5
|
down(queryRunner: QueryRunner): Promise<void>;
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CreateAuthSchema1720200000000 = void 0;
|
|
4
|
+
const typeorm_1 = require("typeorm");
|
|
5
|
+
const schema_1 = require("../schema");
|
|
6
|
+
const USERS_TABLE = `${schema_1.AUTH_SCHEMA}.users`;
|
|
7
|
+
const ROLES_TABLE = `${schema_1.AUTH_SCHEMA}.roles`;
|
|
8
|
+
const PERMISSIONS_TABLE = `${schema_1.AUTH_SCHEMA}.permissions`;
|
|
9
|
+
const USER_ROLES_TABLE = `${schema_1.AUTH_SCHEMA}.user_roles`;
|
|
10
|
+
const ROLE_PERMISSIONS_TABLE = `${schema_1.AUTH_SCHEMA}.role_permissions`;
|
|
11
|
+
const INVALIDATED_TOKENS_TABLE = `${schema_1.AUTH_SCHEMA}.invalidated_tokens`;
|
|
12
|
+
class CreateAuthSchema1720200000000 {
|
|
13
|
+
constructor() {
|
|
14
|
+
this.name = 'CreateAuthSchema1720200000000';
|
|
15
|
+
}
|
|
16
|
+
async up(queryRunner) {
|
|
17
|
+
await queryRunner.createSchema(schema_1.AUTH_SCHEMA, true);
|
|
18
|
+
if (!(await queryRunner.hasTable(USERS_TABLE))) {
|
|
19
|
+
await queryRunner.createTable(new typeorm_1.Table({
|
|
20
|
+
schema: schema_1.AUTH_SCHEMA,
|
|
21
|
+
name: 'users',
|
|
22
|
+
columns: [
|
|
23
|
+
{
|
|
24
|
+
name: 'id',
|
|
25
|
+
type: 'uuid',
|
|
26
|
+
isPrimary: true,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: 'email',
|
|
30
|
+
type: 'varchar',
|
|
31
|
+
length: '255',
|
|
32
|
+
isNullable: false,
|
|
33
|
+
isUnique: true,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: 'userName',
|
|
37
|
+
type: 'varchar',
|
|
38
|
+
length: '100',
|
|
39
|
+
isNullable: true,
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: 'passwordHash',
|
|
43
|
+
type: 'varchar',
|
|
44
|
+
length: '255',
|
|
45
|
+
isNullable: false,
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'token',
|
|
49
|
+
type: 'varchar',
|
|
50
|
+
length: '500',
|
|
51
|
+
isNullable: true,
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: 'isActive',
|
|
55
|
+
type: 'boolean',
|
|
56
|
+
default: false,
|
|
57
|
+
isNullable: false,
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: 'createdAt',
|
|
61
|
+
type: 'timestamptz',
|
|
62
|
+
default: 'CURRENT_TIMESTAMP',
|
|
63
|
+
isNullable: false,
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: 'updatedAt',
|
|
67
|
+
type: 'timestamptz',
|
|
68
|
+
default: 'CURRENT_TIMESTAMP',
|
|
69
|
+
isNullable: false,
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
}), true);
|
|
73
|
+
}
|
|
74
|
+
if (!(await queryRunner.hasTable(ROLES_TABLE))) {
|
|
75
|
+
await queryRunner.createTable(new typeorm_1.Table({
|
|
76
|
+
schema: schema_1.AUTH_SCHEMA,
|
|
77
|
+
name: 'roles',
|
|
78
|
+
columns: [
|
|
79
|
+
{
|
|
80
|
+
name: 'id',
|
|
81
|
+
type: 'uuid',
|
|
82
|
+
isPrimary: true,
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: 'name',
|
|
86
|
+
type: 'varchar',
|
|
87
|
+
length: '100',
|
|
88
|
+
isNullable: false,
|
|
89
|
+
isUnique: true,
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: 'description',
|
|
93
|
+
type: 'text',
|
|
94
|
+
isNullable: true,
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
name: 'createdAt',
|
|
98
|
+
type: 'timestamptz',
|
|
99
|
+
default: 'CURRENT_TIMESTAMP',
|
|
100
|
+
isNullable: false,
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: 'updatedAt',
|
|
104
|
+
type: 'timestamptz',
|
|
105
|
+
default: 'CURRENT_TIMESTAMP',
|
|
106
|
+
isNullable: false,
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
}), true);
|
|
110
|
+
}
|
|
111
|
+
if (!(await queryRunner.hasTable(PERMISSIONS_TABLE))) {
|
|
112
|
+
await queryRunner.createTable(new typeorm_1.Table({
|
|
113
|
+
schema: schema_1.AUTH_SCHEMA,
|
|
114
|
+
name: 'permissions',
|
|
115
|
+
columns: [
|
|
116
|
+
{
|
|
117
|
+
name: 'id',
|
|
118
|
+
type: 'uuid',
|
|
119
|
+
isPrimary: true,
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
name: 'name',
|
|
123
|
+
type: 'varchar',
|
|
124
|
+
length: '100',
|
|
125
|
+
isNullable: false,
|
|
126
|
+
isUnique: true,
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
name: 'description',
|
|
130
|
+
type: 'text',
|
|
131
|
+
isNullable: true,
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
name: 'action',
|
|
135
|
+
type: 'varchar',
|
|
136
|
+
length: '100',
|
|
137
|
+
isNullable: false,
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
name: 'subject',
|
|
141
|
+
type: 'varchar',
|
|
142
|
+
length: '100',
|
|
143
|
+
isNullable: false,
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
name: 'conditions',
|
|
147
|
+
type: 'jsonb',
|
|
148
|
+
isNullable: true,
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
name: 'fields',
|
|
152
|
+
type: 'jsonb',
|
|
153
|
+
isNullable: true,
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
name: 'inverted',
|
|
157
|
+
type: 'boolean',
|
|
158
|
+
default: false,
|
|
159
|
+
isNullable: false,
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
name: 'reason',
|
|
163
|
+
type: 'text',
|
|
164
|
+
isNullable: true,
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
name: 'createdAt',
|
|
168
|
+
type: 'timestamptz',
|
|
169
|
+
default: 'CURRENT_TIMESTAMP',
|
|
170
|
+
isNullable: false,
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
name: 'updatedAt',
|
|
174
|
+
type: 'timestamptz',
|
|
175
|
+
default: 'CURRENT_TIMESTAMP',
|
|
176
|
+
isNullable: false,
|
|
177
|
+
},
|
|
178
|
+
],
|
|
179
|
+
}), true);
|
|
180
|
+
}
|
|
181
|
+
if (!(await queryRunner.hasTable(USER_ROLES_TABLE))) {
|
|
182
|
+
await queryRunner.createTable(new typeorm_1.Table({
|
|
183
|
+
schema: schema_1.AUTH_SCHEMA,
|
|
184
|
+
name: 'user_roles',
|
|
185
|
+
columns: [
|
|
186
|
+
{
|
|
187
|
+
name: 'user_id',
|
|
188
|
+
type: 'uuid',
|
|
189
|
+
isPrimary: true,
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
name: 'role_id',
|
|
193
|
+
type: 'uuid',
|
|
194
|
+
isPrimary: true,
|
|
195
|
+
},
|
|
196
|
+
],
|
|
197
|
+
foreignKeys: [
|
|
198
|
+
{
|
|
199
|
+
name: 'fk_auth_user_roles_user_id',
|
|
200
|
+
columnNames: ['user_id'],
|
|
201
|
+
referencedTableName: USERS_TABLE,
|
|
202
|
+
referencedColumnNames: ['id'],
|
|
203
|
+
onDelete: 'CASCADE',
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
name: 'fk_auth_user_roles_role_id',
|
|
207
|
+
columnNames: ['role_id'],
|
|
208
|
+
referencedTableName: ROLES_TABLE,
|
|
209
|
+
referencedColumnNames: ['id'],
|
|
210
|
+
onDelete: 'CASCADE',
|
|
211
|
+
},
|
|
212
|
+
],
|
|
213
|
+
}), true);
|
|
214
|
+
}
|
|
215
|
+
if (!(await queryRunner.hasTable(ROLE_PERMISSIONS_TABLE))) {
|
|
216
|
+
await queryRunner.createTable(new typeorm_1.Table({
|
|
217
|
+
schema: schema_1.AUTH_SCHEMA,
|
|
218
|
+
name: 'role_permissions',
|
|
219
|
+
columns: [
|
|
220
|
+
{
|
|
221
|
+
name: 'role_id',
|
|
222
|
+
type: 'uuid',
|
|
223
|
+
isPrimary: true,
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
name: 'permission_id',
|
|
227
|
+
type: 'uuid',
|
|
228
|
+
isPrimary: true,
|
|
229
|
+
},
|
|
230
|
+
],
|
|
231
|
+
foreignKeys: [
|
|
232
|
+
{
|
|
233
|
+
name: 'fk_auth_role_permissions_role_id',
|
|
234
|
+
columnNames: ['role_id'],
|
|
235
|
+
referencedTableName: ROLES_TABLE,
|
|
236
|
+
referencedColumnNames: ['id'],
|
|
237
|
+
onDelete: 'CASCADE',
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
name: 'fk_auth_role_permissions_permission_id',
|
|
241
|
+
columnNames: ['permission_id'],
|
|
242
|
+
referencedTableName: PERMISSIONS_TABLE,
|
|
243
|
+
referencedColumnNames: ['id'],
|
|
244
|
+
onDelete: 'CASCADE',
|
|
245
|
+
},
|
|
246
|
+
],
|
|
247
|
+
}), true);
|
|
248
|
+
}
|
|
249
|
+
if (!(await queryRunner.hasTable(INVALIDATED_TOKENS_TABLE))) {
|
|
250
|
+
await queryRunner.createTable(new typeorm_1.Table({
|
|
251
|
+
schema: schema_1.AUTH_SCHEMA,
|
|
252
|
+
name: 'invalidated_tokens',
|
|
253
|
+
columns: [
|
|
254
|
+
{
|
|
255
|
+
name: 'tokenId',
|
|
256
|
+
type: 'varchar',
|
|
257
|
+
length: '128',
|
|
258
|
+
isPrimary: true,
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
name: 'userId',
|
|
262
|
+
type: 'uuid',
|
|
263
|
+
isNullable: true,
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
name: 'expires_at',
|
|
267
|
+
type: 'timestamptz',
|
|
268
|
+
isNullable: false,
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
name: 'invalidated_at',
|
|
272
|
+
type: 'timestamptz',
|
|
273
|
+
default: 'CURRENT_TIMESTAMP',
|
|
274
|
+
isNullable: false,
|
|
275
|
+
},
|
|
276
|
+
],
|
|
277
|
+
}), true);
|
|
278
|
+
}
|
|
279
|
+
const invalidatedTokensIndexName = 'invalidated_tokens_expires_at_idx';
|
|
280
|
+
const invalidatedTokensTable = await queryRunner.getTable(INVALIDATED_TOKENS_TABLE);
|
|
281
|
+
const hasInvalidatedTokensIndex = invalidatedTokensTable?.indices.some((index) => index.name === invalidatedTokensIndexName);
|
|
282
|
+
if (!hasInvalidatedTokensIndex) {
|
|
283
|
+
await queryRunner.createIndex(INVALIDATED_TOKENS_TABLE, new typeorm_1.TableIndex({
|
|
284
|
+
name: invalidatedTokensIndexName,
|
|
285
|
+
columnNames: ['expires_at'],
|
|
286
|
+
isUnique: false,
|
|
287
|
+
}));
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
async down(queryRunner) {
|
|
291
|
+
if (await queryRunner.hasTable(ROLE_PERMISSIONS_TABLE)) {
|
|
292
|
+
await queryRunner.dropTable(ROLE_PERMISSIONS_TABLE, true, true, true);
|
|
293
|
+
}
|
|
294
|
+
if (await queryRunner.hasTable(USER_ROLES_TABLE)) {
|
|
295
|
+
await queryRunner.dropTable(USER_ROLES_TABLE, true, true, true);
|
|
296
|
+
}
|
|
297
|
+
if (await queryRunner.hasTable(INVALIDATED_TOKENS_TABLE)) {
|
|
298
|
+
await queryRunner.dropTable(INVALIDATED_TOKENS_TABLE, true, true, true);
|
|
299
|
+
}
|
|
300
|
+
if (await queryRunner.hasTable(PERMISSIONS_TABLE)) {
|
|
301
|
+
await queryRunner.dropTable(PERMISSIONS_TABLE, true, true, true);
|
|
302
|
+
}
|
|
303
|
+
if (await queryRunner.hasTable(ROLES_TABLE)) {
|
|
304
|
+
await queryRunner.dropTable(ROLES_TABLE, true, true, true);
|
|
305
|
+
}
|
|
306
|
+
if (await queryRunner.hasTable(USERS_TABLE)) {
|
|
307
|
+
await queryRunner.dropTable(USERS_TABLE, true, true, true);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
exports.CreateAuthSchema1720200000000 = CreateAuthSchema1720200000000;
|
|
312
|
+
//# sourceMappingURL=1720200000000-create-auth-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"1720200000000-create-auth-schema.js","sourceRoot":"","sources":["../../../../../../../libs/auth/nest/src/infrastructure-persistence/migrations/1720200000000-create-auth-schema.ts"],"names":[],"mappings":";;;AAAA,qCAA6E;AAC7E,sCAAwC;AAExC,MAAM,WAAW,GAAG,GAAG,oBAAW,QAAQ,CAAC;AAC3C,MAAM,WAAW,GAAG,GAAG,oBAAW,QAAQ,CAAC;AAC3C,MAAM,iBAAiB,GAAG,GAAG,oBAAW,cAAc,CAAC;AACvD,MAAM,gBAAgB,GAAG,GAAG,oBAAW,aAAa,CAAC;AACrD,MAAM,sBAAsB,GAAG,GAAG,oBAAW,mBAAmB,CAAC;AACjE,MAAM,wBAAwB,GAAG,GAAG,oBAAW,qBAAqB,CAAC;AAErE,MAAa,6BAA6B;IAA1C;QACE,SAAI,GAAG,+BAA+B,CAAC;IA+UzC,CAAC;IA7UQ,KAAK,CAAC,EAAE,CAAC,WAAwB;QACtC,MAAM,WAAW,CAAC,YAAY,CAAC,oBAAW,EAAE,IAAI,CAAC,CAAC;QAElD,IAAI,CAAC,CAAC,MAAM,WAAW,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC;YAC/C,MAAM,WAAW,CAAC,WAAW,CAC3B,IAAI,eAAK,CAAC;gBACR,MAAM,EAAE,oBAAW;gBACnB,IAAI,EAAE,OAAO;gBACb,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,IAAI;wBACV,IAAI,EAAE,MAAM;wBACZ,SAAS,EAAE,IAAI;qBAChB;oBACD;wBACE,IAAI,EAAE,OAAO;wBACb,IAAI,EAAE,SAAS;wBACf,MAAM,EAAE,KAAK;wBACb,UAAU,EAAE,KAAK;wBACjB,QAAQ,EAAE,IAAI;qBACf;oBACD;wBACE,IAAI,EAAE,UAAU;wBAChB,IAAI,EAAE,SAAS;wBACf,MAAM,EAAE,KAAK;wBACb,UAAU,EAAE,IAAI;qBACjB;oBACD;wBACE,IAAI,EAAE,cAAc;wBACpB,IAAI,EAAE,SAAS;wBACf,MAAM,EAAE,KAAK;wB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,MAAM,WAAW,CAAC,SAAS,CAAC,iBAAiB,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QACnE,CAAC;QAED,IAAI,MAAM,WAAW,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;YAC5C,MAAM,WAAW,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QAC7D,CAAC;QAED,IAAI,MAAM,WAAW,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;YAC5C,MAAM,WAAW,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;CACF;AAhVD,sEAgVC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DynamicModule } from '@nestjs/common';
|
|
2
2
|
import { ConfigurableModuleClass, OPTIONS_TYPE } from './persistence.module-definition';
|
|
3
|
-
export declare class
|
|
3
|
+
export declare class AuthPersistenceModule extends ConfigurableModuleClass {
|
|
4
4
|
private options;
|
|
5
5
|
constructor(options: string | symbol);
|
|
6
6
|
static forRoot(options: typeof OPTIONS_TYPE): DynamicModule;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.AuthPersistenceModule = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const common_1 = require("@nestjs/common");
|
|
6
|
-
const auth_user_repository_1 = require("./repositories/auth-user.repository");
|
|
7
|
-
const typeorm_auth_user_repository_1 = require("./repositories/typeorm-auth-user.repository");
|
|
8
|
-
const persistence_module_definition_1 = require("./persistence.module-definition");
|
|
9
6
|
const typeorm_1 = require("@nestjs/typeorm");
|
|
10
|
-
const user_entity_1 = require("./entities/user.entity");
|
|
11
|
-
const role_entity_1 = require("./entities/role.entity");
|
|
12
|
-
const permission_entity_1 = require("./entities/permission.entity");
|
|
13
7
|
const invalidated_token_entity_1 = require("./entities/invalidated-token.entity");
|
|
14
|
-
|
|
8
|
+
const permission_entity_1 = require("./entities/permission.entity");
|
|
9
|
+
const role_entity_1 = require("./entities/role.entity");
|
|
10
|
+
const user_entity_1 = require("./entities/user.entity");
|
|
11
|
+
const persistence_module_definition_1 = require("./persistence.module-definition");
|
|
12
|
+
const auth_user_repository_1 = require("./repositories/auth-user.repository");
|
|
13
|
+
const typeorm_auth_user_repository_1 = require("./repositories/typeorm-auth-user.repository");
|
|
14
|
+
let AuthPersistenceModule = class AuthPersistenceModule extends persistence_module_definition_1.ConfigurableModuleClass {
|
|
15
15
|
constructor(options) {
|
|
16
16
|
super();
|
|
17
17
|
this.options = options;
|
|
@@ -43,10 +43,10 @@ let PersistenceModule = class PersistenceModule extends persistence_module_defin
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
|
-
exports.
|
|
47
|
-
exports.
|
|
46
|
+
exports.AuthPersistenceModule = AuthPersistenceModule;
|
|
47
|
+
exports.AuthPersistenceModule = AuthPersistenceModule = tslib_1.__decorate([
|
|
48
48
|
(0, common_1.Module)({}),
|
|
49
49
|
tslib_1.__param(0, (0, common_1.Inject)(persistence_module_definition_1.AUTH_PERSISTENCE_MODULE_OPTIONS)),
|
|
50
50
|
tslib_1.__metadata("design:paramtypes", [Object])
|
|
51
|
-
],
|
|
51
|
+
], AuthPersistenceModule);
|
|
52
52
|
//# sourceMappingURL=persistence.module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"persistence.module.js","sourceRoot":"","sources":["../../../../../../libs/auth/nest/src/infrastructure-persistence/persistence.module.ts"],"names":[],"mappings":";;;;AAAA,2CAA+D;AAC/D,
|
|
1
|
+
{"version":3,"file":"persistence.module.js","sourceRoot":"","sources":["../../../../../../libs/auth/nest/src/infrastructure-persistence/persistence.module.ts"],"names":[],"mappings":";;;;AAAA,2CAA+D;AAC/D,6CAAgD;AAChD,kFAA6E;AAC7E,oEAAgE;AAChE,wDAAoD;AACpD,wDAAoD;AACpD,mFAIyC;AACzC,8EAAyE;AACzE,8FAAwF;AAGjF,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,uDAAuB;IAChE,YACmD,OAAwB;QAEzE,KAAK,EAAE,CAAC;QAFyC,YAAO,GAAP,OAAO,CAAiB;IAG3E,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,OAA4B;QACzC,QAAQ,OAAO,CAAC,WAAW,EAAE,CAAC;YAC5B,KAAK,SAAS;gBACZ,OAAO;oBACL,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;oBACzB,OAAO,EAAE;wBACP,uBAAa,CAAC,UAAU,CAAC;4BACvB,wBAAU;4BACV,wBAAU;4BACV,oCAAgB;4BAChB,iDAAsB;yBACvB,CAAC;qBACH;oBACD,SAAS,EAAE;wBACT,wDAAyB;wBACzB;4BACE,OAAO,EAAE,yCAAkB;4BAC3B,WAAW,EAAE,wDAAyB;yBACvC;qBACF;oBACD,OAAO,EAAE,CAAC,yCAAkB,EAAE,uBAAa,CAAC;iBAC7C,CAAC;YACJ;gBACE,MAAM,IAAI,KAAK,CAAC,iCAAiC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;QAC5E,CAAC;IACH,CAAC;CACF,CAAA;AAjCY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,eAAM,EAAC,EAAE,CAAC;IAGN,mBAAA,IAAA,eAAM,EAAC,+DAA+B,CAAC,CAAA;;GAF/B,qBAAqB,CAiCjC"}
|
|
@@ -1,39 +1,21 @@
|
|
|
1
|
-
import { ActivateUserRequestDTO, ChangePasswordRequestDTO, ForgotPasswordRequestDTO, LoginRequestDTO, LoginResponseDTO, LogoutRequestDTO, RefreshTokenRequestDTO, RegisterRequestDTO, RegisterResponseDTO, ResetPasswordRequestDTO, UpdateEmailRequestDTO, VerifyEmailRequestDTO } from '@anarchitects/auth-ts/dtos';
|
|
2
|
-
import { PolicyRule, User } from '@anarchitects/auth-ts/models';
|
|
1
|
+
import { ActivateUserRequestDTO, ChangePasswordRequestDTO, ForgotPasswordRequestDTO, LoginRequestDTO, LoginResponseDTO, LoggedInUserInfoResponseDTO, LogoutRequestDTO, RefreshTokenRequestDTO, RegisterRequestDTO, RegisterResponseDTO, ResetPasswordRequestDTO, SuccessResponseDTO, UpdateEmailRequestDTO, VerifyEmailRequestDTO } from '@anarchitects/auth-ts/dtos';
|
|
3
2
|
import { AuthService } from '../../application/services/auth.service';
|
|
4
3
|
export declare class AuthController {
|
|
5
4
|
private readonly authService;
|
|
6
5
|
constructor(authService: AuthService);
|
|
7
6
|
registerUser(dto: RegisterRequestDTO): Promise<RegisterResponseDTO>;
|
|
8
|
-
activateUser(dto: ActivateUserRequestDTO): Promise<
|
|
9
|
-
success: boolean;
|
|
10
|
-
}>;
|
|
7
|
+
activateUser(dto: ActivateUserRequestDTO): Promise<SuccessResponseDTO>;
|
|
11
8
|
login(dto: LoginRequestDTO): Promise<LoginResponseDTO>;
|
|
12
|
-
logout(dto: LogoutRequestDTO): Promise<
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
forgotPassword(dto: ForgotPasswordRequestDTO): Promise<{
|
|
19
|
-
success: boolean;
|
|
20
|
-
}>;
|
|
21
|
-
resetPassword(dto: ResetPasswordRequestDTO): Promise<{
|
|
22
|
-
success: boolean;
|
|
23
|
-
}>;
|
|
24
|
-
verifyEmail(dto: VerifyEmailRequestDTO): Promise<{
|
|
25
|
-
success: boolean;
|
|
26
|
-
}>;
|
|
27
|
-
updateEmail(userId: string, dto: UpdateEmailRequestDTO): Promise<{
|
|
28
|
-
success: boolean;
|
|
29
|
-
}>;
|
|
9
|
+
logout(dto: LogoutRequestDTO): Promise<SuccessResponseDTO>;
|
|
10
|
+
changePassword(userId: string, dto: ChangePasswordRequestDTO): Promise<SuccessResponseDTO>;
|
|
11
|
+
forgotPassword(dto: ForgotPasswordRequestDTO): Promise<SuccessResponseDTO>;
|
|
12
|
+
resetPassword(dto: ResetPasswordRequestDTO): Promise<SuccessResponseDTO>;
|
|
13
|
+
verifyEmail(dto: VerifyEmailRequestDTO): Promise<SuccessResponseDTO>;
|
|
14
|
+
updateEmail(userId: string, dto: UpdateEmailRequestDTO): Promise<SuccessResponseDTO>;
|
|
30
15
|
refreshTokens(userId: string, dto: RefreshTokenRequestDTO): Promise<LoginResponseDTO>;
|
|
31
16
|
getLoggedInUserInfo(req: {
|
|
32
17
|
user: {
|
|
33
18
|
sub: string;
|
|
34
19
|
};
|
|
35
|
-
}): Promise<
|
|
36
|
-
user: User;
|
|
37
|
-
rbac: PolicyRule[];
|
|
38
|
-
}>;
|
|
20
|
+
}): Promise<LoggedInUserInfoResponseDTO>;
|
|
39
21
|
}
|
|
@@ -47,6 +47,7 @@ let AuthController = class AuthController {
|
|
|
47
47
|
};
|
|
48
48
|
exports.AuthController = AuthController;
|
|
49
49
|
tslib_1.__decorate([
|
|
50
|
+
(0, common_1.HttpCode)(200),
|
|
50
51
|
(0, common_1.Post)('/register'),
|
|
51
52
|
(0, platform_fastify_1.RouteSchema)({
|
|
52
53
|
body: dtos_1.RegisterRequestSchema,
|
|
@@ -61,9 +62,7 @@ tslib_1.__decorate([
|
|
|
61
62
|
(0, common_1.Patch)('/activate'),
|
|
62
63
|
(0, platform_fastify_1.RouteSchema)({
|
|
63
64
|
body: dtos_1.ActivateUserRequestSchema,
|
|
64
|
-
response: {
|
|
65
|
-
200: { success: { type: 'boolean' } },
|
|
66
|
-
},
|
|
65
|
+
response: { 200: dtos_1.SuccessResponseSchema },
|
|
67
66
|
}),
|
|
68
67
|
tslib_1.__param(0, (0, common_1.Body)()),
|
|
69
68
|
tslib_1.__metadata("design:type", Function),
|
|
@@ -71,6 +70,7 @@ tslib_1.__decorate([
|
|
|
71
70
|
tslib_1.__metadata("design:returntype", Promise)
|
|
72
71
|
], AuthController.prototype, "activateUser", null);
|
|
73
72
|
tslib_1.__decorate([
|
|
73
|
+
(0, common_1.HttpCode)(200),
|
|
74
74
|
(0, common_1.Post)('/login'),
|
|
75
75
|
(0, platform_fastify_1.RouteSchema)({
|
|
76
76
|
body: dtos_1.LoginRequestSchema,
|
|
@@ -82,10 +82,11 @@ tslib_1.__decorate([
|
|
|
82
82
|
tslib_1.__metadata("design:returntype", Promise)
|
|
83
83
|
], AuthController.prototype, "login", null);
|
|
84
84
|
tslib_1.__decorate([
|
|
85
|
+
(0, common_1.HttpCode)(200),
|
|
85
86
|
(0, common_1.Post)('/logout'),
|
|
86
87
|
(0, platform_fastify_1.RouteSchema)({
|
|
87
88
|
body: dtos_1.LogoutRequestSchema,
|
|
88
|
-
response: { 200:
|
|
89
|
+
response: { 200: dtos_1.SuccessResponseSchema },
|
|
89
90
|
}),
|
|
90
91
|
tslib_1.__param(0, (0, common_1.Body)()),
|
|
91
92
|
tslib_1.__metadata("design:type", Function),
|
|
@@ -96,10 +97,8 @@ tslib_1.__decorate([
|
|
|
96
97
|
(0, common_1.Patch)('/change-password/:userId'),
|
|
97
98
|
(0, platform_fastify_1.RouteSchema)({
|
|
98
99
|
body: dtos_1.ChangePasswordRequestSchema,
|
|
99
|
-
params:
|
|
100
|
-
|
|
101
|
-
},
|
|
102
|
-
response: { 200: { success: { type: 'boolean' } } },
|
|
100
|
+
params: dtos_1.UserIdParamsSchema,
|
|
101
|
+
response: { 200: dtos_1.SuccessResponseSchema },
|
|
103
102
|
}),
|
|
104
103
|
tslib_1.__param(0, (0, common_1.Param)('userId')),
|
|
105
104
|
tslib_1.__param(1, (0, common_1.Body)()),
|
|
@@ -108,10 +107,11 @@ tslib_1.__decorate([
|
|
|
108
107
|
tslib_1.__metadata("design:returntype", Promise)
|
|
109
108
|
], AuthController.prototype, "changePassword", null);
|
|
110
109
|
tslib_1.__decorate([
|
|
110
|
+
(0, common_1.HttpCode)(200),
|
|
111
111
|
(0, common_1.Post)('/forgot-password'),
|
|
112
112
|
(0, platform_fastify_1.RouteSchema)({
|
|
113
113
|
body: dtos_1.ForgotPasswordRequestSchema,
|
|
114
|
-
response: { 200:
|
|
114
|
+
response: { 200: dtos_1.SuccessResponseSchema },
|
|
115
115
|
}),
|
|
116
116
|
tslib_1.__param(0, (0, common_1.Body)()),
|
|
117
117
|
tslib_1.__metadata("design:type", Function),
|
|
@@ -119,10 +119,11 @@ tslib_1.__decorate([
|
|
|
119
119
|
tslib_1.__metadata("design:returntype", Promise)
|
|
120
120
|
], AuthController.prototype, "forgotPassword", null);
|
|
121
121
|
tslib_1.__decorate([
|
|
122
|
+
(0, common_1.HttpCode)(200),
|
|
122
123
|
(0, common_1.Post)('/reset-password'),
|
|
123
124
|
(0, platform_fastify_1.RouteSchema)({
|
|
124
125
|
body: dtos_1.ResetPasswordRequestSchema,
|
|
125
|
-
response: { 200:
|
|
126
|
+
response: { 200: dtos_1.SuccessResponseSchema },
|
|
126
127
|
}),
|
|
127
128
|
tslib_1.__param(0, (0, common_1.Body)()),
|
|
128
129
|
tslib_1.__metadata("design:type", Function),
|
|
@@ -130,10 +131,11 @@ tslib_1.__decorate([
|
|
|
130
131
|
tslib_1.__metadata("design:returntype", Promise)
|
|
131
132
|
], AuthController.prototype, "resetPassword", null);
|
|
132
133
|
tslib_1.__decorate([
|
|
134
|
+
(0, common_1.HttpCode)(200),
|
|
133
135
|
(0, common_1.Post)('/verify-email'),
|
|
134
136
|
(0, platform_fastify_1.RouteSchema)({
|
|
135
137
|
body: dtos_1.VerifyEmailRequestSchema,
|
|
136
|
-
response: { 200:
|
|
138
|
+
response: { 200: dtos_1.SuccessResponseSchema },
|
|
137
139
|
}),
|
|
138
140
|
tslib_1.__param(0, (0, common_1.Body)()),
|
|
139
141
|
tslib_1.__metadata("design:type", Function),
|
|
@@ -144,10 +146,8 @@ tslib_1.__decorate([
|
|
|
144
146
|
(0, common_1.Patch)('/update-email/:userId'),
|
|
145
147
|
(0, platform_fastify_1.RouteSchema)({
|
|
146
148
|
body: dtos_1.UpdateEmailRequestSchema,
|
|
147
|
-
params:
|
|
148
|
-
|
|
149
|
-
},
|
|
150
|
-
response: { 200: { success: { type: 'boolean' } } },
|
|
149
|
+
params: dtos_1.UserIdParamsSchema,
|
|
150
|
+
response: { 200: dtos_1.SuccessResponseSchema },
|
|
151
151
|
}),
|
|
152
152
|
tslib_1.__param(0, (0, common_1.Param)('userId')),
|
|
153
153
|
tslib_1.__param(1, (0, common_1.Body)()),
|
|
@@ -156,12 +156,11 @@ tslib_1.__decorate([
|
|
|
156
156
|
tslib_1.__metadata("design:returntype", Promise)
|
|
157
157
|
], AuthController.prototype, "updateEmail", null);
|
|
158
158
|
tslib_1.__decorate([
|
|
159
|
+
(0, common_1.HttpCode)(200),
|
|
159
160
|
(0, common_1.Post)('/refresh-tokens/:userId'),
|
|
160
161
|
(0, platform_fastify_1.RouteSchema)({
|
|
161
162
|
body: dtos_1.RefreshTokenRequestSchema,
|
|
162
|
-
params:
|
|
163
|
-
userId: { type: 'string' },
|
|
164
|
-
},
|
|
163
|
+
params: dtos_1.UserIdParamsSchema,
|
|
165
164
|
response: { 200: dtos_1.LoginResponseSchema },
|
|
166
165
|
}),
|
|
167
166
|
tslib_1.__param(0, (0, common_1.Param)('userId')),
|
|
@@ -173,18 +172,7 @@ tslib_1.__decorate([
|
|
|
173
172
|
tslib_1.__decorate([
|
|
174
173
|
(0, common_1.Get)('/me'),
|
|
175
174
|
(0, platform_fastify_1.RouteSchema)({
|
|
176
|
-
response: {
|
|
177
|
-
200: {
|
|
178
|
-
type: 'object',
|
|
179
|
-
properties: {
|
|
180
|
-
user: { type: 'object' }, // Define user schema as needed
|
|
181
|
-
rbac: {
|
|
182
|
-
type: 'array',
|
|
183
|
-
items: { type: 'object' }, // Define PolicyRule schema as needed
|
|
184
|
-
},
|
|
185
|
-
},
|
|
186
|
-
},
|
|
187
|
-
},
|
|
175
|
+
response: { 200: dtos_1.LoggedInUserInfoResponseSchema },
|
|
188
176
|
}),
|
|
189
177
|
tslib_1.__param(0, (0, common_1.Req)()),
|
|
190
178
|
tslib_1.__metadata("design:type", Function),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.controller.js","sourceRoot":"","sources":["../../../../../../../libs/auth/nest/src/presentation/controllers/auth.controller.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"auth.controller.js","sourceRoot":"","sources":["../../../../../../../libs/auth/nest/src/presentation/controllers/auth.controller.ts"],"names":[],"mappings":";;;;AAAA,qDA8BoC;AACpC,2CASwB;AACxB,+DAAuD;AACvD,0EAAsE;AAG/D,IAAM,cAAc,GAApB,MAAM,cAAc;IACzB,YAA6B,WAAwB;QAAxB,gBAAW,GAAX,WAAW,CAAa;IAAG,CAAC;IAQnD,AAAN,KAAK,CAAC,YAAY,CACR,GAAuB;QAE/B,OAAO,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IAC5C,CAAC;IAOK,AAAN,KAAK,CAAC,YAAY,CACR,GAA2B;QAEnC,OAAO,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IAC5C,CAAC;IAQK,AAAN,KAAK,CAAC,KAAK,CAAS,GAAoB;QACtC,OAAO,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACrC,CAAC;IAQK,AAAN,KAAK,CAAC,MAAM,CAAS,GAAqB;QACxC,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACtC,CAAC;IAQK,AAAN,KAAK,CAAC,cAAc,CACD,MAAc,EACvB,GAA6B;QAErC,OAAO,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACtD,CAAC;IAQK,AAAN,KAAK,CAAC,cAAc,CACV,GAA6B;QAErC,OAAO,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;IAC9C,CAAC;IAQK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"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.AuthPresentationModule = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const common_1 = require("@nestjs/common");
|
|
6
6
|
const auth_controller_1 = require("./controllers/auth.controller");
|
|
7
|
-
let
|
|
7
|
+
let AuthPresentationModule = class AuthPresentationModule {
|
|
8
8
|
};
|
|
9
|
-
exports.
|
|
10
|
-
exports.
|
|
9
|
+
exports.AuthPresentationModule = AuthPresentationModule;
|
|
10
|
+
exports.AuthPresentationModule = AuthPresentationModule = tslib_1.__decorate([
|
|
11
11
|
(0, common_1.Module)({
|
|
12
12
|
controllers: [auth_controller_1.AuthController],
|
|
13
13
|
})
|
|
14
|
-
],
|
|
14
|
+
], AuthPresentationModule);
|
|
15
15
|
//# sourceMappingURL=presentation.module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation.module.js","sourceRoot":"","sources":["../../../../../../libs/auth/nest/src/presentation/presentation.module.ts"],"names":[],"mappings":";;;;AAAA,2CAAwC;AACxC,mEAA+D;AAKxD,IAAM,
|
|
1
|
+
{"version":3,"file":"presentation.module.js","sourceRoot":"","sources":["../../../../../../libs/auth/nest/src/presentation/presentation.module.ts"],"names":[],"mappings":";;;;AAAA,2CAAwC;AACxC,mEAA+D;AAKxD,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;CAAG,CAAA;AAAzB,wDAAsB;iCAAtB,sBAAsB;IAHlC,IAAA,eAAM,EAAC;QACN,WAAW,EAAE,CAAC,gCAAc,CAAC;KAC9B,CAAC;GACW,sBAAsB,CAAG"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CreateInvalidatedTokensCacheTable1720200000000 = void 0;
|
|
4
|
-
const schema_1 = require("../schema");
|
|
5
|
-
class CreateInvalidatedTokensCacheTable1720200000000 {
|
|
6
|
-
constructor() {
|
|
7
|
-
this.name = 'CreateInvalidatedTokensCacheTable1720200000000';
|
|
8
|
-
}
|
|
9
|
-
async up(queryRunner) {
|
|
10
|
-
await queryRunner.query(`CREATE SCHEMA IF NOT EXISTS "${schema_1.AUTH_SCHEMA}";`);
|
|
11
|
-
await queryRunner.query(`
|
|
12
|
-
CREATE UNLOGGED TABLE IF NOT EXISTS "${schema_1.AUTH_SCHEMA}"."invalidated_tokens" (
|
|
13
|
-
token_id varchar(128) PRIMARY KEY,
|
|
14
|
-
user_id uuid NULL,
|
|
15
|
-
expires_at timestamptz NOT NULL,
|
|
16
|
-
invalidated_at timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
17
|
-
);
|
|
18
|
-
`);
|
|
19
|
-
await queryRunner.query(`
|
|
20
|
-
CREATE INDEX IF NOT EXISTS invalidated_tokens_expires_at_idx
|
|
21
|
-
ON "${schema_1.AUTH_SCHEMA}"."invalidated_tokens" (expires_at);
|
|
22
|
-
`);
|
|
23
|
-
}
|
|
24
|
-
async down(queryRunner) {
|
|
25
|
-
await queryRunner.query(`DROP TABLE IF EXISTS "${schema_1.AUTH_SCHEMA}"."invalidated_tokens";`);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
exports.CreateInvalidatedTokensCacheTable1720200000000 = CreateInvalidatedTokensCacheTable1720200000000;
|
|
29
|
-
//# sourceMappingURL=1720200000000-create-invalidated-tokens-cache.table.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"1720200000000-create-invalidated-tokens-cache.table.js","sourceRoot":"","sources":["../../../../../../../libs/auth/nest/src/infrastructure-persistence/migrations/1720200000000-create-invalidated-tokens-cache.table.ts"],"names":[],"mappings":";;;AACA,sCAAwC;AAExC,MAAa,8CAA8C;IAA3D;QAGE,SAAI,GAAG,gDAAgD,CAAC;IAyB1D,CAAC;IAvBQ,KAAK,CAAC,EAAE,CAAC,WAAwB;QACtC,MAAM,WAAW,CAAC,KAAK,CAAC,gCAAgC,oBAAW,IAAI,CAAC,CAAC;QAEzE,MAAM,WAAW,CAAC,KAAK,CAAC;6CACiB,oBAAW;;;;;;KAMnD,CAAC,CAAC;QAEH,MAAM,WAAW,CAAC,KAAK,CAAC;;cAEd,oBAAW;KACpB,CAAC,CAAC;IACL,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,WAAwB;QACxC,MAAM,WAAW,CAAC,KAAK,CACrB,yBAAyB,oBAAW,yBAAyB,CAC9D,CAAC;IACJ,CAAC;CACF;AA5BD,wGA4BC"}
|