@anarchitects/auth-nest 1.0.0 → 3.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.
Files changed (34) hide show
  1. package/README.md +40 -22
  2. package/package.json +3 -3
  3. package/src/application/application.module-definition.d.ts +4 -21
  4. package/src/application/application.module-definition.js.map +1 -1
  5. package/src/application/application.module.d.ts +5 -22
  6. package/src/application/application.module.js +31 -4
  7. package/src/application/application.module.js.map +1 -1
  8. package/src/application/index.d.ts +1 -0
  9. package/src/auth.module.d.ts +4 -11
  10. package/src/auth.module.js +40 -24
  11. package/src/auth.module.js.map +1 -1
  12. package/src/config/auth.config.d.ts +16 -0
  13. package/src/config/auth.config.js +44 -7
  14. package/src/config/auth.config.js.map +1 -1
  15. package/src/config/index.d.ts +1 -0
  16. package/src/config/index.js +1 -0
  17. package/src/config/index.js.map +1 -1
  18. package/src/config/module-options.d.ts +57 -0
  19. package/src/config/module-options.js +58 -0
  20. package/src/config/module-options.js.map +1 -0
  21. package/src/infrastructure-mailer/index.d.ts +1 -0
  22. package/src/infrastructure-mailer/mailer.module.d.ts +4 -0
  23. package/src/infrastructure-mailer/mailer.module.js +31 -6
  24. package/src/infrastructure-mailer/mailer.module.js.map +1 -1
  25. package/src/infrastructure-persistence/index.d.ts +1 -0
  26. package/src/infrastructure-persistence/persistence.module-definition.d.ts +4 -9
  27. package/src/infrastructure-persistence/persistence.module-definition.js.map +1 -1
  28. package/src/infrastructure-persistence/persistence.module.d.ts +4 -2
  29. package/src/infrastructure-persistence/persistence.module.js +21 -4
  30. package/src/infrastructure-persistence/persistence.module.js.map +1 -1
  31. package/src/presentation/index.d.ts +1 -0
  32. package/src/presentation/presentation.module.d.ts +4 -0
  33. package/src/presentation/presentation.module.js +39 -2
  34. package/src/presentation/presentation.module.js.map +1 -1
package/README.md CHANGED
@@ -7,7 +7,7 @@ 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** – `AuthMailerModule` wrapper over shared `CommonNodeMailerModule`; `NodeMailerAdapter` is re-exported for compatibility.
10
+ - **Infrastructure mailer** – `AuthMailerModule` wrapper over shared `CommonMailerModule.forRoot(...)` provider wiring; `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
@@ -29,7 +29,7 @@ Peer requirements:
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
+ | `@anarchitects/auth-nest` | `AuthModule.forRoot(...)`, `AuthModule.forRootFromConfig(...)`, plus re-exports of layered entry points for convenience |
33
33
  | `@anarchitects/auth-nest/application` | `AuthApplicationModule`, `AuthService`, `JwtAuthService`, `HashService`, `BcryptHashService`, `PoliciesService`, `AbilityFactory`, `JwtStrategy` |
34
34
  | `@anarchitects/auth-nest/presentation` | `AuthPresentationModule`, `AuthController`, `PoliciesGuard`, `@Policies()` decorator |
35
35
  | `@anarchitects/auth-nest/infrastructure-persistence` | `AuthPersistenceModule`, `AuthUserRepository`, `TypeormAuthUserRepository`, migration |
@@ -48,6 +48,9 @@ The library reads configuration through `@nestjs/config` using a namespaced `aut
48
48
  | `AUTH_JWT_ISSUER` | Expected `iss` claim in the JWT. | `your_issuer` |
49
49
  | `AUTH_ENCRYPTION_ALGORITHM` | Password hashing algorithm (`bcrypt`). | `bcrypt` |
50
50
  | `AUTH_ENCRYPTION_KEY` | Symmetric key for additional encryption needs. **Must** be overridden in production. | `default_encryption_key` |
51
+ | `AUTH_PERSISTENCE` | Persistence adapter key used by `forRootFromConfig(...)`. | `typeorm` |
52
+ | `AUTH_MAILER_PROVIDER` | Domain mailer provider for `forRootFromConfig(...)` (`node` or `noop`). | `node` |
53
+ | `AUTH_STRATEGIES` | Comma-separated auth strategies for config-driven module composition. | `jwt` |
51
54
 
52
55
  > **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.
53
56
 
@@ -97,18 +100,20 @@ import { authConfig } from '@anarchitects/auth-nest/config';
97
100
  }),
98
101
  CommonMailerModule.forRootFromConfig(),
99
102
  AuthModule.forRoot({
100
- application: {
101
- authStrategies: ['jwt'],
102
- encryption: {
103
- algorithm: 'bcrypt',
104
- key: process.env.AUTH_ENCRYPTION_KEY!,
103
+ presentation: {
104
+ application: {
105
+ authStrategies: ['jwt'],
106
+ encryption: {
107
+ algorithm: 'bcrypt',
108
+ key: process.env.AUTH_ENCRYPTION_KEY!,
109
+ },
110
+ persistence: {
111
+ persistence: 'typeorm',
112
+ },
105
113
  },
106
114
  },
107
- persistence: {
108
- persistence: 'typeorm',
109
- },
110
- features: {
111
- mailer: true,
115
+ mailer: {
116
+ provider: 'node',
112
117
  },
113
118
  }),
114
119
  ],
@@ -118,13 +123,15 @@ export class AuthApiModule {}
118
123
 
119
124
  `AuthModule.forRoot(...)` is the preferred integration path when you want a full auth stack with minimal host-module wiring.
120
125
 
126
+ Use `AuthModule.forRootFromConfig()` when you want module composition fully driven by `AUTH_*`
127
+ variables exposed via `authConfig`.
128
+
121
129
  Disable domain mailer wiring when not needed:
122
130
 
123
131
  ```ts
124
132
  AuthModule.forRoot({
125
- application: { ... },
126
- persistence: { persistence: 'typeorm' },
127
- features: { mailer: false },
133
+ presentation: { application: { ... } },
134
+ mailer: { provider: 'noop' },
128
135
  });
129
136
  ```
130
137
 
@@ -136,7 +143,6 @@ import { ConfigModule } from '@nestjs/config';
136
143
  import { CommonMailerModule, mailerConfig } from '@anarchitects/common-nest-mailer';
137
144
  import { authConfig } from '@anarchitects/auth-nest/config';
138
145
  import { AuthApplicationModule } from '@anarchitects/auth-nest/application';
139
- import { AuthPersistenceModule } from '@anarchitects/auth-nest/infrastructure-persistence';
140
146
  import { AuthPresentationModule } from '@anarchitects/auth-nest/presentation';
141
147
  import { AuthMailerModule } from '@anarchitects/auth-nest/infrastructure-mailer';
142
148
 
@@ -153,10 +159,21 @@ import { AuthMailerModule } from '@anarchitects/auth-nest/infrastructure-mailer'
153
159
  algorithm: 'bcrypt',
154
160
  key: process.env.AUTH_ENCRYPTION_KEY!,
155
161
  },
162
+ persistence: { persistence: 'typeorm' },
163
+ }),
164
+ AuthPresentationModule.forRoot({
165
+ application: {
166
+ authStrategies: ['jwt'],
167
+ encryption: {
168
+ algorithm: 'bcrypt',
169
+ key: process.env.AUTH_ENCRYPTION_KEY!,
170
+ },
171
+ persistence: { persistence: 'typeorm' },
172
+ },
173
+ }),
174
+ AuthMailerModule.forRoot({
175
+ provider: 'node',
156
176
  }),
157
- AuthPersistenceModule.forRoot({ persistence: 'typeorm' }),
158
- AuthPresentationModule,
159
- AuthMailerModule,
160
177
  ],
