@anarchitects/auth-nest 0.4.2 → 2.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 +39 -19
- package/package.json +3 -3
- package/src/application/application.module-definition.d.ts +4 -21
- package/src/application/application.module-definition.js.map +1 -1
- package/src/application/application.module.d.ts +5 -22
- package/src/application/application.module.js +31 -4
- package/src/application/application.module.js.map +1 -1
- package/src/application/index.d.ts +1 -0
- package/src/auth.module.d.ts +4 -11
- package/src/auth.module.js +44 -24
- package/src/auth.module.js.map +1 -1
- package/src/config/auth.config.d.ts +15 -0
- package/src/config/auth.config.js +38 -7
- package/src/config/auth.config.js.map +1 -1
- package/src/config/index.d.ts +1 -0
- package/src/config/index.js +1 -0
- package/src/config/index.js.map +1 -1
- package/src/config/module-options.d.ts +59 -0
- package/src/config/module-options.js +62 -0
- package/src/config/module-options.js.map +1 -0
- package/src/infrastructure-mailer/index.d.ts +1 -0
- package/src/infrastructure-mailer/mailer.module.d.ts +4 -0
- package/src/infrastructure-mailer/mailer.module.js +32 -2
- package/src/infrastructure-mailer/mailer.module.js.map +1 -1
- package/src/infrastructure-persistence/index.d.ts +1 -0
- package/src/infrastructure-persistence/persistence.module-definition.d.ts +4 -9
- package/src/infrastructure-persistence/persistence.module-definition.js.map +1 -1
- package/src/infrastructure-persistence/persistence.module.d.ts +4 -2
- package/src/infrastructure-persistence/persistence.module.js +21 -4
- package/src/infrastructure-persistence/persistence.module.js.map +1 -1
- package/src/presentation/index.d.ts +1 -0
- package/src/presentation/presentation.module.d.ts +4 -0
- package/src/presentation/presentation.module.js +39 -2
- package/src/presentation/presentation.module.js.map +1 -1
package/README.md
CHANGED
|
@@ -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_ENABLED` | Enables/disables domain mailer wiring in `forRootFromConfig(...)`. | `true` |
|
|
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,22 @@ import { authConfig } from '@anarchitects/auth-nest/config';
|
|
|
97
100
|
}),
|
|
98
101
|
CommonMailerModule.forRootFromConfig(),
|
|
99
102
|
AuthModule.forRoot({
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
mailer: true,
|
|
115
|
+
mailer: {
|
|
116
|
+
features: {
|
|
117
|
+
enabled: true,
|
|
118
|
+
},
|
|
112
119
|
},
|
|
113
120
|
}),
|
|
114
121
|
],
|
|
@@ -118,13 +125,15 @@ export class AuthApiModule {}
|
|
|
118
125
|
|
|
119
126
|
`AuthModule.forRoot(...)` is the preferred integration path when you want a full auth stack with minimal host-module wiring.
|
|
120
127
|
|
|
128
|
+
Use `AuthModule.forRootFromConfig()` when you want module composition fully driven by `AUTH_*`
|
|
129
|
+
variables exposed via `authConfig`.
|
|
130
|
+
|
|
121
131
|
Disable domain mailer wiring when not needed:
|
|
122
132
|
|
|
123
133
|
```ts
|
|
124
134
|
AuthModule.forRoot({
|
|
125
|
-
application: { ... },
|
|
126
|
-
|
|
127
|
-
features: { mailer: false },
|
|
135
|
+
presentation: { application: { ... } },
|
|
136
|
+
mailer: { features: { enabled: false } },
|
|
128
137
|
});
|
|
129
138
|
```
|
|
130
139
|
|
|
@@ -136,7 +145,6 @@ import { ConfigModule } from '@nestjs/config';
|
|
|
136
145
|
import { CommonMailerModule, mailerConfig } from '@anarchitects/common-nest-mailer';
|
|
137
146
|
import { authConfig } from '@anarchitects/auth-nest/config';
|
|
138
147
|
import { AuthApplicationModule } from '@anarchitects/auth-nest/application';
|
|
139
|
-
import { AuthPersistenceModule } from '@anarchitects/auth-nest/infrastructure-persistence';
|
|
140
148
|
import { AuthPresentationModule } from '@anarchitects/auth-nest/presentation';
|
|
141
149
|
import { AuthMailerModule } from '@anarchitects/auth-nest/infrastructure-mailer';
|
|
142
150
|
|
|
@@ -153,10 +161,21 @@ import { AuthMailerModule } from '@anarchitects/auth-nest/infrastructure-mailer'
|
|
|
153
161
|
algorithm: 'bcrypt',
|
|
154
162
|
key: process.env.AUTH_ENCRYPTION_KEY!,
|
|
155
163
|
},
|
|
164
|
+
persistence: { persistence: 'typeorm' },
|
|
165
|
+
}),
|
|
166
|
+
AuthPresentationModule.forRoot({
|
|
167
|
+
application: {
|
|
168
|
+
authStrategies: ['jwt'],
|
|
169
|
+
encryption: {
|
|
170
|
+
algorithm: 'bcrypt',
|
|
171
|
+
key: process.env.AUTH_ENCRYPTION_KEY!,
|
|
172
|
+
},
|
|
173
|
+
persistence: { persistence: 'typeorm' },
|
|
174
|
+
},
|
|
175
|
+
}),
|
|
176
|
+
AuthMailerModule.forRoot({
|
|
177
|
+
features: { enabled: true },
|
|
156
178
|
}),
|
|
157
|
-
AuthPersistenceModule.forRoot({ persistence: 'typeorm' }),
|
|
158
|
-
AuthPresentationModule,
|
|
159
|
-
AuthMailerModule,
|
|
160
179
|
],
|
|
161
180
|
})
|
|
162
181
|
export class AuthApiModule {}
|
|
@@ -169,7 +188,8 @@ Use layered composition when you need to replace or selectively compose infrastr
|
|
|
169
188
|
`AuthMailerModule` is now adapter-only. It wraps the shared `CommonNodeMailerModule` from
|
|
170
189
|
`@anarchitects/common-nest-mailer` and no longer configures transport with
|
|
171
190
|
`MailerModule.forRootAsync(...)`.
|
|
172
|
-
Configure transport once at app root with `CommonMailerModule` when `features.
|
|
191
|
+
Configure transport once at app root with `CommonMailerModule` when `mailer.features.enabled` is `true`.
|
|
192
|
+
Disable per-domain wiring with `mailer.features.enabled: false`.
|
|
173
193
|
The shared mailer DI contract (`MailerPort`) and concrete `NodeMailerAdapter` now live in
|
|
174
194
|
`@anarchitects/common-nest-mailer`.
|
|
175
195
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anarchitects/auth-nest",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "2.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": "0.1
|
|
11
|
+
"@anarchitects/auth-ts": "1.0.1",
|
|
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": "
|
|
22
|
+
"@anarchitects/common-nest-mailer": "1.0.1"
|
|
23
23
|
},
|
|
24
24
|
"publishConfig": {
|
|
25
25
|
"access": "public"
|
|
@@ -1,25 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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;
|
|
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 {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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
|
|
11
|
-
|
|
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
|
|
20
|
-
const
|
|
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(
|
|
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,
|
|
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;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;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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"}
|
package/src/auth.module.d.ts
CHANGED
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
import { DynamicModule } from '@nestjs/common';
|
|
2
|
-
import {
|
|
3
|
-
|
|
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
|
|
5
|
+
static forRoot(options?: AuthModuleOptions): DynamicModule;
|
|
6
|
+
static forRootFromConfig(overrides?: AuthModuleOptions): DynamicModule;
|
|
14
7
|
}
|
package/src/auth.module.js
CHANGED
|
@@ -5,35 +5,55 @@ 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
|
|
16
|
-
const
|
|
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
|
+
features: {
|
|
46
|
+
...configOptions.mailer?.features,
|
|
47
|
+
...overrides.mailer?.features,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
return {
|
|
52
|
+
...moduleDefinition,
|
|
53
|
+
imports: [
|
|
54
|
+
config_1.ConfigModule.forFeature(config_2.authConfig),
|
|
55
|
+
...(moduleDefinition.imports ?? []),
|
|
56
|
+
],
|
|
37
57
|
};
|
|
38
58
|
}
|
|
39
59
|
};
|
package/src/auth.module.js.map
CHANGED
|
@@ -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
|
|
1
|
+
{"version":3,"file":"auth.module.js","sourceRoot":"","sources":["../../../../../libs/auth/nest/src/auth.module.ts"],"names":[],"mappings":";;;;;AAAA,2CAAuD;AACvD,2CAA8C;AAC9C,mEAA2D;AAC3D,iDAAwD;AACxD,qCAAwE;AAMjE,IAAM,UAAU,kBAAhB,MAAM,UAAU;IACrB,MAAM,CAAC,OAAO,CAAC,UAA6B,EAAE;QAC5C,MAAM,kBAAkB,GAAG,qCAAsB,CAAC,OAAO,CACvD,OAAO,CAAC,YAAY,CACrB,CAAC;QACF,MAAM,YAAY,GAAG,wCAAgB,CAAC,OAAO,CAAC,OAAO,CAAC,M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ACF,CAAC;IACJ,CAAC;CACF,CAAA;AApDY,gCAAU;qBAAV,UAAU;IADtB,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,UAAU,CAoDtB"}
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import { ConfigType } from '@nestjs/config';
|
|
2
|
+
export declare const DEFAULT_AUTH_JWT_SECRET = "default_jwt_secret";
|
|
3
|
+
export declare const DEFAULT_AUTH_JWT_EXPIRATION = "3600s";
|
|
4
|
+
export declare const DEFAULT_AUTH_JWT_AUDIENCE = "your_audience";
|
|
5
|
+
export declare const DEFAULT_AUTH_JWT_ISSUER = "your_issuer";
|
|
6
|
+
export declare const DEFAULT_AUTH_ENCRYPTION_ALGORITHM = "bcrypt";
|
|
7
|
+
export declare const DEFAULT_AUTH_ENCRYPTION_KEY = "default_encryption_key";
|
|
8
|
+
export declare const DEFAULT_AUTH_PERSISTENCE = "typeorm";
|
|
9
|
+
export declare const DEFAULT_AUTH_MAILER_ENABLED = true;
|
|
10
|
+
export declare const DEFAULT_AUTH_STRATEGIES: readonly ["jwt"];
|
|
2
11
|
export declare const authConfig: (() => {
|
|
3
12
|
jwtSecret: string;
|
|
4
13
|
jwtExpiration: string;
|
|
@@ -6,6 +15,9 @@ export declare const authConfig: (() => {
|
|
|
6
15
|
jwtIssuer: string;
|
|
7
16
|
encryptionAlgorithm: string;
|
|
8
17
|
encryptionKey: string;
|
|
18
|
+
persistence: string;
|
|
19
|
+
mailerEnabled: boolean;
|
|
20
|
+
authStrategies: string[];
|
|
9
21
|
}) & import("@nestjs/config").ConfigFactoryKeyHost<{
|
|
10
22
|
jwtSecret: string;
|
|
11
23
|
jwtExpiration: string;
|
|
@@ -13,6 +25,9 @@ export declare const authConfig: (() => {
|
|
|
13
25
|
jwtIssuer: string;
|
|
14
26
|
encryptionAlgorithm: string;
|
|
15
27
|
encryptionKey: string;
|
|
28
|
+
persistence: string;
|
|
29
|
+
mailerEnabled: boolean;
|
|
30
|
+
authStrategies: string[];
|
|
16
31
|
}>;
|
|
17
32
|
export type AuthConfig = ConfigType<typeof authConfig>;
|
|
18
33
|
export declare const InjectAuthConfig: () => PropertyDecorator & ParameterDecorator;
|
|
@@ -1,16 +1,47 @@
|
|
|
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_ENABLED = 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_ENABLED = true;
|
|
15
|
+
exports.DEFAULT_AUTH_STRATEGIES = ['jwt'];
|
|
16
|
+
const parseMailerEnabled = () => {
|
|
17
|
+
const value = process.env['AUTH_MAILER_ENABLED'];
|
|
18
|
+
if (value === undefined) {
|
|
19
|
+
return exports.DEFAULT_AUTH_MAILER_ENABLED;
|
|
20
|
+
}
|
|
21
|
+
return value !== 'false';
|
|
22
|
+
};
|
|
23
|
+
const parseAuthStrategies = () => {
|
|
24
|
+
const raw = process.env['AUTH_STRATEGIES'];
|
|
25
|
+
if (!raw) {
|
|
26
|
+
return [...exports.DEFAULT_AUTH_STRATEGIES];
|
|
27
|
+
}
|
|
28
|
+
const parsed = raw
|
|
29
|
+
.split(',')
|
|
30
|
+
.map((strategy) => strategy.trim())
|
|
31
|
+
.filter((strategy) => strategy.length > 0);
|
|
32
|
+
return parsed.length > 0 ? parsed : [...exports.DEFAULT_AUTH_STRATEGIES];
|
|
33
|
+
};
|
|
7
34
|
exports.authConfig = (0, config_1.registerAs)(AUTH_CONFIG_KEY, () => ({
|
|
8
|
-
jwtSecret: process.env['AUTH_JWT_SECRET']
|
|
9
|
-
jwtExpiration: process.env['AUTH_JWT_EXPIRATION']
|
|
10
|
-
jwtAudience: process.env['AUTH_JWT_AUDIENCE']
|
|
11
|
-
jwtIssuer: process.env['AUTH_JWT_ISSUER']
|
|
12
|
-
encryptionAlgorithm: process.env['AUTH_ENCRYPTION_ALGORITHM']
|
|
13
|
-
|
|
35
|
+
jwtSecret: process.env['AUTH_JWT_SECRET'] ?? exports.DEFAULT_AUTH_JWT_SECRET,
|
|
36
|
+
jwtExpiration: process.env['AUTH_JWT_EXPIRATION'] ?? exports.DEFAULT_AUTH_JWT_EXPIRATION,
|
|
37
|
+
jwtAudience: process.env['AUTH_JWT_AUDIENCE'] ?? exports.DEFAULT_AUTH_JWT_AUDIENCE,
|
|
38
|
+
jwtIssuer: process.env['AUTH_JWT_ISSUER'] ?? exports.DEFAULT_AUTH_JWT_ISSUER,
|
|
39
|
+
encryptionAlgorithm: process.env['AUTH_ENCRYPTION_ALGORITHM'] ??
|
|
40
|
+
exports.DEFAULT_AUTH_ENCRYPTION_ALGORITHM,
|
|
41
|
+
encryptionKey: process.env['AUTH_ENCRYPTION_KEY'] ?? exports.DEFAULT_AUTH_ENCRYPTION_KEY,
|
|
42
|
+
persistence: process.env['AUTH_PERSISTENCE'] ?? exports.DEFAULT_AUTH_PERSISTENCE,
|
|
43
|
+
mailerEnabled: parseMailerEnabled(),
|
|
44
|
+
authStrategies: parseAuthStrategies(),
|
|
14
45
|
}));
|
|
15
46
|
const InjectAuthConfig = () => (0, common_1.Inject)(exports.authConfig.KEY);
|
|
16
47
|
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;
|
|
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;AAClB,QAAA,uBAAuB,GAAG,oBAAoB,CAAC;AAC/C,QAAA,2BAA2B,GAAG,OAAO,CAAC;AACtC,QAAA,yBAAyB,GAAG,eAAe,CAAC;AAC5C,QAAA,uBAAuB,GAAG,aAAa,CAAC;AACxC,QAAA,iCAAiC,GAAG,QAAQ,CAAC;AAC7C,QAAA,2BAA2B,GAAG,wBAAwB,CAAC;AACvD,QAAA,wBAAwB,GAAG,SAAS,CAAC;AACrC,QAAA,2BAA2B,GAAG,IAAI,CAAC;AACnC,QAAA,uBAAuB,GAAG,CAAC,KAAK,CAAU,CAAC;AAExD,MAAM,kBAAkB,GAAG,GAAY,EAAE;IACvC,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;IACjD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,mCAA2B,CAAC;IACrC,CAAC;IAED,OAAO,KA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AE,mBAAmB,EAAE;CACtC,CAAC,CAAC,CAAC;AAIG,MAAM,gBAAgB,GAAG,GAAG,EAAE,CAAC,IAAA,eAAM,EAAC,kBAAU,CAAC,GAAG,CAAC,CAAC;AAAhD,QAAA,gBAAgB,oBAAgC"}
|
package/src/config/index.d.ts
CHANGED
package/src/config/index.js
CHANGED
package/src/config/index.js.map
CHANGED
|
@@ -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,59 @@
|
|
|
1
|
+
import type { AuthConfig } from './auth.config';
|
|
2
|
+
export type AuthPersistenceModuleOptions = {
|
|
3
|
+
persistence?: string;
|
|
4
|
+
};
|
|
5
|
+
export type ResolvedAuthPersistenceModuleOptions = {
|
|
6
|
+
persistence: string;
|
|
7
|
+
};
|
|
8
|
+
export type AuthMailerModuleFeatures = {
|
|
9
|
+
enabled?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export type AuthMailerModuleOptions = {
|
|
12
|
+
features?: AuthMailerModuleFeatures;
|
|
13
|
+
};
|
|
14
|
+
export type ResolvedAuthMailerModuleOptions = {
|
|
15
|
+
features: {
|
|
16
|
+
enabled: boolean;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export type AuthApplicationModuleOptions = {
|
|
20
|
+
authStrategies?: string[];
|
|
21
|
+
encryption?: {
|
|
22
|
+
algorithm?: 'bcrypt' | 'argon2';
|
|
23
|
+
key?: string;
|
|
24
|
+
};
|
|
25
|
+
persistence?: AuthPersistenceModuleOptions;
|
|
26
|
+
};
|
|
27
|
+
export type ResolvedAuthApplicationModuleOptions = {
|
|
28
|
+
authStrategies: string[];
|
|
29
|
+
encryption: {
|
|
30
|
+
algorithm: 'bcrypt' | 'argon2';
|
|
31
|
+
key: string;
|
|
32
|
+
};
|
|
33
|
+
persistence: ResolvedAuthPersistenceModuleOptions;
|
|
34
|
+
};
|
|
35
|
+
export type AuthPresentationModuleOptions = {
|
|
36
|
+
application?: AuthApplicationModuleOptions;
|
|
37
|
+
};
|
|
38
|
+
export type ResolvedAuthPresentationModuleOptions = {
|
|
39
|
+
application: ResolvedAuthApplicationModuleOptions;
|
|
40
|
+
};
|
|
41
|
+
export type AuthModuleFeatures = AuthMailerModuleFeatures;
|
|
42
|
+
export type AuthModuleOptions = {
|
|
43
|
+
presentation?: AuthPresentationModuleOptions;
|
|
44
|
+
mailer?: AuthMailerModuleOptions;
|
|
45
|
+
};
|
|
46
|
+
export type ResolvedAuthModuleOptions = {
|
|
47
|
+
presentation: ResolvedAuthPresentationModuleOptions;
|
|
48
|
+
mailer: ResolvedAuthMailerModuleOptions;
|
|
49
|
+
};
|
|
50
|
+
export declare const resolveAuthPersistenceModuleOptions: (options?: AuthPersistenceModuleOptions) => ResolvedAuthPersistenceModuleOptions;
|
|
51
|
+
export declare const resolveAuthMailerModuleOptions: (options?: AuthMailerModuleOptions) => ResolvedAuthMailerModuleOptions;
|
|
52
|
+
export declare const resolveAuthApplicationModuleOptions: (options?: AuthApplicationModuleOptions) => ResolvedAuthApplicationModuleOptions;
|
|
53
|
+
export declare const resolveAuthPresentationModuleOptions: (options?: AuthPresentationModuleOptions) => ResolvedAuthPresentationModuleOptions;
|
|
54
|
+
export declare const resolveAuthModuleOptions: (options?: AuthModuleOptions) => ResolvedAuthModuleOptions;
|
|
55
|
+
export declare const mapAuthConfigToPersistenceModuleOptions: (config: AuthConfig) => AuthPersistenceModuleOptions;
|
|
56
|
+
export declare const mapAuthConfigToMailerModuleOptions: (config: AuthConfig) => AuthMailerModuleOptions;
|
|
57
|
+
export declare const mapAuthConfigToApplicationModuleOptions: (config: AuthConfig) => AuthApplicationModuleOptions;
|
|
58
|
+
export declare const mapAuthConfigToPresentationModuleOptions: (config: AuthConfig) => AuthPresentationModuleOptions;
|
|
59
|
+
export declare const mapAuthConfigToAuthModuleOptions: (config: AuthConfig) => AuthModuleOptions;
|
|
@@ -0,0 +1,62 @@
|
|
|
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
|
+
features: {
|
|
11
|
+
enabled: options.features?.enabled ?? auth_config_1.DEFAULT_AUTH_MAILER_ENABLED,
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
exports.resolveAuthMailerModuleOptions = resolveAuthMailerModuleOptions;
|
|
15
|
+
const resolveAuthApplicationModuleOptions = (options = {}) => ({
|
|
16
|
+
authStrategies: options.authStrategies ?? [...auth_config_1.DEFAULT_AUTH_STRATEGIES],
|
|
17
|
+
encryption: {
|
|
18
|
+
algorithm: options.encryption?.algorithm ??
|
|
19
|
+
auth_config_1.DEFAULT_AUTH_ENCRYPTION_ALGORITHM,
|
|
20
|
+
key: options.encryption?.key ?? auth_config_1.DEFAULT_AUTH_ENCRYPTION_KEY,
|
|
21
|
+
},
|
|
22
|
+
persistence: (0, exports.resolveAuthPersistenceModuleOptions)(options.persistence),
|
|
23
|
+
});
|
|
24
|
+
exports.resolveAuthApplicationModuleOptions = resolveAuthApplicationModuleOptions;
|
|
25
|
+
const resolveAuthPresentationModuleOptions = (options = {}) => ({
|
|
26
|
+
application: (0, exports.resolveAuthApplicationModuleOptions)(options.application),
|
|
27
|
+
});
|
|
28
|
+
exports.resolveAuthPresentationModuleOptions = resolveAuthPresentationModuleOptions;
|
|
29
|
+
const resolveAuthModuleOptions = (options = {}) => ({
|
|
30
|
+
presentation: (0, exports.resolveAuthPresentationModuleOptions)(options.presentation),
|
|
31
|
+
mailer: (0, exports.resolveAuthMailerModuleOptions)(options.mailer),
|
|
32
|
+
});
|
|
33
|
+
exports.resolveAuthModuleOptions = resolveAuthModuleOptions;
|
|
34
|
+
const mapAuthConfigToPersistenceModuleOptions = (config) => ({
|
|
35
|
+
persistence: config.persistence ?? auth_config_1.DEFAULT_AUTH_PERSISTENCE,
|
|
36
|
+
});
|
|
37
|
+
exports.mapAuthConfigToPersistenceModuleOptions = mapAuthConfigToPersistenceModuleOptions;
|
|
38
|
+
const mapAuthConfigToMailerModuleOptions = (config) => ({
|
|
39
|
+
features: {
|
|
40
|
+
enabled: config.mailerEnabled ?? auth_config_1.DEFAULT_AUTH_MAILER_ENABLED,
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
exports.mapAuthConfigToMailerModuleOptions = mapAuthConfigToMailerModuleOptions;
|
|
44
|
+
const mapAuthConfigToApplicationModuleOptions = (config) => ({
|
|
45
|
+
authStrategies: config.authStrategies ?? [...auth_config_1.DEFAULT_AUTH_STRATEGIES],
|
|
46
|
+
encryption: {
|
|
47
|
+
algorithm: config.encryptionAlgorithm,
|
|
48
|
+
key: config.encryptionKey ?? auth_config_1.DEFAULT_AUTH_ENCRYPTION_KEY,
|
|
49
|
+
},
|
|
50
|
+
persistence: (0, exports.mapAuthConfigToPersistenceModuleOptions)(config),
|
|
51
|
+
});
|
|
52
|
+
exports.mapAuthConfigToApplicationModuleOptions = mapAuthConfigToApplicationModuleOptions;
|
|
53
|
+
const mapAuthConfigToPresentationModuleOptions = (config) => ({
|
|
54
|
+
application: (0, exports.mapAuthConfigToApplicationModuleOptions)(config),
|
|
55
|
+
});
|
|
56
|
+
exports.mapAuthConfigToPresentationModuleOptions = mapAuthConfigToPresentationModuleOptions;
|
|
57
|
+
const mapAuthConfigToAuthModuleOptions = (config) => ({
|
|
58
|
+
presentation: (0, exports.mapAuthConfigToPresentationModuleOptions)(config),
|
|
59
|
+
mailer: (0, exports.mapAuthConfigToMailerModuleOptions)(config),
|
|
60
|
+
});
|
|
61
|
+
exports.mapAuthConfigToAuthModuleOptions = mapAuthConfigToAuthModuleOptions;
|
|
62
|
+
//# 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;AA+DhB,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;QACR,OAAO,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,IAAI,yCAA2B;KAClE;CACF,CAAC,CAAC;AANU,QAAA,8BAA8B,kCAMxC;AAEI,MAAM,mCAAmC,GAAG,CACjD,UAAwC,EAAE,EACJ,EAAE,CAAC,CAAC;IAC1C,cAAc,EAAE,OAAO,CAAC,cAAc,IAAI,CAAC,GAAG,qCAAuB,CAAC;IACtE,UAAU,EAAE;QACV,SAAS,EACP,OAAO,CAAC,UAAU,EAAE,SAAS;YAC5B,+CAAyD;QAC5D,GAAG,E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,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,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,13 +1,43 @@
|
|
|
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
|
-
|
|
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
|
+
if (!resolvedOptions.features.enabled) {
|
|
14
|
+
return {
|
|
15
|
+
module: common_nest_mailer_1.CommonMailerNoopModule,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
module: AuthMailerModule_1,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
static forRootFromConfig(overrides = {}) {
|
|
23
|
+
const configOptions = (0, config_2.mapAuthConfigToMailerModuleOptions)((0, config_2.authConfig)());
|
|
24
|
+
const moduleDefinition = this.forRoot({
|
|
25
|
+
features: {
|
|
26
|
+
...configOptions.features,
|
|
27
|
+
...overrides.features,
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
return {
|
|
31
|
+
...moduleDefinition,
|
|
32
|
+
imports: [
|
|
33
|
+
config_1.ConfigModule.forFeature(config_2.authConfig),
|
|
34
|
+
...(moduleDefinition.imports ?? []),
|
|
35
|
+
],
|
|
36
|
+
};
|
|
37
|
+
}
|
|
8
38
|
};
|
|
9
39
|
exports.AuthMailerModule = AuthMailerModule;
|
|
10
|
-
exports.AuthMailerModule = AuthMailerModule = tslib_1.__decorate([
|
|
40
|
+
exports.AuthMailerModule = AuthMailerModule = AuthMailerModule_1 = tslib_1.__decorate([
|
|
11
41
|
(0, common_1.Global)(),
|
|
12
42
|
(0, common_1.Module)({
|
|
13
43
|
imports: [common_nest_mailer_1.CommonNodeMailerModule],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mailer.module.js","sourceRoot":"","sources":["../../../../../../libs/auth/nest/src/infrastructure-mailer/mailer.module.ts"],"names":[],"mappings":"
|
|
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,yEAG0C;AAC1C,sCAImB;AAQZ,IAAM,gBAAgB,wBAAtB,MAAM,gBAAgB;IAC3B,MAAM,CAAC,OAAO,CAAC,UAAmC,EAAE;QAClD,MAAM,eAAe,GAAG,IAAA,uCAA8B,EAAC,OAAO,CAAC,CAAC;QAEhE,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;YACtC,OAAO;gBACL,MAAM,EAAE,2CAAsB;aAC/B,CAAC;QACJ,CAAC;QAED,OAAO;YACL,MAAM,EAAE,kBAAgB;SACzB,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,QAAQ,EAAE;gBACR,GAAG,aAAa,CAAC,QAAQ;gBACzB,GAAG,SAAS,CAAC,QAAQ;aACtB;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;AAlCY,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,CAkC5B"}
|
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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;
|
|
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
|
|
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
|
|
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
|
-
|
|
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(
|
|
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: ${
|
|
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;
|
|
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"}
|
|
@@ -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
|
-
|
|
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":"
|
|
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,EAA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