@anarchitects/auth-nest 0.0.1 → 0.4.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 +217 -18
- package/package.json +26 -12
- 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 +6 -26
- package/src/application/application.module.js +47 -24
- package/src/application/application.module.js.map +1 -1
- package/src/application/index.d.ts +1 -0
- package/src/auth.module.d.ts +7 -0
- package/src/auth.module.js +60 -0
- package/src/auth.module.js.map +1 -0
- package/src/config/auth.config.d.ts +16 -0
- package/src/config/auth.config.js +44 -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 +57 -0
- package/src/config/module-options.js +58 -0
- package/src/config/module-options.js.map +1 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -0
- package/src/index.js.map +1 -1
- package/src/infrastructure-mailer/adapters/node-mailer.adapter.d.ts +1 -8
- package/src/infrastructure-mailer/adapters/node-mailer.adapter.js +2 -19
- package/src/infrastructure-mailer/adapters/node-mailer.adapter.js.map +1 -1
- package/src/infrastructure-mailer/index.d.ts +1 -1
- package/src/infrastructure-mailer/index.js +0 -1
- package/src/infrastructure-mailer/index.js.map +1 -1
- package/src/infrastructure-mailer/mailer.module.d.ts +5 -1
- package/src/infrastructure-mailer/mailer.module.js +36 -17
- package/src/infrastructure-mailer/mailer.module.js.map +1 -1
- package/src/infrastructure-persistence/index.d.ts +2 -0
- package/src/infrastructure-persistence/index.js +1 -0
- package/src/infrastructure-persistence/index.js.map +1 -1
- package/src/infrastructure-persistence/migrations/{1720200000000-create-invalidated-tokens-cache.table.d.ts → 1720200000000-create-auth-schema.d.ts} +1 -1
- package/src/infrastructure-persistence/migrations/1720200000000-create-auth-schema.js +312 -0
- package/src/infrastructure-persistence/migrations/1720200000000-create-auth-schema.js.map +1 -0
- package/src/infrastructure-persistence/persistence.module-definition.d.ts +4 -9
- package/src/infrastructure-persistence/persistence.module-definition.js.map +1 -1
- package/src/infrastructure-persistence/persistence.module.d.ts +5 -5
- package/src/infrastructure-persistence/persistence.module.js +33 -22
- package/src/infrastructure-persistence/persistence.module.js.map +1 -1
- package/src/presentation/controllers/auth.controller.d.ts +9 -27
- package/src/presentation/controllers/auth.controller.js +18 -30
- package/src/presentation/controllers/auth.controller.js.map +1 -1
- package/src/presentation/index.d.ts +1 -0
- package/src/presentation/presentation.module.d.ts +5 -1
- package/src/presentation/presentation.module.js +42 -5
- package/src/presentation/presentation.module.js.map +1 -1
- package/src/infrastructure-mailer/adapters/mailer.adapter.d.ts +0 -4
- package/src/infrastructure-mailer/adapters/mailer.adapter.js +0 -7
- package/src/infrastructure-mailer/adapters/mailer.adapter.js.map +0 -1
- package/src/infrastructure-persistence/migrations/1720200000000-create-invalidated-tokens-cache.table.js +0 -29
- package/src/infrastructure-persistence/migrations/1720200000000-create-invalidated-tokens-cache.table.js.map +0 -1
|
@@ -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']
|
|
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
|
-
|
|
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;
|
|
1
|
+
{"version":3,"file":"auth.config.js","source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AC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAE7C,OAAO,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,+BAAuB,CAAC,CAAC;AACnE,CAAC,CAAC;AAEW,QAAA,UAAU,GAAG,IAAA,mBAAU,EAAC,eAAe,EAAE,GAAG,EAAE,CAAC,CAAC;IAC3D,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,IAAI,+BAAuB;IACpE,aAAa,EACX,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,IAAI,mCAA2B;IACnE,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,iCAAyB;IAC1E,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,IAAI,+BAAuB;IACpE,mBAAmB,EACjB,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC;QACxC,yCAAiC;IACnC,aAAa,EACX,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,IAAI,mCAA2B;IACnE,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,IAAI,gCAAwB;IACxE,cAAc,EAAE,mBAAmB,EAAE;IACrC,cAAc,EAAE,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,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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|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./auth.module"), exports);
|
|
4
5
|
tslib_1.__exportStar(require("./application"), exports);
|
|
5
6
|
tslib_1.__exportStar(require("./presentation"), exports);
|
|
6
7
|
tslib_1.__exportStar(require("./infrastructure-persistence"), exports);
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/auth/nest/src/index.ts"],"names":[],"mappings":";;;AAAA,wDAA8B;AAC9B,yDAA+B;AAC/B,uEAA6C;AAC7C,kEAAwC;AACxC,mDAAyB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/auth/nest/src/index.ts"],"names":[],"mappings":";;;AAAA,wDAA8B;AAC9B,wDAA8B;AAC9B,yDAA+B;AAC/B,uEAA6C;AAC7C,kEAAwC;AACxC,mDAAyB"}
|
|
@@ -1,8 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { MailerAdapter } from './mailer.adapter';
|
|
3
|
-
export declare class NodeMailerAdapter implements MailerAdapter {
|
|
4
|
-
private readonly mailer;
|
|
5
|
-
constructor(mailer: MailerService);
|
|
6
|
-
send(to: string, subject: string, html: string): Promise<SentMessageInfo>;
|
|
7
|
-
sendTemplate(to: string, subject: string, template: string, context?: Record<string, unknown>): Promise<SentMessageInfo>;
|
|
8
|
-
}
|
|
1
|
+
export { NodeMailerAdapter } from '@anarchitects/common-nest-mailer';
|
|
@@ -1,23 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NodeMailerAdapter = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const mailer_1 = require("@nestjs-modules/mailer");
|
|
7
|
-
let NodeMailerAdapter = class NodeMailerAdapter {
|
|
8
|
-
constructor(mailer) {
|
|
9
|
-
this.mailer = mailer;
|
|
10
|
-
}
|
|
11
|
-
async send(to, subject, html) {
|
|
12
|
-
return await this.mailer.sendMail({ to, subject, html });
|
|
13
|
-
}
|
|
14
|
-
async sendTemplate(to, subject, template, context) {
|
|
15
|
-
return await this.mailer.sendMail({ to, subject, template, context });
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
exports.NodeMailerAdapter = NodeMailerAdapter;
|
|
19
|
-
exports.NodeMailerAdapter = NodeMailerAdapter = tslib_1.__decorate([
|
|
20
|
-
(0, common_1.Injectable)(),
|
|
21
|
-
tslib_1.__metadata("design:paramtypes", [mailer_1.MailerService])
|
|
22
|
-
], NodeMailerAdapter);
|
|
4
|
+
var common_nest_mailer_1 = require("@anarchitects/common-nest-mailer");
|
|
5
|
+
Object.defineProperty(exports, "NodeMailerAdapter", { enumerable: true, get: function () { return common_nest_mailer_1.NodeMailerAdapter; } });
|
|
23
6
|
//# sourceMappingURL=node-mailer.adapter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-mailer.adapter.js","sourceRoot":"","sources":["../../../../../../../libs/auth/nest/src/infrastructure-mailer/adapters/node-mailer.adapter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"node-mailer.adapter.js","sourceRoot":"","sources":["../../../../../../../libs/auth/nest/src/infrastructure-mailer/adapters/node-mailer.adapter.ts"],"names":[],"mappings":";;;AAAA,uEAAqE;AAA5D,uHAAA,iBAAiB,OAAA"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./adapters/mailer.adapter"), exports);
|
|
5
4
|
tslib_1.__exportStar(require("./adapters/node-mailer.adapter"), exports);
|
|
6
5
|
tslib_1.__exportStar(require("./mailer.module"), exports);
|
|
7
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../libs/auth/nest/src/infrastructure-mailer/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../libs/auth/nest/src/infrastructure-mailer/index.ts"],"names":[],"mappings":";;;AAAA,yEAA+C;AAC/C,0DAAgC"}
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { DynamicModule } from '@nestjs/common';
|
|
2
|
+
import type { AuthMailerModuleOptions } from '../config';
|
|
3
|
+
export declare class AuthMailerModule {
|
|
4
|
+
static forRoot(options?: AuthMailerModuleOptions): DynamicModule;
|
|
5
|
+
static forRootFromConfig(overrides?: AuthMailerModuleOptions): DynamicModule;
|
|
2
6
|
}
|
|
@@ -1,23 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var AuthMailerModule_1;
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
+
exports.AuthMailerModule = void 0;
|
|
4
5
|
const tslib_1 = require("tslib");
|
|
5
6
|
const common_1 = require("@nestjs/common");
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
|
|
7
|
+
const config_1 = require("@nestjs/config");
|
|
8
|
+
const common_nest_mailer_1 = require("@anarchitects/common-nest-mailer");
|
|
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
|
+
}
|
|
9
36
|
};
|
|
10
|
-
exports.
|
|
11
|
-
exports.
|
|
12
|
-
(0, common_1.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
{
|
|
16
|
-
provide: mailer_adapter_1.MailerAdapter,
|
|
17
|
-
useExisting: node_mailer_adapter_1.NodeMailerAdapter,
|
|
18
|
-
},
|
|
19
|
-
],
|
|
20
|
-
exports: [mailer_adapter_1.MailerAdapter],
|
|
21
|
-
})
|
|
22
|
-
], MailerModule);
|
|
37
|
+
exports.AuthMailerModule = AuthMailerModule;
|
|
38
|
+
exports.AuthMailerModule = AuthMailerModule = AuthMailerModule_1 = tslib_1.__decorate([
|
|
39
|
+
(0, common_1.Global)(),
|
|
40
|
+
(0, common_1.Module)({})
|
|
41
|
+
], AuthMailerModule);
|
|
23
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":"
|
|
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"}
|
|
@@ -3,4 +3,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
tslib_1.__exportStar(require("./persistence.module"), exports);
|
|
5
5
|
tslib_1.__exportStar(require("./repositories/auth-user.repository"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./migrations/1720200000000-create-auth-schema"), exports);
|
|
6
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../libs/auth/nest/src/infrastructure-persistence/index.ts"],"names":[],"mappings":";;;AAAA,+DAAqC;AACrC,8EAAoD"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../libs/auth/nest/src/infrastructure-persistence/index.ts"],"names":[],"mappings":";;;AAAA,+DAAqC;AACrC,8EAAoD;AACpD,wFAA8D"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
2
|
-
export declare class
|
|
2
|
+
export declare class CreateAuthSchema1720200000000 implements MigrationInterface {
|
|
3
3
|
name: string;
|
|
4
4
|
up(queryRunner: QueryRunner): Promise<void>;
|
|
5
5
|
down(queryRunner: QueryRunner): Promise<void>;
|