161
178
  })
162
179
  export class AuthApiModule {}
@@ -166,10 +183,11 @@ Use layered composition when you need to replace or selectively compose infrastr
166
183
 
167
184
  ## Mailer Migration Note
168
185
 
169
- `AuthMailerModule` is now adapter-only. It wraps the shared `CommonNodeMailerModule` from
170
- `@anarchitects/common-nest-mailer` and no longer configures transport with
186
+ `AuthMailerModule` is now adapter-only. It wraps shared `CommonMailerModule.forRoot(...)`
187
+ provider wiring from `@anarchitects/common-nest-mailer` and no longer configures transport with
171
188
  `MailerModule.forRootAsync(...)`.
172
- Configure transport once at app root with `CommonMailerModule` when `features.mailer` is enabled.
189
+ Configure transport once at app root with `CommonMailerModule`.
190
+ Set `mailer.provider: 'noop'` to disable active delivery behavior per domain.
173
191
  The shared mailer DI contract (`MailerPort`) and concrete `NodeMailerAdapter` now live in
174
192
  `@anarchitects/common-nest-mailer`.
175
193
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anarchitects/auth-nest",
3
- "version": "1.0.0",
3
+ "version": "3.0.0",
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": "1.0.0",
11
+ "@anarchitects/auth-ts": "2.0.0",
12
12
  "bcrypt": "^6.0.0",
13
13
  "@nestjs/passport": "^11.0.5",
14
14
  "passport-jwt": "^4.0.1",
@@ -19,7 +19,7 @@
19
19
  "@nestjs/platform-fastify": "^11.1.6",
20
20
  "@casl/ability": "^6.7.3",
21
21
  "@nestjs/core": "^11.0.0",
22
- "@anarchitects/common-nest-mailer": "1.0.0"
22
+ "@anarchitects/common-nest-mailer": "2.0.0"
23
23
  },
