@anarchitects/auth-nest 0.4.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +75 -13
- package/package.json +4 -4
- package/src/application/application.module.d.ts +2 -5
- package/src/application/application.module.js +8 -12
- package/src/application/application.module.js.map +1 -1
- package/src/auth.module.d.ts +14 -0
- package/src/auth.module.js +44 -0
- package/src/auth.module.js.map +1 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -0
- package/src/index.js.map +1 -1
- package/src/infrastructure-mailer/adapters/node-mailer.adapter.d.ts +1 -8
- package/src/infrastructure-mailer/adapters/node-mailer.adapter.js +2 -19
- package/src/infrastructure-mailer/adapters/node-mailer.adapter.js.map +1 -1
- package/src/infrastructure-mailer/index.d.ts +0 -1
- package/src/infrastructure-mailer/index.js +0 -1
- package/src/infrastructure-mailer/index.js.map +1 -1
- package/src/infrastructure-mailer/mailer.module.js +4 -10
- package/src/infrastructure-mailer/mailer.module.js.map +1 -1
- package/src/infrastructure-persistence/persistence.module.d.ts +0 -2
- package/src/infrastructure-persistence/persistence.module.js +1 -7
- package/src/infrastructure-persistence/persistence.module.js.map +1 -1
- package/src/infrastructure-mailer/adapters/mailer.adapter.d.ts +0 -4
- package/src/infrastructure-mailer/adapters/mailer.adapter.js +0 -7
- package/src/infrastructure-mailer/adapters/mailer.adapter.js.map +0 -1
package/README.md
CHANGED
|
@@ -7,15 +7,15 @@ NestJS services, controllers, and infrastructure for the Anarchitecture authenti
|
|
|
7
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
8
|
- **Presentation layer** – `AuthController` exposing REST handlers for the full auth lifecycle, `PoliciesGuard` and `@Policies()` decorator for route-level authorization.
|
|
9
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** – `
|
|
10
|
+
- **Infrastructure mailer** – `AuthMailerModule` wrapper over shared `CommonNodeMailerModule`; `NodeMailerAdapter` is re-exported for compatibility.
|
|
11
11
|
- **Config** – Typed `authConfig` namespace using `@nestjs/config` with an `InjectAuthConfig()` helper decorator.
|
|
12
12
|
|
|
13
13
|
## Installation
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
|
-
npm install @anarchitects/auth-nest
|
|
16
|
+
npm install @anarchitects/auth-nest @anarchitects/common-nest-mailer
|
|
17
17
|
# or
|
|
18
|
-
yarn add @anarchitects/auth-nest
|
|
18
|
+
yarn add @anarchitects/auth-nest @anarchitects/common-nest-mailer
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
Peer requirements:
|
|
@@ -25,14 +25,15 @@ Peer requirements:
|
|
|
25
25
|
- `@casl/ability` for RBAC policy evaluation
|
|
26
26
|
- `@nestjs-modules/mailer` (when using the mailer module)
|
|
27
27
|
|
|
28
|
-
##
|
|
28
|
+
## Exports
|
|
29
29
|
|
|
30
30
|
| Import path | Contents |
|
|
31
31
|
| ---------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
32
|
+
| `@anarchitects/auth-nest` | `AuthModule.forRoot(...)`, plus re-exports of layered entry points for convenience |
|
|
32
33
|
| `@anarchitects/auth-nest/application` | `AuthApplicationModule`, `AuthService`, `JwtAuthService`, `HashService`, `BcryptHashService`, `PoliciesService`, `AbilityFactory`, `JwtStrategy` |
|
|
33
34
|
| `@anarchitects/auth-nest/presentation` | `AuthPresentationModule`, `AuthController`, `PoliciesGuard`, `@Policies()` decorator |
|
|
34
35
|
| `@anarchitects/auth-nest/infrastructure-persistence` | `AuthPersistenceModule`, `AuthUserRepository`, `TypeormAuthUserRepository`, migration |
|
|
35
|
-
| `@anarchitects/auth-nest/infrastructure-mailer` | `AuthMailerModule`, `
|
|
36
|
+
| `@anarchitects/auth-nest/infrastructure-mailer` | `AuthMailerModule`, `NodeMailerAdapter` |
|
|
36
37
|
| `@anarchitects/auth-nest/config` | `authConfig`, `AuthConfig` type, `InjectAuthConfig()` |
|
|
37
38
|
|
|
38
39
|
## Configuration
|
|
@@ -79,11 +80,60 @@ export class AppModule {}
|
|
|
79
80
|
|
|
80
81
|
## Usage
|
|
81
82
|
|
|
82
|
-
###
|
|
83
|
+
### Easy mode (single facade import)
|
|
83
84
|
|
|
84
85
|
```ts
|
|
85
86
|
import { Module } from '@nestjs/common';
|
|
86
87
|
import { ConfigModule } from '@nestjs/config';
|
|
88
|
+
import { CommonMailerModule, mailerConfig } from '@anarchitects/common-nest-mailer';
|
|
89
|
+
import { AuthModule } from '@anarchitects/auth-nest';
|
|
90
|
+
import { authConfig } from '@anarchitects/auth-nest/config';
|
|
91
|
+
|
|
92
|
+
@Module({
|
|
93
|
+
imports: [
|
|
94
|
+
ConfigModule.forRoot({
|
|
95
|
+
isGlobal: true,
|
|
96
|
+
load: [authConfig, mailerConfig],
|
|
97
|
+
}),
|
|
98
|
+
CommonMailerModule.forRootFromConfig(),
|
|
99
|
+
AuthModule.forRoot({
|
|
100
|
+
application: {
|
|
101
|
+
authStrategies: ['jwt'],
|
|
102
|
+
encryption: {
|
|
103
|
+
algorithm: 'bcrypt',
|
|
104
|
+
key: process.env.AUTH_ENCRYPTION_KEY!,
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
persistence: {
|
|
108
|
+
persistence: 'typeorm',
|
|
109
|
+
},
|
|
110
|
+
features: {
|
|
111
|
+
mailer: true,
|
|
112
|
+
},
|
|
113
|
+
}),
|
|
114
|
+
],
|
|
115
|
+
})
|
|
116
|
+
export class AuthApiModule {}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
`AuthModule.forRoot(...)` is the preferred integration path when you want a full auth stack with minimal host-module wiring.
|
|
120
|
+
|
|
121
|
+
Disable domain mailer wiring when not needed:
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
|
+
AuthModule.forRoot({
|
|
125
|
+
application: { ... },
|
|
126
|
+
persistence: { persistence: 'typeorm' },
|
|
127
|
+
features: { mailer: false },
|
|
128
|
+
});
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Layered composition (advanced)
|
|
132
|
+
|
|
133
|
+
```ts
|
|
134
|
+
import { Module } from '@nestjs/common';
|
|
135
|
+
import { ConfigModule } from '@nestjs/config';
|
|
136
|
+
import { CommonMailerModule, mailerConfig } from '@anarchitects/common-nest-mailer';
|
|
87
137
|
import { authConfig } from '@anarchitects/auth-nest/config';
|
|
88
138
|
import { AuthApplicationModule } from '@anarchitects/auth-nest/application';
|
|
89
139
|
import { AuthPersistenceModule } from '@anarchitects/auth-nest/infrastructure-persistence';
|
|
@@ -92,15 +142,19 @@ import { AuthMailerModule } from '@anarchitects/auth-nest/infrastructure-mailer'
|
|
|
92
142
|
|
|
93
143
|
@Module({
|
|
94
144
|
imports: [
|
|
95
|
-
ConfigModule.forRoot({
|
|
96
|
-
|
|
145
|
+
ConfigModule.forRoot({
|
|
146
|
+
isGlobal: true,
|
|
147
|
+
load: [authConfig, mailerConfig],
|
|
148
|
+
}),
|
|
149
|
+
CommonMailerModule.forRootFromConfig(),
|
|
150
|
+
AuthApplicationModule.forRoot({
|
|
97
151
|
authStrategies: ['jwt'],
|
|
98
152
|
encryption: {
|
|
99
153
|
algorithm: 'bcrypt',
|
|
100
154
|
key: process.env.AUTH_ENCRYPTION_KEY!,
|
|
101
155
|
},
|
|
102
156
|
}),
|
|
103
|
-
AuthPersistenceModule.
|
|
157
|
+
AuthPersistenceModule.forRoot({ persistence: 'typeorm' }),
|
|
104
158
|
AuthPresentationModule,
|
|
105
159
|
AuthMailerModule,
|
|
106
160
|
],
|
|
@@ -108,6 +162,17 @@ import { AuthMailerModule } from '@anarchitects/auth-nest/infrastructure-mailer'
|
|
|
108
162
|
export class AuthApiModule {}
|
|
109
163
|
```
|
|
110
164
|
|
|
165
|
+
Use layered composition when you need to replace or selectively compose infrastructure/application concerns.
|
|
166
|
+
|
|
167
|
+
## Mailer Migration Note
|
|
168
|
+
|
|
169
|
+
`AuthMailerModule` is now adapter-only. It wraps the shared `CommonNodeMailerModule` from
|
|
170
|
+
`@anarchitects/common-nest-mailer` and no longer configures transport with
|
|
171
|
+
`MailerModule.forRootAsync(...)`.
|
|
172
|
+
Configure transport once at app root with `CommonMailerModule` when `features.mailer` is enabled.
|
|
173
|
+
The shared mailer DI contract (`MailerPort`) and concrete `NodeMailerAdapter` now live in
|
|
174
|
+
`@anarchitects/common-nest-mailer`.
|
|
175
|
+
|
|
111
176
|
### Injecting services
|
|
112
177
|
|
|
113
178
|
```ts
|
|
@@ -131,10 +196,7 @@ export class AuthController {
|
|
|
131
196
|
```ts
|
|
132
197
|
import { TypeormAuthUserRepository } from '@anarchitects/auth-nest/infrastructure-persistence';
|
|
133
198
|
|
|
134
|
-
await authUserRepository.invalidateTokens(
|
|
135
|
-
[hashedAccessToken, hashedRefreshToken],
|
|
136
|
-
userId,
|
|
137
|
-
);
|
|
199
|
+
await authUserRepository.invalidateTokens([hashedAccessToken, hashedRefreshToken], userId);
|
|
138
200
|
```
|
|
139
201
|
|
|
140
202
|
### Route-level authorization with policies
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anarchitects/auth-nest",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"types": "./src/index.d.ts",
|
|
@@ -8,18 +8,18 @@
|
|
|
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": "1.0.0",
|
|
12
12
|
"bcrypt": "^6.0.0",
|
|
13
13
|
"@nestjs/passport": "^11.0.5",
|
|
14
14
|
"passport-jwt": "^4.0.1",
|
|
15
15
|
"@nestjs/config": "^4.0.2",
|
|
16
|
-
"@nestjs-modules/mailer": "^2.0.2",
|
|
17
16
|
"typeorm": "^0.3.27",
|
|
18
17
|
"uuidv7": "^1.0.2",
|
|
19
18
|
"@nestjs/typeorm": "^11.0.0",
|
|
20
19
|
"@nestjs/platform-fastify": "^11.1.6",
|
|
21
20
|
"@casl/ability": "^6.7.3",
|
|
22
|
-
"@nestjs/core": "^11.0.0"
|
|
21
|
+
"@nestjs/core": "^11.0.0",
|
|
22
|
+
"@anarchitects/common-nest-mailer": "1.0.0"
|
|
23
23
|
},
|
|
24
24
|
"publishConfig": {
|
|
25
25
|
"access": "public"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AuthConfig } from '../config';
|
|
2
1
|
import { ConfigurableModuleClass, OPTIONS_TYPE } from './application.module-definition';
|
|
2
|
+
import { AbilityFactory } from './factories/ability.factory';
|
|
3
3
|
import { AuthService } from './services/auth.service';
|
|
4
4
|
import { BcryptHashService } from './services/bcrypt-hash.service';
|
|
5
5
|
import { HashService } from './services/hash.service';
|
|
@@ -7,12 +7,9 @@ import { JwtAuthService } from './services/jwt-auth.service';
|
|
|
7
7
|
import { PoliciesService } from './services/policies.service';
|
|
8
8
|
import { JwtStrategy } from './strategies/jwt/strategy';
|
|
9
9
|
export declare class AuthApplicationModule extends ConfigurableModuleClass {
|
|
10
|
-
private options;
|
|
11
|
-
private authConfig;
|
|
12
|
-
constructor(options: string | symbol, authConfig: AuthConfig);
|
|
13
10
|
static forRoot(options: typeof OPTIONS_TYPE): {
|
|
14
11
|
imports: import("@nestjs/common").DynamicModule[];
|
|
15
|
-
providers: (typeof BcryptHashService | typeof JwtAuthService | typeof PoliciesService | typeof JwtStrategy | {
|
|
12
|
+
providers: (typeof AbilityFactory | typeof BcryptHashService | typeof JwtAuthService | typeof PoliciesService | typeof JwtStrategy | {
|
|
16
13
|
provide: typeof HashService;
|
|
17
14
|
useExisting: typeof BcryptHashService;
|
|
18
15
|
} | {
|
|
@@ -3,9 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.AuthApplicationModule = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const common_1 = require("@nestjs/common");
|
|
6
|
+
const config_1 = require("@nestjs/config");
|
|
6
7
|
const jwt_1 = require("@nestjs/jwt");
|
|
7
|
-
const
|
|
8
|
+
const config_2 = require("../config");
|
|
8
9
|
const application_module_definition_1 = require("./application.module-definition");
|
|
10
|
+
const ability_factory_1 = require("./factories/ability.factory");
|
|
9
11
|
const auth_service_1 = require("./services/auth.service");
|
|
10
12
|
const bcrypt_hash_service_1 = require("./services/bcrypt-hash.service");
|
|
11
13
|
const hash_service_1 = require("./services/hash.service");
|
|
@@ -13,17 +15,12 @@ const jwt_auth_service_1 = require("./services/jwt-auth.service");
|
|
|
13
15
|
const policies_service_1 = require("./services/policies.service");
|
|
14
16
|
const strategy_1 = require("./strategies/jwt/strategy");
|
|
15
17
|
let AuthApplicationModule = class AuthApplicationModule extends application_module_definition_1.ConfigurableModuleClass {
|
|
16
|
-
constructor(options, authConfig) {
|
|
17
|
-
super();
|
|
18
|
-
this.options = options;
|
|
19
|
-
this.authConfig = authConfig;
|
|
20
|
-
}
|
|
21
18
|
static forRoot(options) {
|
|
22
19
|
const { authStrategies, encryption } = options;
|
|
23
|
-
const imports = [];
|
|
20
|
+
const imports = [config_1.ConfigModule.forFeature(config_2.authConfig)];
|
|
24
21
|
const providers = [];
|
|
25
22
|
const exports = [];
|
|
26
|
-
providers.push(policies_service_1.PoliciesService);
|
|
23
|
+
providers.push(ability_factory_1.AbilityFactory, policies_service_1.PoliciesService);
|
|
27
24
|
switch (encryption.algorithm) {
|
|
28
25
|
case 'bcrypt':
|
|
29
26
|
providers.push(bcrypt_hash_service_1.BcryptHashService, {
|
|
@@ -40,6 +37,8 @@ let AuthApplicationModule = class AuthApplicationModule extends application_modu
|
|
|
40
37
|
}
|
|
41
38
|
if (authStrategies.includes('jwt')) {
|
|
42
39
|
imports.push(jwt_1.JwtModule.registerAsync({
|
|
40
|
+
imports: [config_1.ConfigModule.forFeature(config_2.authConfig)],
|
|
41
|
+
inject: [config_2.authConfig.KEY],
|
|
43
42
|
useFactory: (authConfig) => ({
|
|
44
43
|
secret: authConfig.jwtSecret,
|
|
45
44
|
signOptions: {
|
|
@@ -65,9 +64,6 @@ let AuthApplicationModule = class AuthApplicationModule extends application_modu
|
|
|
65
64
|
};
|
|
66
65
|
exports.AuthApplicationModule = AuthApplicationModule;
|
|
67
66
|
exports.AuthApplicationModule = AuthApplicationModule = tslib_1.__decorate([
|
|
68
|
-
(0, common_1.Module)({})
|
|
69
|
-
tslib_1.__param(0, (0, common_1.Inject)(application_module_definition_1.AUTH_APPLICATION_MODULE_OPTIONS)),
|
|
70
|
-
tslib_1.__param(1, (0, config_1.InjectAuthConfig)()),
|
|
71
|
-
tslib_1.__metadata("design:paramtypes", [Object, Object])
|
|
67
|
+
(0, common_1.Module)({})
|
|
72
68
|
], AuthApplicationModule);
|
|
73
69
|
//# 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,
|
|
1
|
+
{"version":3,"file":"application.module.js","sourceRoot":"","sources":["../../../../../../libs/auth/nest/src/application/application.module.ts"],"names":[],"mappings":";;;;AAAA,2CAAwC;AACxC,2CAA8C;AAC9C,qCAAwC;AACxC,sCAAmD;AACnD,mFAGyC;AACzC,iEAA6D;AAC7D,0DAAsD;AACtD,wEAAmE;AACnE,0DAAsD;AACtD,kEAA6D;AAC7D,kEAA8D;AAC9D,wDAAwD;AAGjD,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,uDAAuB;IAChE,MAAM,CAAC,OAAO,CAAC,OAA4B;QACzC,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;QAC/C,MAAM,OAAO,GAAG,CAAC,qBAAY,CAAC,UAAU,CAAC,mBAAU,CAAC,CAAC,CAAC;QACtD,MAAM,SAAS,GAAG,EAAE,CAAC;QACrB,MAAM,OAAO,GAAG,EAAE,CAAC;QACnB,SAAS,CAAC,IAAI,CAAC,gCAAc,EAAE,kCAAe,CAAC,CAAC;QAChD,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,OAAO,EAAE,CAAC,qBAAY,CAAC,UAAU,CAAC,mBAAU,CAAC,CAAC;gBAC9C,MAAM,EAAE,CAAC,mBAAU,CAAC,GAAG,CAAC;gBACxB,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;AAnDY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,qBAAqB,CAmDjC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DynamicModule } from '@nestjs/common';
|
|
2
|
+
import { AuthApplicationModule } from './application';
|
|
3
|
+
import { AuthPersistenceModule } from './infrastructure-persistence';
|
|
4
|
+
export type AuthModuleFeatures = {
|
|
5
|
+
mailer?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export type AuthModuleOptions = {
|
|
8
|
+
application: Parameters<typeof AuthApplicationModule.forRoot>[0];
|
|
9
|
+
persistence: Parameters<typeof AuthPersistenceModule.forRoot>[0];
|
|
10
|
+
features?: AuthModuleFeatures;
|
|
11
|
+
};
|
|
12
|
+
export declare class AuthModule {
|
|
13
|
+
static forRoot(options: AuthModuleOptions): DynamicModule;
|
|
14
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var AuthModule_1;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.AuthModule = void 0;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const common_1 = require("@nestjs/common");
|
|
7
|
+
const config_1 = require("@nestjs/config");
|
|
8
|
+
const application_1 = require("./application");
|
|
9
|
+
const config_2 = require("./config");
|
|
10
|
+
const infrastructure_mailer_1 = require("./infrastructure-mailer");
|
|
11
|
+
const infrastructure_persistence_1 = require("./infrastructure-persistence");
|
|
12
|
+
const presentation_1 = require("./presentation");
|
|
13
|
+
let AuthModule = AuthModule_1 = class AuthModule {
|
|
14
|
+
static forRoot(options) {
|
|
15
|
+
const mailerEnabled = options.features?.mailer ?? true;
|
|
16
|
+
const applicationModule = application_1.AuthApplicationModule.forRoot(options.application);
|
|
17
|
+
const persistenceModule = infrastructure_persistence_1.AuthPersistenceModule.forRoot(options.persistence);
|
|
18
|
+
const imports = [
|
|
19
|
+
config_1.ConfigModule.forFeature(config_2.authConfig),
|
|
20
|
+
applicationModule,
|
|
21
|
+
persistenceModule,
|
|
22
|
+
presentation_1.AuthPresentationModule,
|
|
23
|
+
];
|
|
24
|
+
const exports = [
|
|
25
|
+
applicationModule,
|
|
26
|
+
persistenceModule,
|
|
27
|
+
presentation_1.AuthPresentationModule,
|
|
28
|
+
];
|
|
29
|
+
if (mailerEnabled) {
|
|
30
|
+
imports.push(infrastructure_mailer_1.AuthMailerModule);
|
|
31
|
+
exports.push(infrastructure_mailer_1.AuthMailerModule);
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
module: AuthModule_1,
|
|
35
|
+
imports,
|
|
36
|
+
exports,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
exports.AuthModule = AuthModule;
|
|
41
|
+
exports.AuthModule = AuthModule = AuthModule_1 = tslib_1.__decorate([
|
|
42
|
+
(0, common_1.Module)({})
|
|
43
|
+
], AuthModule);
|
|
44
|
+
//# sourceMappingURL=auth.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.module.js","sourceRoot":"","sources":["../../../../../libs/auth/nest/src/auth.module.ts"],"names":[],"mappings":";;;;;AAAA,2CAAuD;AACvD,2CAA8C;AAC9C,+CAAsD;AACtD,qCAAsC;AACtC,mEAA2D;AAC3D,6EAAqE;AACrE,iDAAwD;AAajD,IAAM,UAAU,kBAAhB,MAAM,UAAU;IACrB,MAAM,CAAC,OAAO,CAAC,OAA0B;QACvC,MAAM,aAAa,GAAG,OAAO,CAAC,QAAQ,EAAE,MAAM,IAAI,IAAI,CAAC;QACvD,MAAM,iBAAiB,GAAG,mCAAqB,CAAC,OAAO,CACrD,OAAO,CAAC,WAAW,CACpB,CAAC;QACF,MAAM,iBAAiB,GAAG,kDAAqB,CAAC,OAAO,CACrD,OAAO,CAAC,WAAW,CACpB,CAAC;QACF,MAAM,OAAO,GAAG;YACd,qBAAY,CAAC,UAAU,CAAC,mBAAU,CAAC;YACnC,iBAAiB;YACjB,iBAAiB;YACjB,qCAAsB;SACvB,CAAC;QACF,MAAM,OAAO,GAAG;YACd,iBAAiB;YACjB,iBAAiB;YACjB,qCAAsB;SACvB,CAAC;QAEF,IAAI,aAAa,EAAE,CAAC;YAClB,OAAO,CAAC,IAAI,CAAC,wCAAgB,CAAC,CAAC;YAC/B,OAAO,CAAC,IAAI,CAAC,wCAAgB,CAAC,CAAC;QACjC,CAAC;QAED,OAAO;YACL,MAAM,EAAE,YAAU;YAClB,OAAO;YACP,OAAO;SACR,CAAC;IACJ,CAAC;CACF,CAAA;AAhCY,gCAAU;qBAAV,UAAU;IADtB,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,UAAU,CAgCtB"}
|
package/src/index.d.ts
CHANGED
package/src/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./auth.module"), exports);
|
|
4
5
|
tslib_1.__exportStar(require("./application"), exports);
|
|
5
6
|
tslib_1.__exportStar(require("./presentation"), exports);
|
|
6
7
|
tslib_1.__exportStar(require("./infrastructure-persistence"), exports);
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/auth/nest/src/index.ts"],"names":[],"mappings":";;;AAAA,wDAA8B;AAC9B,yDAA+B;AAC/B,uEAA6C;AAC7C,kEAAwC;AACxC,mDAAyB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/auth/nest/src/index.ts"],"names":[],"mappings":";;;AAAA,wDAA8B;AAC9B,wDAA8B;AAC9B,yDAA+B;AAC/B,uEAA6C;AAC7C,kEAAwC;AACxC,mDAAyB"}
|
|
@@ -1,8 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { MailerAdapter } from './mailer.adapter';
|
|
3
|
-
export declare class NodeMailerAdapter implements MailerAdapter {
|
|
4
|
-
private readonly mailer;
|
|
5
|
-
constructor(mailer: MailerService);
|
|
6
|
-
send(to: string, subject: string, html: string): Promise<SentMessageInfo>;
|
|
7
|
-
sendTemplate(to: string, subject: string, template: string, context?: Record<string, unknown>): Promise<SentMessageInfo>;
|
|
8
|
-
}
|
|
1
|
+
export { NodeMailerAdapter } from '@anarchitects/common-nest-mailer';
|
|
@@ -1,23 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NodeMailerAdapter = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const mailer_1 = require("@nestjs-modules/mailer");
|
|
7
|
-
let NodeMailerAdapter = class NodeMailerAdapter {
|
|
8
|
-
constructor(mailer) {
|
|
9
|
-
this.mailer = mailer;
|
|
10
|
-
}
|
|
11
|
-
async send(to, subject, html) {
|
|
12
|
-
return await this.mailer.sendMail({ to, subject, html });
|
|
13
|
-
}
|
|
14
|
-
async sendTemplate(to, subject, template, context) {
|
|
15
|
-
return await this.mailer.sendMail({ to, subject, template, context });
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
exports.NodeMailerAdapter = NodeMailerAdapter;
|
|
19
|
-
exports.NodeMailerAdapter = NodeMailerAdapter = tslib_1.__decorate([
|
|
20
|
-
(0, common_1.Injectable)(),
|
|
21
|
-
tslib_1.__metadata("design:paramtypes", [mailer_1.MailerService])
|
|
22
|
-
], NodeMailerAdapter);
|
|
4
|
+
var common_nest_mailer_1 = require("@anarchitects/common-nest-mailer");
|
|
5
|
+
Object.defineProperty(exports, "NodeMailerAdapter", { enumerable: true, get: function () { return common_nest_mailer_1.NodeMailerAdapter; } });
|
|
23
6
|
//# sourceMappingURL=node-mailer.adapter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-mailer.adapter.js","sourceRoot":"","sources":["../../../../../../../libs/auth/nest/src/infrastructure-mailer/adapters/node-mailer.adapter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"node-mailer.adapter.js","sourceRoot":"","sources":["../../../../../../../libs/auth/nest/src/infrastructure-mailer/adapters/node-mailer.adapter.ts"],"names":[],"mappings":";;;AAAA,uEAAqE;AAA5D,uHAAA,iBAAiB,OAAA"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./adapters/mailer.adapter"), exports);
|
|
5
4
|
tslib_1.__exportStar(require("./adapters/node-mailer.adapter"), exports);
|
|
6
5
|
tslib_1.__exportStar(require("./mailer.module"), exports);
|
|
7
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../libs/auth/nest/src/infrastructure-mailer/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../libs/auth/nest/src/infrastructure-mailer/index.ts"],"names":[],"mappings":";;;AAAA,yEAA+C;AAC/C,0DAAgC"}
|
|
@@ -3,21 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.AuthMailerModule = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const common_1 = require("@nestjs/common");
|
|
6
|
-
const
|
|
7
|
-
const node_mailer_adapter_1 = require("./adapters/node-mailer.adapter");
|
|
6
|
+
const common_nest_mailer_1 = require("@anarchitects/common-nest-mailer");
|
|
8
7
|
let AuthMailerModule = class AuthMailerModule {
|
|
9
8
|
};
|
|
10
9
|
exports.AuthMailerModule = AuthMailerModule;
|
|
11
10
|
exports.AuthMailerModule = AuthMailerModule = tslib_1.__decorate([
|
|
11
|
+
(0, common_1.Global)(),
|
|
12
12
|
(0, common_1.Module)({
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
{
|
|
16
|
-
provide: mailer_adapter_1.MailerAdapter,
|
|
17
|
-
useExisting: node_mailer_adapter_1.NodeMailerAdapter,
|
|
18
|
-
},
|
|
19
|
-
],
|
|
20
|
-
exports: [mailer_adapter_1.MailerAdapter],
|
|
13
|
+
imports: [common_nest_mailer_1.CommonNodeMailerModule],
|
|
14
|
+
exports: [common_nest_mailer_1.CommonNodeMailerModule],
|
|
21
15
|
})
|
|
22
16
|
], AuthMailerModule);
|
|
23
17
|
//# 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,
|
|
1
|
+
{"version":3,"file":"mailer.module.js","sourceRoot":"","sources":["../../../../../../libs/auth/nest/src/infrastructure-mailer/mailer.module.ts"],"names":[],"mappings":";;;;AAAA,2CAAgD;AAChD,yEAA0E;AAOnE,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;CAAG,CAAA;AAAnB,4CAAgB;2BAAhB,gBAAgB;IAL5B,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,2CAAsB,CAAC;QACjC,OAAO,EAAE,CAAC,2CAAsB,CAAC;KAClC,CAAC;GACW,gBAAgB,CAAG"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { DynamicModule } from '@nestjs/common';
|
|
2
2
|
import { ConfigurableModuleClass, OPTIONS_TYPE } from './persistence.module-definition';
|
|
3
3
|
export declare class AuthPersistenceModule extends ConfigurableModuleClass {
|
|
4
|
-
private options;
|
|
5
|
-
constructor(options: string | symbol);
|
|
6
4
|
static forRoot(options: typeof OPTIONS_TYPE): DynamicModule;
|
|
7
5
|
}
|
|
@@ -12,10 +12,6 @@ const persistence_module_definition_1 = require("./persistence.module-definition
|
|
|
12
12
|
const auth_user_repository_1 = require("./repositories/auth-user.repository");
|
|
13
13
|
const typeorm_auth_user_repository_1 = require("./repositories/typeorm-auth-user.repository");
|
|
14
14
|
let AuthPersistenceModule = class AuthPersistenceModule extends persistence_module_definition_1.ConfigurableModuleClass {
|
|
15
|
-
constructor(options) {
|
|
16
|
-
super();
|
|
17
|
-
this.options = options;
|
|
18
|
-
}
|
|
19
15
|
static forRoot(options) {
|
|
20
16
|
switch (options.persistence) {
|
|
21
17
|
case 'typeorm':
|
|
@@ -45,8 +41,6 @@ let AuthPersistenceModule = class AuthPersistenceModule extends persistence_modu
|
|
|
45
41
|
};
|
|
46
42
|
exports.AuthPersistenceModule = AuthPersistenceModule;
|
|
47
43
|
exports.AuthPersistenceModule = AuthPersistenceModule = tslib_1.__decorate([
|
|
48
|
-
(0, common_1.Module)({})
|
|
49
|
-
tslib_1.__param(0, (0, common_1.Inject)(persistence_module_definition_1.AUTH_PERSISTENCE_MODULE_OPTIONS)),
|
|
50
|
-
tslib_1.__metadata("design:paramtypes", [Object])
|
|
44
|
+
(0, common_1.Module)({})
|
|
51
45
|
], AuthPersistenceModule);
|
|
52
46
|
//# 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,
|
|
1
|
+
{"version":3,"file":"persistence.module.js","sourceRoot":"","sources":["../../../../../../libs/auth/nest/src/infrastructure-persistence/persistence.module.ts"],"names":[],"mappings":";;;;AAAA,2CAAuD;AACvD,6CAAgD;AAChD,kFAA6E;AAC7E,oEAAgE;AAChE,wDAAoD;AACpD,wDAAoD;AACpD,mFAGyC;AACzC,8EAAyE;AACzE,8FAAwF;AAGjF,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,uDAAuB;IAChE,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;AA3BY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,qBAAqB,CA2BjC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mailer.adapter.js","sourceRoot":"","sources":["../../../../../../../libs/auth/nest/src/infrastructure-mailer/adapters/mailer.adapter.ts"],"names":[],"mappings":";;;AAAA,MAAsB,aAAa;CAQlC;AARD,sCAQC"}
|