24
24
  "publishConfig": {
25
25
  "access": "public"
@@ -1,25 +1,8 @@
1
- export declare const ConfigurableModuleClass: import("@nestjs/common").ConfigurableModuleCls<{
2
- authStrategies: string[];
3
- encryption: {
4
- algorithm: "bcrypt" | "argon2";
5
- key: string;
6
- };
7
- }, "forRoot", "create", {
1
+ import type { ResolvedAuthApplicationModuleOptions } from '../config';
2
+ export declare const ConfigurableModuleClass: import("@nestjs/common").ConfigurableModuleCls<ResolvedAuthApplicationModuleOptions, "forRoot", "create", {
8
3
  isGlobal?: boolean;
9
- }>, AUTH_APPLICATION_MODULE_OPTIONS: string | symbol, OPTIONS_TYPE: {
10
- authStrategies: string[];
11
- encryption: {
12
- algorithm: "bcrypt" | "argon2";
13
- key: string;
14
- };
15
- } & Partial<{
4
+ }>, AUTH_APPLICATION_MODULE_OPTIONS: string | symbol, OPTIONS_TYPE: ResolvedAuthApplicationModuleOptions & Partial<{
16
5
  isGlobal?: boolean;
17
- }>, ASYNC_OPTIONS_TYPE: import("@nestjs/common").ConfigurableModuleAsyncOptions<{
18
- authStrategies: string[];
19
- encryption: {
20
- algorithm: "bcrypt" | "argon2";
21
- key: string;
22
- };
23
- }, "create"> & Partial<{
6
+ }>, ASYNC_OPTIONS_TYPE: import("@nestjs/common").ConfigurableModuleAsyncOptions<ResolvedAuthApplicationModuleOptions, "create"> & Partial<{
24
7
  isGlobal?: boolean;
25
8
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"application.module-definition.js","sourceRoot":"","sources":["../../../../../../libs/auth/nest/src/application/application.module-definition.ts"],"names":[],"mappings":";;;;AAAA,2CAA2D;AAE9C,KAKT,IAAI,kCAAyB,EAG7B;KACD,kBAAkB,CAAC,SAAS,CAAC;KAC7B,SAAS,CACR,EAAE,QAAQ,EAAE,IAAI,EAAE,EAClB,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;IACvB,GAAG,UAAU;IACb,MAAM,EAAE,MAAM,CAAC,QAAQ,IAAI,KAAK;CACjC,CAAC,CACH;KACA,KAAK,EAAE,EAhBR,+BAAuB,+BACD,uCAA+B,4BACrD,oBAAY,oBACZ,0BAAkB,yBAaT"}
1
+ {"version":3,"file":"application.module-definition.js","sourceRoot":"","sources":["../../../../../../libs/auth/nest/src/application/application.module-definition.ts"],"names":[],"mappings":";;;;AAAA,2CAA2D;AAG9C,KAKT,IAAI,kCAAyB,EAAwC;KACtE,kBAAkB,CAAC,SAAS,CAAC;KAC7B,SAAS,CACR,EAAE,QAAQ,EAAE,IAAI,EAAE,EAClB,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;IACvB,GAAG,UAAU;IACb,MAAM,EAAE,MAAM,CAAC,QAAQ,IAAI,KAAK;CACjC,CAAC,CACH;KACA,KAAK,EAAE,EAbR,+BAAuB,+BACD,uCAA+B,4BACrD,oBAAY,oBACZ,0BAAkB,yBAUT"}
@@ -1,24 +1,7 @@
1
- import { ConfigurableModuleClass, OPTIONS_TYPE } from './application.module-definition';
2
- import { AbilityFactory } from './factories/ability.factory';
3
- import { AuthService } from './services/auth.service';
4
- import { BcryptHashService } from './services/bcrypt-hash.service';
5
- import { HashService } from './services/hash.service';
6
- import { JwtAuthService } from './services/jwt-auth.service';
7
- import { PoliciesService } from './services/policies.service';
8
- import { JwtStrategy } from './strategies/jwt/strategy';
1
+ import { DynamicModule } from '@nestjs/common';
2
+ import { ConfigurableModuleClass } from './application.module-definition';
3
+ import type { AuthApplicationModuleOptions } from '../config';
9
4
  export declare class AuthApplicationModule extends ConfigurableModuleClass {
10
- static forRoot(options: typeof OPTIONS_TYPE): {
11
- imports: import("@nestjs/common").DynamicModule[];
12
- providers: (typeof AbilityFactory | typeof BcryptHashService | typeof JwtAuthService | typeof PoliciesService | typeof JwtStrategy | {
13
- provide: typeof HashService;
14
- useExisting: typeof BcryptHashService;
15
- } | {
16
- provide: typeof AuthService;
17
- useExisting: typeof JwtAuthService;
18
- })[];
19
- exports: (typeof AuthService | typeof HashService)[];
20
- module: import("@nestjs/common").Type<any>;
21
- global?: boolean;
22
- controllers?: import("@nestjs/common").Type<any>[];
23
- };
5
+ static forRoot(options?: AuthApplicationModuleOptions): DynamicModule;
6
+ static forRootFromConfig(overrides?: AuthApplicationModuleOptions): DynamicModule;
24
7
  }
@@ -14,10 +14,15 @@ const hash_service_1 = require("./services/hash.service");
14
14
  const jwt_auth_service_1 = require("./services/jwt-auth.service");
15
15
  const policies_service_1 = require("./services/policies.service");
16
16
  const strategy_1 = require("./strategies/jwt/strategy");
17
+ const infrastructure_persistence_1 = require("../infrastructure-persistence");
17
18
  let AuthApplicationModule = class AuthApplicationModule extends application_module_definition_1.ConfigurableModuleClass {
18
- static forRoot(options) {
19
- const { authStrategies, encryption } = options;
20
- const imports = [config_1.ConfigModule.forFeature(config_2.authConfig)];
19
+ static forRoot(options = {}) {
20
+ const resolvedOptions = (0, config_2.resolveAuthApplicationModuleOptions)(options);
21
+ const { authStrategies, encryption, persistence } = resolvedOptions;
22
+ const imports = [
23
+ config_1.ConfigModule.forFeature(config_2.authConfig),
24
+ infrastructure_persistence_1.AuthPersistenceModule.forRoot(persistence),
25
+ ];
21
26
  const providers = [];
22
27
  const exports = [];
23
28
  providers.push(ability_factory_1.AbilityFactory, policies_service_1.PoliciesService);
@@ -55,12 +60,34 @@ let AuthApplicationModule = class AuthApplicationModule extends application_modu
55
60
  exports.push(auth_service_1.AuthService);
56
61
  }
57
62
  return {
58
- ...super.forRoot(options),
63
+ ...super.forRoot(resolvedOptions),
59
64
  imports,
60
65
  providers,
61
66
  exports,
62
67
  };
63
68
  }
69
+ static forRootFromConfig(overrides = {}) {
70
+ const configOptions = (0, config_2.mapAuthConfigToApplicationModuleOptions)((0, config_2.authConfig)());
71
+ const moduleDefinition = this.forRoot({
72
+ ...configOptions,
73
+ ...overrides,
74
+ encryption: {
75
+ ...configOptions.encryption,
76
+ ...overrides.encryption,
77
+ },
78
+ persistence: {
79
+ ...configOptions.persistence,
80
+ ...overrides.persistence,
81
+ },
82
+ });
83
+ return {
84
+ ...moduleDefinition,
85
+ imports: [
86
+ config_1.ConfigModule.forFeature(config_2.authConfig),
87
+ ...(moduleDefinition.imports ?? []),
88
+ ],
89
+ };
90
+ }
64
91
  };
65
92
  exports.AuthApplicationModule = AuthApplicationModule;
66
93
  exports.AuthApplicationModule = AuthApplicationModule = tslib_1.__decorate([
@@ -1 +1 @@
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;AAC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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"}
1
+ {"version":3,"file":"application.module.js","sourceRoot":"","sources":["../../../../../../libs/auth/nest/src/application/application.module.ts"],"names":[],"mappings":";;;;AAAA,2CAAuD;AACvD,2CAA8C;AAC9C,qCAAwC;AACxC,sCAKmB;AACnB,mFAGyC;AACzC,iEAA6D;AAC7D,0DAAsD;AACtD,wEAAmE;AACnE,0DAAsD;AACtD,kEAA6D;AAC7D,kEAA8D;AAC9D,wDAAwD;AACxD,8EAAsE;AAI/D,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,uDAAuB;IAChE,MAAM,CAAC,OAAO,CAAC,UAAwC,EAAE;QACvD,MAAM,eAAe,GACnB,IAAA,4CAAmC,EAAC,OAAO,CAAC,CAAC;QAC/C,MAAM,EAAE,cAAc,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,eAAe,CAAC;QACpE,MAAM,OAAO,GAAG;YACd,qBAAY,CAAC,UAAU,CAAC,mBAAU,CAAC;YACnC,kDAAqB,CAAC,OAAO,CAAC,WAAW,CAAC;SAC3C,CAAC;QACF,MAAM,SAAS,GAAG,EAAE,CAAC;QACrB,MAAM,OAAO,GAAG,EAAE,CAAC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,KAAK,CAAC,OAAO,CAAC,eAAe,CAAC;YACjC,OAAO;YACP,SAAS;YACT,OAAO;SACR,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,iBAAiB,CACtB,YAA0C,EAAE;QAE5C,MAAM,aAAa,GAAG,IAAA,gDAAuC,EAAC,IAAA,mBAAU,GAAE,CAAC,CAAC;QAC5E,MAAM,gBAAgB,GAAG,IAAI,CAAC,OAAO,CAAC;YACpC,GAAG,aAAa;YAChB,GAAG,SAAS;YACZ,UAAU,EAAE;gBACV,GAAG,aAAa,CAAC,UAAU;gBAC3B,GAAG,SAAS,CAAC,UAAU;aACxB;YACD,WAAW,EAAE;gBACX,GAAG,aAAa,CAAC,WAAW;gBAC5B,GAAG,SAAS,CAAC,WAAW;aACzB;SACF,CAAC,CAAC;QAEH,OAAO;YACL,GAAG,gBAAgB;YACnB,OAAO,EAAE;gBACP,qBAAY,CAAC,UAAU,CAAC,mBAAU,CAAC;gBACnC,GAAG,CAAC,gBAAgB,CAAC,OAAO,IAAI,EAAE,CAAC;aACpC;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AAlFY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,qBAAqB,CAkFjC"}
@@ -6,3 +6,4 @@ export * from './services/bcrypt-hash.service';
6
6
  export * from './services/policies.service';
7
7
  export * from './strategies/jwt/strategy';
8
8
  export * from './factories/ability.factory';
9
+ export type { AuthApplicationModuleOptions } from '../config';
@@ -1,14 +1,7 @@
1
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
- };
2
+ import type { AuthModuleOptions } from './config';
3
+ export type { AuthModuleFeatures, AuthModuleOptions } from './config';
12
4
  export declare class AuthModule {
13
- static forRoot(options: AuthModuleOptions): DynamicModule;
5
+ static forRoot(options?: AuthModuleOptions): DynamicModule;
6
+ static forRootFromConfig(overrides?: AuthModuleOptions): DynamicModule;
14
7
  }
@@ -5,35 +5,51 @@ exports.AuthModule = void 0;
5
5
  const tslib_1 = require("tslib");
6
6
  const common_1 = require("@nestjs/common");
7
7
  const config_1 = require("@nestjs/config");
8
- const application_1 = require("./application");
9
- const config_2 = require("./config");
10
8
  const infrastructure_mailer_1 = require("./infrastructure-mailer");
11
- const infrastructure_persistence_1 = require("./infrastructure-persistence");
12
9
  const presentation_1 = require("./presentation");
10
+ const config_2 = require("./config");
13
11
  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
- }
12
+ static forRoot(options = {}) {
13
+ const presentationModule = presentation_1.AuthPresentationModule.forRoot(options.presentation);
14
+ const mailerModule = infrastructure_mailer_1.AuthMailerModule.forRoot(options.mailer);
33
15
  return {
34
16
  module: AuthModule_1,
35
- imports,
36
- exports,
17
+ imports: [presentationModule, mailerModule],
18
+ exports: [presentationModule, mailerModule],
19
+ };
20
+ }
21
+ static forRootFromConfig(overrides = {}) {
22
+ const configOptions = (0, config_2.mapAuthConfigToAuthModuleOptions)((0, config_2.authConfig)());
23
+ const moduleDefinition = this.forRoot({
24
+ ...configOptions,
25
+ ...overrides,
26
+ presentation: {
27
+ ...configOptions.presentation,
28
+ ...overrides.presentation,
29
+ application: {
30
+ ...configOptions.presentation?.application,
31
+ ...overrides.presentation?.application,
32
+ encryption: {
33
+ ...configOptions.presentation?.application?.encryption,
34
+ ...overrides.presentation?.application?.encryption,
35
+ },
36
+ persistence: {
37
+ ...configOptions.presentation?.application?.persistence,
38
+ ...overrides.presentation?.application?.persistence,
39
+ },
40
+ },
41
+ },
42
+ mailer: {
43
+ ...configOptions.mailer,
44
+ ...overrides.mailer,
45
+ },
46
+ });
47
+ return {
48
+ ...moduleDefinition,
49
+ imports: [
50
+ config_1.ConfigModule.forFeature(config_2.authConfig),
51
+ ...(moduleDefinition.imports ?? []),
52
+ ],
37
53
  };
38
54
  }
39
55
  };
@@ -1 +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,aA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AC1C,GAAG,SAAS,CAAC,YAAY,EAAE,WAAW;oBACtC,UAAU,EAAE;wBACV,GAAG,aAAa,CAAC,YAAY,EAAE,WAAW,EAAE,UAAU;wBACtD,GAAG,SAAS,CAAC,YAAY,EAAE,WAAW,EAAE,UAAU;qBACnD;oBACD,WAAW,EAAE;wBACX,GAAG,aAAa,CAAC,YAAY,EAAE,WAAW,EAAE,WAAW;wBACvD,GAAG,SAAS,CAAC,YAAY,EAAE,WAAW,EAAE,WAAW;qBACpD;iBACF;aACF;YACD,MAAM,EAAE;gBACN,GAAG,aAAa,CAAC,MAAM;gBACvB,GAAG,SAAS,CAAC,MAAM;aACpB;SACF,CAAC,CAAC;QAEH,OAAO;YACL,GAAG,gBAAgB;YACnB,OAAO,EAAE;gBACP,qBAAY,CAAC,UAAU,CAAC,mBAAU,CAAC;gBACnC,GAAG,CAAC,gBAAgB,CAAC,OAAO,IAAI,EAAE,CAAC;aACpC;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AAhDY,gCAAU;qBAAV,UAAU;IADtB,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,UAAU,CAgDtB"}
@@ -1,4 +1,14 @@
1
1
  import { ConfigType } from '@nestjs/config';
2
+ import type { CommonMailerProvider } from '@anarchitects/common-nest-mailer';
3
+ export declare const DEFAULT_AUTH_JWT_SECRET = "default_jwt_secret";
4
+ export declare const DEFAULT_AUTH_JWT_EXPIRATION = "3600s";
5
+ export declare const DEFAULT_AUTH_JWT_AUDIENCE = "your_audience";
6
+ export declare const DEFAULT_AUTH_JWT_ISSUER = "your_issuer";
7
+ export declare const DEFAULT_AUTH_ENCRYPTION_ALGORITHM = "bcrypt";
8
+ export declare const DEFAULT_AUTH_ENCRYPTION_KEY = "default_encryption_key";
9
+ export declare const DEFAULT_AUTH_PERSISTENCE = "typeorm";
10
+ export declare const DEFAULT_AUTH_MAILER_PROVIDER = "node";
11
+ export declare const DEFAULT_AUTH_STRATEGIES: readonly ["jwt"];
2
12
  export declare const authConfig: (() => {
3
13
  jwtSecret: string;
4
14
  jwtExpiration: string;
@@ -6,6 +16,9 @@ export declare const authConfig: (() => {
6
16
  jwtIssuer: string;
7
17
  encryptionAlgorithm: string;
8
18
  encryptionKey: string;
19
+ persistence: string;
20
+ mailerProvider: CommonMailerProvider;
21
+ authStrategies: string[];
9
22
  }) & import("@nestjs/config").ConfigFactoryKeyHost<{
10
23
  jwtSecret: string;
11
24
  jwtExpiration: string;
@@ -13,6 +26,9 @@ export declare const authConfig: (() => {
13
26
  jwtIssuer: string;
14
27
  encryptionAlgorithm: string;
15
28
  encryptionKey: string;
29
+ persistence: string;
30
+ mailerProvider: CommonMailerProvider;
31
+ authStrategies: string[];
16
32
  }>;
17
33
  export type AuthConfig = ConfigType<typeof authConfig>;
18
34
  export declare const InjectAuthConfig: () => PropertyDecorator & ParameterDecorator;
@@ -1,16 +1,53 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InjectAuthConfig = exports.authConfig = void 0;
3
+ exports.InjectAuthConfig = exports.authConfig = exports.DEFAULT_AUTH_STRATEGIES = exports.DEFAULT_AUTH_MAILER_PROVIDER = exports.DEFAULT_AUTH_PERSISTENCE = exports.DEFAULT_AUTH_ENCRYPTION_KEY = exports.DEFAULT_AUTH_ENCRYPTION_ALGORITHM = exports.DEFAULT_AUTH_JWT_ISSUER = exports.DEFAULT_AUTH_JWT_AUDIENCE = exports.DEFAULT_AUTH_JWT_EXPIRATION = exports.DEFAULT_AUTH_JWT_SECRET = void 0;
4
4
  const common_1 = require("@nestjs/common");
5
5
  const config_1 = require("@nestjs/config");
6
6
  const AUTH_CONFIG_KEY = 'auth';
7
+ exports.DEFAULT_AUTH_JWT_SECRET = 'default_jwt_secret';
8
+ exports.DEFAULT_AUTH_JWT_EXPIRATION = '3600s';
9
+ exports.DEFAULT_AUTH_JWT_AUDIENCE = 'your_audience';
10
+ exports.DEFAULT_AUTH_JWT_ISSUER = 'your_issuer';
11
+ exports.DEFAULT_AUTH_ENCRYPTION_ALGORITHM = 'bcrypt';
12
+ exports.DEFAULT_AUTH_ENCRYPTION_KEY = 'default_encryption_key';
13
+ exports.DEFAULT_AUTH_PERSISTENCE = 'typeorm';
14
+ exports.DEFAULT_AUTH_MAILER_PROVIDER = 'node';
15
+ exports.DEFAULT_AUTH_STRATEGIES = ['jwt'];
16
+ const parseMailerProvider = () => {
17
+ const value = process.env['AUTH_MAILER_PROVIDER'];
18
+ if (value === undefined) {
19
+ return exports.DEFAULT_AUTH_MAILER_PROVIDER;
20
+ }
21
+ switch (value) {
22
+ case 'node':
23
+ case 'noop':
24
+ return value;
25
+ default:
26
+ throw new Error(`Unsupported mailer provider: ${value}`);
27
+ }
28
+ };
29
+ const parseAuthStrategies = () => {
30
+ const raw = process.env['AUTH_STRATEGIES'];
31
+ if (!raw) {
32
+ return [...exports.DEFAULT_AUTH_STRATEGIES];
33
+ }
34
+ const parsed = raw
35
+ .split(',')
36
+ .map((strategy) => strategy.trim())
37
+ .filter((strategy) => strategy.length > 0);
38
+ return parsed.length > 0 ? parsed : [...exports.DEFAULT_AUTH_STRATEGIES];
39
+ };
7
40
  exports.authConfig = (0, config_1.registerAs)(AUTH_CONFIG_KEY, () => ({
8
- jwtSecret: process.env['AUTH_JWT_SECRET'] || 'default_jwt_secret',
9
- jwtExpiration: process.env['AUTH_JWT_EXPIRATION'] || '3600s',
10
- jwtAudience: process.env['AUTH_JWT_AUDIENCE'] || 'your_audience',
11
- jwtIssuer: process.env['AUTH_JWT_ISSUER'] || 'your_issuer',
12
- encryptionAlgorithm: process.env['AUTH_ENCRYPTION_ALGORITHM'] || 'bcrypt',
13
- encryptionKey: process.env['AUTH_ENCRYPTION_KEY'] || 'default_encryption_key',
41
+ jwtSecret: process.env['AUTH_JWT_SECRET'] ?? exports.DEFAULT_AUTH_JWT_SECRET,
42
+ jwtExpiration: process.env['AUTH_JWT_EXPIRATION'] ?? exports.DEFAULT_AUTH_JWT_EXPIRATION,
43
+ jwtAudience: process.env['AUTH_JWT_AUDIENCE'] ?? exports.DEFAULT_AUTH_JWT_AUDIENCE,
44
+ jwtIssuer: process.env['AUTH_JWT_ISSUER'] ?? exports.DEFAULT_AUTH_JWT_ISSUER,
45
+ encryptionAlgorithm: process.env['AUTH_ENCRYPTION_ALGORITHM'] ??
46
+ exports.DEFAULT_AUTH_ENCRYPTION_ALGORITHM,
47
+ encryptionKey: process.env['AUTH_ENCRYPTION_KEY'] ?? exports.DEFAULT_AUTH_ENCRYPTION_KEY,
48
+ persistence: process.env['AUTH_PERSISTENCE'] ?? exports.DEFAULT_AUTH_PERSISTENCE,
49
+ mailerProvider: parseMailerProvider(),
50
+ authStrategies: parseAuthStrategies(),
14
51
  }));
15
52
  const InjectAuthConfig = () => (0, common_1.Inject)(exports.authConfig.KEY);
16
53
  exports.InjectAuthConfig = InjectAuthConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"auth.config.js","sourceRoot":"","sources":["../../../../../../libs/auth/nest/src/config/auth.config.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AACxC,2CAAwD;AAExD,MAAM,eAAe,GAAG,MAAM,CAAC;AAElB,QAAA,UAAU,GAAG,IAAA,mBAAU,EAAC,eAAe,EAAE,GAAG,EAAE,CAAC,CAAC;IAC3D,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,IAAI,oBAAoB;IACjE,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,IAAI,OAAO;IAC5D,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,eAAe;IAChE,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,IAAI,aAAa;IAC1D,mBAAmB,EAAE,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,IAAI,QAAQ;IACzE,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,IAAI,wBAAwB;CAC9E,CAAC,CAAC,CAAC;AA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object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./auth.config"), exports);
5
+ tslib_1.__exportStar(require("./module-options"), exports);
5
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../libs/auth/nest/src/config/index.ts"],"names":[],"mappings":";;;AAAA,wDAA8B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../libs/auth/nest/src/config/index.ts"],"names":[],"mappings":";;;AAAA,wDAA8B;AAC9B,2DAAiC"}
@@ -0,0 +1,57 @@
1
+ import type { CommonMailerProvider } from '@anarchitects/common-nest-mailer';
2
+ import type { AuthConfig } from './auth.config';
3
+ export type AuthPersistenceModuleOptions = {
4
+ persistence?: string;
5
+ };
6
+ export type ResolvedAuthPersistenceModuleOptions = {
7
+ persistence: string;
8
+ };
9
+ export type AuthMailerModuleOptions = {
10
+ provider?: CommonMailerProvider;
11
+ };
12
+ export type ResolvedAuthMailerModuleOptions = {
13
+ provider: CommonMailerProvider;
14
+ };
15
+ export type AuthApplicationModuleOptions = {
16
+ authStrategies?: string[];
17
+ encryption?: {
18
+ algorithm?: 'bcrypt' | 'argon2';
19
+ key?: string;
20
+ };
21
+ persistence?: AuthPersistenceModuleOptions;
22
+ };
23
+ export type ResolvedAuthApplicationModuleOptions = {
24
+ authStrategies: string[];
25
+ encryption: {
26
+ algorithm: 'bcrypt' | 'argon2';
27
+ key: string;
28
+ };
29
+ persistence: ResolvedAuthPersistenceModuleOptions;
30
+ };
31
+ export type AuthPresentationModuleOptions = {
32
+ application?: AuthApplicationModuleOptions;
33
+ };
34
+ export type ResolvedAuthPresentationModuleOptions = {
35
+ application: ResolvedAuthApplicationModuleOptions;
36
+ };
37
+ export type AuthModuleFeatures = {
38
+ provider?: CommonMailerProvider;
39
+ };
40
+ export type AuthModuleOptions = {
41
+ presentation?: AuthPresentationModuleOptions;
42
+ mailer?: AuthMailerModuleOptions;
43
+ };
44
+ export type ResolvedAuthModuleOptions = {
45
+ presentation: ResolvedAuthPresentationModuleOptions;
46
+ mailer: ResolvedAuthMailerModuleOptions;
47
+ };
48
+ export declare const resolveAuthPersistenceModuleOptions: (options?: AuthPersistenceModuleOptions) => ResolvedAuthPersistenceModuleOptions;
49
+ export declare const resolveAuthMailerModuleOptions: (options?: AuthMailerModuleOptions) => ResolvedAuthMailerModuleOptions;
50
+ export declare const resolveAuthApplicationModuleOptions: (options?: AuthApplicationModuleOptions) => ResolvedAuthApplicationModuleOptions;
51
+ export declare const resolveAuthPresentationModuleOptions: (options?: AuthPresentationModuleOptions) => ResolvedAuthPresentationModuleOptions;
52
+ export declare const resolveAuthModuleOptions: (options?: AuthModuleOptions) => ResolvedAuthModuleOptions;
53
+ export declare const mapAuthConfigToPersistenceModuleOptions: (config: AuthConfig) => AuthPersistenceModuleOptions;
54
+ export declare const mapAuthConfigToMailerModuleOptions: (config: AuthConfig) => AuthMailerModuleOptions;
55
+ export declare const mapAuthConfigToApplicationModuleOptions: (config: AuthConfig) => AuthApplicationModuleOptions;
56
+ export declare const mapAuthConfigToPresentationModuleOptions: (config: AuthConfig) => AuthPresentationModuleOptions;
57
+ export declare const mapAuthConfigToAuthModuleOptions: (config: AuthConfig) => AuthModuleOptions;
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapAuthConfigToAuthModuleOptions = exports.mapAuthConfigToPresentationModuleOptions = exports.mapAuthConfigToApplicationModuleOptions = exports.mapAuthConfigToMailerModuleOptions = exports.mapAuthConfigToPersistenceModuleOptions = exports.resolveAuthModuleOptions = exports.resolveAuthPresentationModuleOptions = exports.resolveAuthApplicationModuleOptions = exports.resolveAuthMailerModuleOptions = exports.resolveAuthPersistenceModuleOptions = void 0;
4
+ const auth_config_1 = require("./auth.config");
5
+ const resolveAuthPersistenceModuleOptions = (options = {}) => ({
6
+ persistence: options.persistence ?? auth_config_1.DEFAULT_AUTH_PERSISTENCE,
7
+ });
8
+ exports.resolveAuthPersistenceModuleOptions = resolveAuthPersistenceModuleOptions;
9
+ const resolveAuthMailerModuleOptions = (options = {}) => ({
10
+ provider: options.provider ?? auth_config_1.DEFAULT_AUTH_MAILER_PROVIDER,
11
+ });
12
+ exports.resolveAuthMailerModuleOptions = resolveAuthMailerModuleOptions;
13
+ const resolveAuthApplicationModuleOptions = (options = {}) => ({
14
+ authStrategies: options.authStrategies ?? [...auth_config_1.DEFAULT_AUTH_STRATEGIES],
15
+ encryption: {
16
+ algorithm: options.encryption?.algorithm ??
17
+ auth_config_1.DEFAULT_AUTH_ENCRYPTION_ALGORITHM,
18
+ key: options.encryption?.key ?? auth_config_1.DEFAULT_AUTH_ENCRYPTION_KEY,
19
+ },
20
+ persistence: (0, exports.resolveAuthPersistenceModuleOptions)(options.persistence),
21
+ });
22
+ exports.resolveAuthApplicationModuleOptions = resolveAuthApplicationModuleOptions;
23
+ const resolveAuthPresentationModuleOptions = (options = {}) => ({
24
+ application: (0, exports.resolveAuthApplicationModuleOptions)(options.application),
25
+ });
26
+ exports.resolveAuthPresentationModuleOptions = resolveAuthPresentationModuleOptions;
27
+ const resolveAuthModuleOptions = (options = {}) => ({
28
+ presentation: (0, exports.resolveAuthPresentationModuleOptions)(options.presentation),
29
+ mailer: (0, exports.resolveAuthMailerModuleOptions)(options.mailer),
30
+ });
31
+ exports.resolveAuthModuleOptions = resolveAuthModuleOptions;
32
+ const mapAuthConfigToPersistenceModuleOptions = (config) => ({
33
+ persistence: config.persistence ?? auth_config_1.DEFAULT_AUTH_PERSISTENCE,
34
+ });
35
+ exports.mapAuthConfigToPersistenceModuleOptions = mapAuthConfigToPersistenceModuleOptions;
36
+ const mapAuthConfigToMailerModuleOptions = (config) => ({
37
+ provider: config.mailerProvider ?? auth_config_1.DEFAULT_AUTH_MAILER_PROVIDER,
38
+ });
39
+ exports.mapAuthConfigToMailerModuleOptions = mapAuthConfigToMailerModuleOptions;
40
+ const mapAuthConfigToApplicationModuleOptions = (config) => ({
41
+ authStrategies: config.authStrategies ?? [...auth_config_1.DEFAULT_AUTH_STRATEGIES],
42
+ encryption: {
43
+ algorithm: config.encryptionAlgorithm,
44
+ key: config.encryptionKey ?? auth_config_1.DEFAULT_AUTH_ENCRYPTION_KEY,
45
+ },
46
+ persistence: (0, exports.mapAuthConfigToPersistenceModuleOptions)(config),
47
+ });
48
+ exports.mapAuthConfigToApplicationModuleOptions = mapAuthConfigToApplicationModuleOptions;
49
+ const mapAuthConfigToPresentationModuleOptions = (config) => ({
50
+ application: (0, exports.mapAuthConfigToApplicationModuleOptions)(config),
51
+ });
52
+ exports.mapAuthConfigToPresentationModuleOptions = mapAuthConfigToPresentationModuleOptions;
53
+ const mapAuthConfigToAuthModuleOptions = (config) => ({
54
+ presentation: (0, exports.mapAuthConfigToPresentationModuleOptions)(config),
55
+ mailer: (0, exports.mapAuthConfigToMailerModuleOptions)(config),
56
+ });
57
+ exports.mapAuthConfigToAuthModuleOptions = mapAuthConfigToAuthModuleOptions;
58
+ //# sourceMappingURL=module-options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module-options.js","sourceRoot":"","sources":["../../../../../../libs/auth/nest/src/config/module-options.ts"],"names":[],"mappings":";;;AAAA,+CAMuB;AA4DhB,MAAM,mCAAmC,GAAG,CACjD,UAAwC,EAAE,EACJ,EAAE,CAAC,CAAC;IAC1C,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,sCAAwB;CAC7D,CAAC,CAAC;AAJU,QAAA,mCAAmC,uCAI7C;AAEI,MAAM,8BAA8B,GAAG,CAC5C,UAAmC,EAAE,EACJ,EAAE,CAAC,CAAC;IACrC,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,0CAA4B;CAC3D,CAAC,CAAC;AAJU,QAAA,8BAA8B,kCAIxC;AAEI,MAAM,mCAAmC,GAAG,CACjD,UAAwC,EAAE,EACJ,EAAE,CAAC,CAAC;IAC1C,cAAc,EAAE,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,mBAA0C;QAC5D,GAAG,EAAE,MAAM,CAAC,aAAa,IAAI,yCAA2B;KACzD;IACD,WAAW,EAAE,IAAA,+CAAuC,EAAC,MAAM,CAAC;CAC7D,CAAC,CAAC;AATU,QAAA,uCAAuC,2CASjD;AAEI,MAAM,wCAAwC,GAAG,CACtD,MAAkB,EACa,EAAE,CAAC,CAAC;IACnC,WAAW,EAAE,IAAA,+CAAuC,EAAC,MAAM,CAAC;CAC7D,CAAC,CAAC;AAJU,QAAA,wCAAwC,4CAIlD;AAEI,MAAM,gCAAgC,GAAG,CAC9C,MAAkB,EACC,EAAE,CAAC,CAAC;IACvB,YAAY,EAAE,IAAA,gDAAwC,EAAC,MAAM,CAAC;IAC9D,MAAM,EAAE,IAAA,0CAAkC,EAAC,MAAM,CAAC;CACnD,CAAC,CAAC;AALU,QAAA,gCAAgC,oCAK1C"}
@@ -1,2 +1,3 @@
1
1
  export * from './adapters/node-mailer.adapter';
2
2
  export * from './mailer.module';
3
+ export type { AuthMailerModuleOptions } from '../config';
@@ -1,2 +1,6 @@
1
+ import { DynamicModule } from '@nestjs/common';
2
+ import type { AuthMailerModuleOptions } from '../config';
1
3
  export declare class AuthMailerModule {
4
+ static forRoot(options?: AuthMailerModuleOptions): DynamicModule;
5
+ static forRootFromConfig(overrides?: AuthMailerModuleOptions): DynamicModule;
2
6
  }
@@ -1,17 +1,42 @@
1
1
  "use strict";
2
+ var AuthMailerModule_1;
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.AuthMailerModule = void 0;
4
5
  const tslib_1 = require("tslib");
5
6
  const common_1 = require("@nestjs/common");
7
+ const config_1 = require("@nestjs/config");
6
8
  const common_nest_mailer_1 = require("@anarchitects/common-nest-mailer");
7
- let AuthMailerModule = class AuthMailerModule {
9
+ const config_2 = require("../config");
10
+ let AuthMailerModule = AuthMailerModule_1 = class AuthMailerModule {
11
+ static forRoot(options = {}) {
12
+ const resolvedOptions = (0, config_2.resolveAuthMailerModuleOptions)(options);
13
+ const commonMailerModule = common_nest_mailer_1.CommonMailerModule.forRoot({
14
+ provider: resolvedOptions.provider,
15
+ });
16
+ return {
17
+ module: AuthMailerModule_1,
18
+ imports: [commonMailerModule],
19
+ exports: [commonMailerModule],
20
+ };
21
+ }
22
+ static forRootFromConfig(overrides = {}) {
23
+ const configOptions = (0, config_2.mapAuthConfigToMailerModuleOptions)((0, config_2.authConfig)());
24
+ const moduleDefinition = this.forRoot({
25
+ ...configOptions,
26
+ ...overrides,
27
+ });
28
+ return {
29
+ ...moduleDefinition,
30
+ imports: [
31
+ config_1.ConfigModule.forFeature(config_2.authConfig),
32
+ ...(moduleDefinition.imports ?? []),
33
+ ],
34
+ };
35
+ }
8
36
  };
9
37
  exports.AuthMailerModule = AuthMailerModule;
10
- exports.AuthMailerModule = AuthMailerModule = tslib_1.__decorate([
38
+ exports.AuthMailerModule = AuthMailerModule = AuthMailerModule_1 = tslib_1.__decorate([
11
39
  (0, common_1.Global)(),
12
- (0, common_1.Module)({
13
- imports: [common_nest_mailer_1.CommonNodeMailerModule],
14
- exports: [common_nest_mailer_1.CommonNodeMailerModule],
15
- })
40
+ (0, common_1.Module)({})
16
41
  ], AuthMailerModule);
17
42
  //# 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,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
+ {"version":3,"file":"mailer.module.js","sourceRoot":"","sources":["../../../../../../libs/auth/nest/src/infrastructure-mailer/mailer.module.ts"],"names":[],"mappings":";;;;;AAAA,2CAA+D;AAC/D,2CAA8C;AAC9C,yEAAsE;AACtE,sCAImB;AAKZ,IAAM,gBAAgB,wBAAtB,MAAM,gBAAgB;IAC3B,MAAM,CAAC,OAAO,CAAC,UAAmC,EAAE;QAClD,MAAM,eAAe,GAAG,IAAA,uCAA8B,EAAC,OAAO,CAAC,CAAC;QAChE,MAAM,kBAAkB,GAAG,uCAAkB,CAAC,OAAO,CAAC;YACpD,QAAQ,EAAE,eAAe,CAAC,QAAQ;SACnC,CAAC,CAAC;QAEH,OAAO;YACL,MAAM,EAAE,kBAAgB;YACxB,OAAO,EAAE,CAAC,kBAAkB,CAAC;YAC7B,OAAO,EAAE,CAAC,kBAAkB,CAAC;SAC9B,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,iBAAiB,CACtB,YAAqC,EAAE;QAEvC,MAAM,aAAa,GAAG,IAAA,2CAAkC,EAAC,IAAA,mBAAU,GAAE,CAAC,CAAC;QACvE,MAAM,gBAAgB,GAAG,IAAI,CAAC,OAAO,CAAC;YACpC,GAAG,aAAa;YAChB,GAAG,SAAS;SACb,CAAC,CAAC;QAEH,OAAO;YACL,GAAG,gBAAgB;YACnB,OAAO,EAAE;gBACP,qBAAY,CAAC,UAAU,CAAC,mBAAU,CAAC;gBACnC,GAAG,CAAC,gBAAgB,CAAC,OAAO,IAAI,EAAE,CAAC;aACpC;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AA/BY,4CAAgB;2BAAhB,gBAAgB;IAF5B,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,gBAAgB,CA+B5B"}
@@ -1,3 +1,4 @@
1
1
  export * from './persistence.module';
2
2
  export * from './repositories/auth-user.repository';
3
3
  export * from './migrations/1720200000000-create-auth-schema';
4
+ export type { AuthPersistenceModuleOptions } from '../config';
@@ -1,13 +1,8 @@
1
- export declare const ConfigurableModuleClass: import("@nestjs/common").ConfigurableModuleCls<{
2
- persistence: string;
3
- }, "forRoot", "create", {
1
+ import type { ResolvedAuthPersistenceModuleOptions } from '../config';
2
+ export declare const ConfigurableModuleClass: import("@nestjs/common").ConfigurableModuleCls<ResolvedAuthPersistenceModuleOptions, "forRoot", "create", {
4
3
  isGlobal?: boolean;
5
- }>, AUTH_PERSISTENCE_MODULE_OPTIONS: string | symbol, OPTIONS_TYPE: {
6
- persistence: string;
7
- } & Partial<{
4
+ }>, AUTH_PERSISTENCE_MODULE_OPTIONS: string | symbol, OPTIONS_TYPE: ResolvedAuthPersistenceModuleOptions & Partial<{
8
5
  isGlobal?: boolean;
9
- }>, ASYNC_OPTIONS_TYPE: import("@nestjs/common").ConfigurableModuleAsyncOptions<{
10
- persistence: string;
11
- }, "create"> & Partial<{
6
+ }>, ASYNC_OPTIONS_TYPE: import("@nestjs/common").ConfigurableModuleAsyncOptions<ResolvedAuthPersistenceModuleOptions, "create"> & Partial<{
12
7
  isGlobal?: boolean;
13
8
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"persistence.module-definition.js","sourceRoot":"","sources":["../../../../../../libs/auth/nest/src/infrastructure-persistence/persistence.module-definition.ts"],"names":[],"mappings":";;;;AAAA,2CAA2D;AAE9C,KAKT,IAAI,kCAAyB,EAA2B;KACzD,kBAAkB,CAAC,SAAS,CAAC;KAC7B,SAAS,CACR,EAAE,QAAQ,EAAE,IAAI,EAAE,EAClB,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;IACvB,GAAG,UAAU;IACb,MAAM,EAAE,MAAM,CAAC,QAAQ,IAAI,KAAK;CACjC,CAAC,CACH;KACA,KAAK,EAAE,EAbR,+BAAuB,+BACD,uCAA+B,4BACrD,oBAAY,oBACZ,0BAAkB,yBAUT"}
1
+ {"version":3,"file":"persistence.module-definition.js","sourceRoot":"","sources":["../../../../../../libs/auth/nest/src/infrastructure-persistence/persistence.module-definition.ts"],"names":[],"mappings":";;;;AAAA,2CAA2D;AAG9C,KAKT,IAAI,kCAAyB,EAAwC;KACtE,kBAAkB,CAAC,SAAS,CAAC;KAC7B,SAAS,CACR,EAAE,QAAQ,EAAE,IAAI,EAAE,EAClB,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;IACvB,GAAG,UAAU;IACb,MAAM,EAAE,MAAM,CAAC,QAAQ,IAAI,KAAK;CACjC,CAAC,CACH;KACA,KAAK,EAAE,EAbR,+BAAuB,+BACD,uCAA+B,4BACrD,oBAAY,oBACZ,0BAAkB,yBAUT"}
@@ -1,5 +1,7 @@
1
1
  import { DynamicModule } from '@nestjs/common';
2
- import { ConfigurableModuleClass, OPTIONS_TYPE } from './persistence.module-definition';
2
+ import { ConfigurableModuleClass } from './persistence.module-definition';
3
+ import type { AuthPersistenceModuleOptions } from '../config';
3
4
  export declare class AuthPersistenceModule extends ConfigurableModuleClass {
4
- static forRoot(options: typeof OPTIONS_TYPE): DynamicModule;
5
+ static forRoot(options?: AuthPersistenceModuleOptions): DynamicModule;
6
+ static forRootFromConfig(overrides?: AuthPersistenceModuleOptions): DynamicModule;
5
7
  }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AuthPersistenceModule = 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 typeorm_1 = require("@nestjs/typeorm");
7
8
  const invalidated_token_entity_1 = require("./entities/invalidated-token.entity");
8
9
  const permission_entity_1 = require("./entities/permission.entity");
@@ -11,12 +12,14 @@ const user_entity_1 = require("./entities/user.entity");
11
12
  const persistence_module_definition_1 = require("./persistence.module-definition");
12
13
  const auth_user_repository_1 = require("./repositories/auth-user.repository");
13
14
  const typeorm_auth_user_repository_1 = require("./repositories/typeorm-auth-user.repository");
15
+ const config_2 = require("../config");
14
16
  let AuthPersistenceModule = class AuthPersistenceModule extends persistence_module_definition_1.ConfigurableModuleClass {
15
- static forRoot(options) {
16
- switch (options.persistence) {
17
+ static forRoot(options = {}) {
18
+ const resolvedOptions = (0, config_2.resolveAuthPersistenceModuleOptions)(options);
19
+ switch (resolvedOptions.persistence) {
17
20
  case 'typeorm':
18
21
  return {
19
- ...super.forRoot(options),
22
+ ...super.forRoot(resolvedOptions),
20
23
  imports: [
21
24
  typeorm_1.TypeOrmModule.forFeature([
22
25
  user_entity_1.UserEntity,
@@ -35,9 +38,23 @@ let AuthPersistenceModule = class AuthPersistenceModule extends persistence_modu
35
38
  exports: [auth_user_repository_1.AuthUserRepository, typeorm_1.TypeOrmModule],
36
39
  };
37
40
  default:
38
- throw new Error(`Unsupported persistence type: ${options.persistence}`);
41
+ throw new Error(`Unsupported persistence type: ${resolvedOptions.persistence}`);
39
42
  }
40
43
  }
44
+ static forRootFromConfig(overrides = {}) {
45
+ const configOptions = (0, config_2.mapAuthConfigToPersistenceModuleOptions)((0, config_2.authConfig)());
46
+ const moduleDefinition = this.forRoot({
47
+ ...configOptions,
48
+ ...overrides,
49
+ });
50
+ return {
51
+ ...moduleDefinition,
52
+ imports: [
53
+ config_1.ConfigModule.forFeature(config_2.authConfig),
54
+ ...(moduleDefinition.imports ?? []),
55
+ ],
56
+ };
57
+ }
41
58
  };
42
59
  exports.AuthPersistenceModule = AuthPersistenceModule;
43
60
  exports.AuthPersistenceModule = AuthPersistenceModule = tslib_1.__decorate([
@@ -1 +1 @@
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
+ {"version":3,"file":"persistence.module.js","sourceRoot":"","sources":["../../../../../../libs/auth/nest/src/infrastructure-persistence/persistence.module.ts"],"names":[],"mappings":";;;;AAAA,2CAAuD;AACvD,2CAA8C;AAC9C,6CAAgD;AAChD,kFAA6E;AAC7E,oEAAgE;AAChE,wDAAoD;AACpD,wDAAoD;AACpD,mFAGyC;AACzC,8EAAyE;AACzE,8FAAwF;AACxF,sCAImB;AAIZ,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,uDAAuB;IAChE,MAAM,CAAC,OAAO,CAAC,UAAwC,EAAE;QACvD,MAAM,eAAe,GACnB,IAAA,4CAAmC,EAAC,OAAO,CAAC,CAAC;QAE/C,QAAQ,eAAe,CAAC,WAAW,EAAE,CAAC;YACpC,KAAK,SAAS;gBACZ,OAAO;oBACL,GAAG,KAAK,CAAC,OAAO,CAAC,eAAe,CAAC;oBACjC,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,CACb,iCAAiC,eAAe,CAAC,WAAW,EAAE,CAC/D,CAAC;QACN,CAAC;IACH,CAAC;IAED,MAAM,CAAC,iBAAiB,CACtB,YAA0C,EAAE;QAE5C,MAAM,aAAa,GAAG,IAAA,gDAAuC,EAAC,IAAA,mBAAU,GAAE,CAAC,CAAC;QAC5E,MAAM,gBAAgB,GAAG,IAAI,CAAC,OAAO,CAAC;YACpC,GAAG,aAAa;YAChB,GAAG,SAAS;SACb,CAAC,CAAC;QAEH,OAAO;YACL,GAAG,gBAAgB;YACnB,OAAO,EAAE;gBACP,qBAAY,CAAC,UAAU,CAAC,mBAAU,CAAC;gBACnC,GAAG,CAAC,gBAAgB,CAAC,OAAO,IAAI,EAAE,CAAC;aACpC;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AAlDY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,qBAAqB,CAkDjC"}
@@ -2,3 +2,4 @@ export * from './presentation.module';
2
2
  export * from './controllers/auth.controller';
3
3
  export * from './guards/policies.guard';
4
4
  export * from './decorators/policies.decorator';
5
+ export type { AuthPresentationModuleOptions } from '../config';
@@ -1,2 +1,6 @@
1
+ import { DynamicModule } from '@nestjs/common';
2
+ import type { AuthPresentationModuleOptions } from '../config';
1
3
  export declare class AuthPresentationModule {
4
+ static forRoot(options?: AuthPresentationModuleOptions): DynamicModule;
5
+ static forRootFromConfig(overrides?: AuthPresentationModuleOptions): DynamicModule;
2
6
  }
@@ -1,13 +1,50 @@
1
1
  "use strict";
2
+ var AuthPresentationModule_1;
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.AuthPresentationModule = void 0;
4
5
  const tslib_1 = require("tslib");
5
6
  const common_1 = require("@nestjs/common");
7
+ const config_1 = require("@nestjs/config");
6
8
  const auth_controller_1 = require("./controllers/auth.controller");
7
- let AuthPresentationModule = class AuthPresentationModule {
9
+ const application_1 = require("../application");
10
+ const config_2 = require("../config");
11
+ let AuthPresentationModule = AuthPresentationModule_1 = class AuthPresentationModule {
12
+ static forRoot(options = {}) {
13
+ return {
14
+ module: AuthPresentationModule_1,
15
+ imports: [application_1.AuthApplicationModule.forRoot(options.application)],
16
+ exports: [application_1.AuthApplicationModule],
17
+ };
18
+ }
19
+ static forRootFromConfig(overrides = {}) {
20
+ const configOptions = (0, config_2.mapAuthConfigToPresentationModuleOptions)((0, config_2.authConfig)());
21
+ const moduleDefinition = this.forRoot({
22
+ ...configOptions,
23
+ ...overrides,
24
+ application: {
25
+ ...configOptions.application,
26
+ ...overrides.application,
27
+ encryption: {
28
+ ...configOptions.application?.encryption,
29
+ ...overrides.application?.encryption,
30
+ },
31
+ persistence: {
32
+ ...configOptions.application?.persistence,
33
+ ...overrides.application?.persistence,
34
+ },
35
+ },
36
+ });
37
+ return {
38
+ ...moduleDefinition,
39
+ imports: [
40
+ config_1.ConfigModule.forFeature(config_2.authConfig),
41
+ ...(moduleDefinition.imports ?? []),
42
+ ],
43
+ };
44
+ }
8
45
  };
9
46
  exports.AuthPresentationModule = AuthPresentationModule;
10
- exports.AuthPresentationModule = AuthPresentationModule = tslib_1.__decorate([
47
+ exports.AuthPresentationModule = AuthPresentationModule = AuthPresentationModule_1 = tslib_1.__decorate([
11
48
  (0, common_1.Module)({
12
49
  controllers: [auth_controller_1.AuthController],
13
50
  })
@@ -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,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
+ {"version":3,"file":"presentation.module.js","sourceRoot":"","sources":["../../../../../../libs/auth/nest/src/presentation/presentation.module.ts"],"names":[],"mappings":";;;;;AAAA,2CAAuD;AACvD,2CAA8C;AAC9C,mEAA+D;AAC/D,gDAAuD;AACvD,sCAGmB;AAMZ,IAAM,sBAAsB,8BAA5B,MAAM,sBAAsB;IACjC,MAAM,CAAC,OAAO,CAAC,UAAyC,EAAE;QACxD,OAAO;YACL,MAAM,EAAE,wBAAsB;YAC9B,OAAO,EAAE,CAAC,mCAAqB,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;YAC7D,OAAO,EAAE,CAAC,mCAAqB,CAAC;SACjC,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,iBAAiB,CACtB,YAA2C,EAAE;QAE7C,MAAM,aAAa,GACjB,IAAA,iDAAwC,EAAC,IAAA,mBAAU,GAAE,CAAC,CAAC;QACzD,MAAM,gBAAgB,GAAG,IAAI,CAAC,OAAO,CAAC;YACpC,GAAG,aAAa;YAChB,GAAG,SAAS;YACZ,WAAW,EAAE;gBACX,GAAG,aAAa,CAAC,WAAW;gBAC5B,GAAG,SAAS,CAAC,WAAW;gBACxB,UAAU,EAAE;oBACV,GAAG,aAAa,CAAC,WAAW,EAAE,UAAU;oBACxC,GAAG,SAAS,CAAC,WAAW,EAAE,UAAU;iBACrC;gBACD,WAAW,EAAE;oBACX,GAAG,aAAa,CAAC,WAAW,EAAE,WAAW;oBACzC,GAAG,SAAS,CAAC,WAAW,EAAE,WAAW;iBACtC;aACF;SACF,CAAC,CAAC;QAEH,OAAO;YACL,GAAG,gBAAgB;YACnB,OAAO,EAAE;gBACP,qBAAY,CAAC,UAAU,CAAC,mBAAU,CAAC;gBACnC,GAAG,CAAC,gB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