@webiny/api-mailer 6.0.0-beta.0 → 6.0.0-rc.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 +10 -13
- package/constants.d.ts +1 -0
- package/constants.js +3 -0
- package/constants.js.map +1 -0
- package/domain/Encryption/abstractions.d.ts +8 -0
- package/domain/Encryption/abstractions.js +4 -0
- package/domain/Encryption/abstractions.js.map +1 -0
- package/domain/MailTransport/abstractions.d.ts +18 -0
- package/domain/MailTransport/abstractions.js +5 -0
- package/domain/MailTransport/abstractions.js.map +1 -0
- package/domain/MailerService/abstractions.d.ts +19 -0
- package/domain/MailerService/abstractions.js +4 -0
- package/domain/MailerService/abstractions.js.map +1 -0
- package/domain/MailerService/errors.d.ts +16 -0
- package/domain/MailerService/errors.js +30 -0
- package/domain/MailerService/errors.js.map +1 -0
- package/domain/errors.d.ts +24 -0
- package/domain/errors.js +44 -0
- package/domain/errors.js.map +1 -0
- package/features/DummyTransport/DummyMailTransport.d.ts +9 -0
- package/features/DummyTransport/DummyMailTransport.js +12 -0
- package/features/DummyTransport/DummyMailTransport.js.map +1 -0
- package/features/DummyTransport/DummyMailTransportFactory.d.ts +8 -0
- package/features/DummyTransport/DummyMailTransportFactory.js +13 -0
- package/features/DummyTransport/DummyMailTransportFactory.js.map +1 -0
- package/features/DummyTransport/feature.d.ts +1 -0
- package/features/DummyTransport/feature.js +10 -0
- package/features/DummyTransport/feature.js.map +1 -0
- package/features/Encryption/PasswordEncryption.d.ts +9 -0
- package/features/Encryption/PasswordEncryption.js +23 -0
- package/features/Encryption/PasswordEncryption.js.map +1 -0
- package/features/Encryption/feature.d.ts +1 -0
- package/features/Encryption/feature.js +10 -0
- package/features/Encryption/feature.js.map +1 -0
- package/features/Encryption/utils/password.js +56 -0
- package/features/Encryption/utils/password.js.map +1 -0
- package/features/Encryption/utils/secret.js +11 -0
- package/features/Encryption/utils/secret.js.map +1 -0
- package/features/GetSettings/GetSettingsRepository.d.ts +15 -0
- package/features/GetSettings/GetSettingsRepository.js +39 -0
- package/features/GetSettings/GetSettingsRepository.js.map +1 -0
- package/features/GetSettings/GetSettingsUseCase.d.ts +12 -0
- package/features/GetSettings/GetSettingsUseCase.js +15 -0
- package/features/GetSettings/GetSettingsUseCase.js.map +1 -0
- package/features/GetSettings/abstractions.d.ts +16 -0
- package/features/GetSettings/abstractions.js +5 -0
- package/features/GetSettings/abstractions.js.map +1 -0
- package/features/GetSettings/feature.d.ts +1 -0
- package/features/GetSettings/feature.js +12 -0
- package/features/GetSettings/feature.js.map +1 -0
- package/features/GetSettings/index.d.ts +1 -0
- package/features/GetSettings/index.js +3 -0
- package/features/GetSettings/index.js.map +1 -0
- package/features/MailerService/MailerService.d.ts +15 -0
- package/features/MailerService/MailerService.js +52 -0
- package/features/MailerService/MailerService.js.map +1 -0
- package/features/MailerService/TransportFactory.d.ts +2 -0
- package/features/MailerService/TransportFactory.js +31 -0
- package/features/MailerService/TransportFactory.js.map +1 -0
- package/features/MailerService/feature.d.ts +1 -0
- package/features/MailerService/feature.js +10 -0
- package/features/MailerService/feature.js.map +1 -0
- package/features/SaveSettings/SaveSettingsRepository.d.ts +13 -0
- package/features/SaveSettings/SaveSettingsRepository.js +57 -0
- package/features/SaveSettings/SaveSettingsRepository.js.map +1 -0
- package/features/SaveSettings/SaveSettingsUseCase.d.ts +14 -0
- package/features/SaveSettings/SaveSettingsUseCase.js +51 -0
- package/features/SaveSettings/SaveSettingsUseCase.js.map +1 -0
- package/features/SaveSettings/abstractions.d.ts +53 -0
- package/features/SaveSettings/abstractions.js +11 -0
- package/features/SaveSettings/abstractions.js.map +1 -0
- package/features/SaveSettings/events.d.ts +10 -0
- package/features/SaveSettings/events.js +16 -0
- package/features/SaveSettings/events.js.map +1 -0
- package/features/SaveSettings/feature.d.ts +1 -0
- package/features/SaveSettings/feature.js +12 -0
- package/features/SaveSettings/feature.js.map +1 -0
- package/features/SaveSettings/index.d.ts +1 -0
- package/features/SaveSettings/index.js +3 -0
- package/features/SaveSettings/index.js.map +1 -0
- package/features/SaveSettings/validation.d.ts +23 -0
- package/features/SaveSettings/validation.js +19 -0
- package/features/SaveSettings/validation.js.map +1 -0
- package/features/SendMail/SendMailUseCase.d.ts +16 -0
- package/features/SendMail/SendMailUseCase.js +62 -0
- package/features/SendMail/SendMailUseCase.js.map +1 -0
- package/features/SendMail/abstractions.d.ts +45 -0
- package/features/SendMail/abstractions.js +11 -0
- package/features/SendMail/abstractions.js.map +1 -0
- package/features/SendMail/events.d.ts +14 -0
- package/features/SendMail/events.js +22 -0
- package/features/SendMail/events.js.map +1 -0
- package/features/SendMail/feature.d.ts +1 -0
- package/features/SendMail/feature.js +10 -0
- package/features/SendMail/feature.js.map +1 -0
- package/features/SmtpTransport/SmtpConfig.d.ts +6 -0
- package/features/SmtpTransport/SmtpConfig.js +29 -0
- package/features/SmtpTransport/SmtpConfig.js.map +1 -0
- package/features/SmtpTransport/SmtpMailTransport.d.ts +18 -0
- package/features/SmtpTransport/SmtpMailTransport.js +61 -0
- package/features/SmtpTransport/SmtpMailTransport.js.map +1 -0
- package/features/SmtpTransport/SmtpMailTransportFactory.d.ts +9 -0
- package/features/SmtpTransport/SmtpMailTransportFactory.js +14 -0
- package/features/SmtpTransport/SmtpMailTransportFactory.js.map +1 -0
- package/features/SmtpTransport/feature.d.ts +1 -0
- package/features/SmtpTransport/feature.js +10 -0
- package/features/SmtpTransport/feature.js.map +1 -0
- package/graphql/settings.d.ts +2 -2
- package/graphql/settings.js +46 -34
- package/graphql/settings.js.map +1 -1
- package/index.d.ts +4 -5
- package/index.js +22 -78
- package/index.js.map +1 -1
- package/package.json +31 -37
- package/types.d.ts +1 -108
- package/types.js +1 -5
- package/types.js.map +1 -1
- package/context.d.ts +0 -3
- package/context.js +0 -20
- package/context.js.map +0 -1
- package/crud/settings/hooks.d.ts +0 -5
- package/crud/settings/hooks.js +0 -42
- package/crud/settings/hooks.js.map +0 -1
- package/crud/settings/model.d.ts +0 -2
- package/crud/settings/model.js +0 -72
- package/crud/settings/model.js.map +0 -1
- package/crud/settings/password.js +0 -55
- package/crud/settings/password.js.map +0 -1
- package/crud/settings/secret.js +0 -19
- package/crud/settings/secret.js.map +0 -1
- package/crud/settings/transform.d.ts +0 -13
- package/crud/settings/transform.js +0 -46
- package/crud/settings/transform.js.map +0 -1
- package/crud/settings/validation.d.ts +0 -45
- package/crud/settings/validation.js +0 -28
- package/crud/settings/validation.js.map +0 -1
- package/crud/settings.crud.d.ts +0 -5
- package/crud/settings.crud.js +0 -269
- package/crud/settings.crud.js.map +0 -1
- package/crud/transport/onTransportBeforeSend.d.ts +0 -7
- package/crud/transport/onTransportBeforeSend.js +0 -62
- package/crud/transport/onTransportBeforeSend.js.map +0 -1
- package/crud/transporter.crud.d.ts +0 -2
- package/crud/transporter.crud.js +0 -158
- package/crud/transporter.crud.js.map +0 -1
- package/graphql/index.d.ts +0 -1
- package/graphql/index.js +0 -13
- package/graphql/index.js.map +0 -1
- package/plugins/CreateTransportPlugin.d.ts +0 -17
- package/plugins/CreateTransportPlugin.js +0 -24
- package/plugins/CreateTransportPlugin.js.map +0 -1
- package/plugins/index.d.ts +0 -1
- package/plugins/index.js +0 -18
- package/plugins/index.js.map +0 -1
- package/transports/createDummyTransport.d.ts +0 -5
- package/transports/createDummyTransport.js +0 -25
- package/transports/createDummyTransport.js.map +0 -1
- package/transports/createSmtpTransport.d.ts +0 -12
- package/transports/createSmtpTransport.js +0 -94
- package/transports/createSmtpTransport.js.map +0 -1
- package/transports/index.d.ts +0 -2
- package/transports/index.js +0 -29
- package/transports/index.js.map +0 -1
- /package/{crud/settings → features/Encryption/utils}/password.d.ts +0 -0
- /package/{crud/settings → features/Encryption/utils}/secret.d.ts +0 -0
package/README.md
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
# @webiny/api-mailer
|
|
2
|
-
|
|
3
|
-
[!
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
## Documentation
|
|
14
|
-
[Webiny Documentation > Overview > Features > Mailer](https://www.webiny.com/docs/overview/features/mailer)
|
|
2
|
+
|
|
3
|
+
> [!NOTE]
|
|
4
|
+
> This package is part of the [Webiny](https://www.webiny.com) monorepo.
|
|
5
|
+
> It’s **included in every Webiny project by default** and is not meant to be used as a standalone package.
|
|
6
|
+
|
|
7
|
+
📘 **Documentation:** [https://www.webiny.com/docs](https://www.webiny.com/docs)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
_This README file is automatically generated during the publish process._
|
package/constants.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const MAILER_TRANSPORT_SETTINGS = "Mailer/Settings/Transport";
|
package/constants.js
ADDED
package/constants.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["MAILER_TRANSPORT_SETTINGS"],"sources":["constants.ts"],"sourcesContent":["export const MAILER_TRANSPORT_SETTINGS = \"Mailer/Settings/Transport\";\n"],"mappings":"AAAA,OAAO,MAAMA,yBAAyB,GAAG,2BAA2B","ignoreList":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface IEncryption {
|
|
2
|
+
encrypt(value: string): Promise<string>;
|
|
3
|
+
decrypt(value: string): Promise<string>;
|
|
4
|
+
}
|
|
5
|
+
export declare const Encryption: import("@webiny/di").Abstraction<IEncryption>;
|
|
6
|
+
export declare namespace Encryption {
|
|
7
|
+
type Interface = IEncryption;
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createAbstraction","Encryption"],"sources":["abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\n\nexport interface IEncryption {\n encrypt(value: string): Promise<string>;\n decrypt(value: string): Promise<string>;\n}\n\nexport const Encryption = createAbstraction<IEncryption>(\"Encryption\");\n\nexport namespace Encryption {\n export type Interface = IEncryption;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AAOvD,OAAO,MAAMC,UAAU,GAAGD,iBAAiB,CAAc,YAAY,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { TransportSendData, TransportSendResponse, TransportSettings } from "../../types.js";
|
|
2
|
+
export interface IMailTransport {
|
|
3
|
+
name: string;
|
|
4
|
+
send(params: TransportSendData): Promise<TransportSendResponse>;
|
|
5
|
+
}
|
|
6
|
+
export declare const MailTransport: import("@webiny/di").Abstraction<IMailTransport>;
|
|
7
|
+
export declare namespace MailTransport {
|
|
8
|
+
type Interface = IMailTransport;
|
|
9
|
+
type SendParams = TransportSendData;
|
|
10
|
+
}
|
|
11
|
+
export interface IMailTransportFactory {
|
|
12
|
+
createTransport(settings: TransportSettings): Promise<IMailTransport>;
|
|
13
|
+
}
|
|
14
|
+
export declare const MailTransportFactory: import("@webiny/di").Abstraction<IMailTransportFactory>;
|
|
15
|
+
export declare namespace MailTransportFactory {
|
|
16
|
+
type Interface = IMailTransportFactory;
|
|
17
|
+
type Return = Promise<IMailTransport>;
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createAbstraction","MailTransport","MailTransportFactory"],"sources":["abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { TransportSendData, TransportSendResponse, TransportSettings } from \"~/types.js\";\n\nexport interface IMailTransport {\n name: string;\n send(params: TransportSendData): Promise<TransportSendResponse>;\n}\n\nexport const MailTransport = createAbstraction<IMailTransport>(\"MailTransport\");\n\nexport namespace MailTransport {\n export type Interface = IMailTransport;\n export type SendParams = TransportSendData;\n}\n\nexport interface IMailTransportFactory {\n createTransport(settings: TransportSettings): Promise<IMailTransport>;\n}\n\nexport const MailTransportFactory =\n createAbstraction<IMailTransportFactory>(\"MailTransportFactory\");\n\nexport namespace MailTransportFactory {\n export type Interface = IMailTransportFactory;\n export type Return = Promise<IMailTransport>;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AAQvD,OAAO,MAAMC,aAAa,GAAGD,iBAAiB,CAAiB,eAAe,CAAC;AAW/E,OAAO,MAAME,oBAAoB,GAC7BF,iBAAiB,CAAwB,sBAAsB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import type { TransportSendData, TransportSendResponse } from "../../types.js";
|
|
3
|
+
import { NoTransportAvailableError, NoSettingsConfiguredError, TransportSendError } from "./errors.js";
|
|
4
|
+
export interface IMailerServiceErrors {
|
|
5
|
+
noTransport: NoTransportAvailableError;
|
|
6
|
+
noSettings: NoSettingsConfiguredError;
|
|
7
|
+
transportSend: TransportSendError;
|
|
8
|
+
}
|
|
9
|
+
type MailerServiceError = IMailerServiceErrors[keyof IMailerServiceErrors];
|
|
10
|
+
export interface IMailerService {
|
|
11
|
+
sendMail<T = any>(data: TransportSendData): Promise<Result<TransportSendResponse<T>, MailerServiceError>>;
|
|
12
|
+
}
|
|
13
|
+
export declare const MailerService: import("@webiny/di").Abstraction<IMailerService>;
|
|
14
|
+
export declare namespace MailerService {
|
|
15
|
+
type Interface = IMailerService;
|
|
16
|
+
type Return<T = any> = Promise<Result<TransportSendResponse<T>, MailerServiceError>>;
|
|
17
|
+
type Error = MailerServiceError;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createAbstraction","MailerService"],"sources":["abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport type { TransportSendData, TransportSendResponse } from \"~/types.js\";\nimport {\n NoTransportAvailableError,\n NoSettingsConfiguredError,\n TransportSendError\n} from \"./errors.js\";\n\nexport interface IMailerServiceErrors {\n noTransport: NoTransportAvailableError;\n noSettings: NoSettingsConfiguredError;\n transportSend: TransportSendError;\n}\n\ntype MailerServiceError = IMailerServiceErrors[keyof IMailerServiceErrors];\n\nexport interface IMailerService {\n sendMail<T = any>(\n data: TransportSendData\n ): Promise<Result<TransportSendResponse<T>, MailerServiceError>>;\n}\n\nexport const MailerService = createAbstraction<IMailerService>(\"MailerService\");\n\nexport namespace MailerService {\n export type Interface = IMailerService;\n export type Return<T = any> = Promise<Result<TransportSendResponse<T>, MailerServiceError>>;\n export type Error = MailerServiceError;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AAuBvD,OAAO,MAAMC,aAAa,GAAGD,iBAAiB,CAAiB,eAAe,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BaseError } from "@webiny/feature/api";
|
|
2
|
+
import type { TransportSendResponse } from "../../types.js";
|
|
3
|
+
export declare class NoTransportAvailableError extends BaseError {
|
|
4
|
+
readonly code: "Mailer/MailerService/NoTransportAvailable";
|
|
5
|
+
constructor();
|
|
6
|
+
}
|
|
7
|
+
export declare class NoSettingsConfiguredError extends BaseError {
|
|
8
|
+
readonly code: "Mailer/MailerService/NoSettingsConfigured";
|
|
9
|
+
constructor();
|
|
10
|
+
}
|
|
11
|
+
export declare class TransportSendError extends BaseError<{
|
|
12
|
+
error: TransportSendResponse["error"];
|
|
13
|
+
}> {
|
|
14
|
+
readonly code: "Mailer/MailerService/TransportSendError";
|
|
15
|
+
constructor(error: NonNullable<TransportSendResponse["error"]>);
|
|
16
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { BaseError } from "@webiny/feature/api";
|
|
2
|
+
export class NoTransportAvailableError extends BaseError {
|
|
3
|
+
code = "Mailer/MailerService/NoTransportAvailable";
|
|
4
|
+
constructor() {
|
|
5
|
+
super({
|
|
6
|
+
message: "There is no transport available."
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export class NoSettingsConfiguredError extends BaseError {
|
|
11
|
+
code = "Mailer/MailerService/NoSettingsConfigured";
|
|
12
|
+
constructor() {
|
|
13
|
+
super({
|
|
14
|
+
message: "No mailer settings are configured and no environment variables are set."
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export class TransportSendError extends BaseError {
|
|
19
|
+
code = "Mailer/MailerService/TransportSendError";
|
|
20
|
+
constructor(error) {
|
|
21
|
+
super({
|
|
22
|
+
message: error.message,
|
|
23
|
+
data: {
|
|
24
|
+
error
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["BaseError","NoTransportAvailableError","code","constructor","message","NoSettingsConfiguredError","TransportSendError","error","data"],"sources":["errors.ts"],"sourcesContent":["import { BaseError } from \"@webiny/feature/api\";\nimport type { TransportSendResponse } from \"~/types.js\";\n\nexport class NoTransportAvailableError extends BaseError {\n override readonly code = \"Mailer/MailerService/NoTransportAvailable\" as const;\n\n constructor() {\n super({\n message: \"There is no transport available.\"\n });\n }\n}\n\nexport class NoSettingsConfiguredError extends BaseError {\n override readonly code = \"Mailer/MailerService/NoSettingsConfigured\" as const;\n\n constructor() {\n super({\n message: \"No mailer settings are configured and no environment variables are set.\"\n });\n }\n}\n\nexport class TransportSendError extends BaseError<{ error: TransportSendResponse[\"error\"] }> {\n override readonly code = \"Mailer/MailerService/TransportSendError\" as const;\n\n constructor(error: NonNullable<TransportSendResponse[\"error\"]>) {\n super({\n message: error.message,\n data: {\n error\n }\n });\n }\n}\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,qBAAqB;AAG/C,OAAO,MAAMC,yBAAyB,SAASD,SAAS,CAAC;EACnCE,IAAI,GAAG,2CAA2C;EAEpEC,WAAWA,CAAA,EAAG;IACV,KAAK,CAAC;MACFC,OAAO,EAAE;IACb,CAAC,CAAC;EACN;AACJ;AAEA,OAAO,MAAMC,yBAAyB,SAASL,SAAS,CAAC;EACnCE,IAAI,GAAG,2CAA2C;EAEpEC,WAAWA,CAAA,EAAG;IACV,KAAK,CAAC;MACFC,OAAO,EAAE;IACb,CAAC,CAAC;EACN;AACJ;AAEA,OAAO,MAAME,kBAAkB,SAASN,SAAS,CAA4C;EACvEE,IAAI,GAAG,yCAAyC;EAElEC,WAAWA,CAACI,KAAkD,EAAE;IAC5D,KAAK,CAAC;MACFH,OAAO,EAAEG,KAAK,CAACH,OAAO;MACtBI,IAAI,EAAE;QACFD;MACJ;IACJ,CAAC,CAAC;EACN;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { BaseError } from "@webiny/feature/api";
|
|
2
|
+
import type { ZodError } from "zod";
|
|
3
|
+
export declare class MailValidationError extends BaseError<{
|
|
4
|
+
errors: ZodError["errors"];
|
|
5
|
+
}> {
|
|
6
|
+
readonly code: "Mailer/SendMail/Validation";
|
|
7
|
+
constructor(errors: ZodError["errors"]);
|
|
8
|
+
}
|
|
9
|
+
export declare class SettingsValidationError extends BaseError<{
|
|
10
|
+
errors: ZodError["errors"];
|
|
11
|
+
}> {
|
|
12
|
+
readonly code: "Mailer/Settings/Validation";
|
|
13
|
+
constructor(errors: ZodError["errors"]);
|
|
14
|
+
}
|
|
15
|
+
export declare class SettingsNotAuthorized extends BaseError {
|
|
16
|
+
readonly code: "Mailer/Settings/NotAuthorized";
|
|
17
|
+
constructor();
|
|
18
|
+
}
|
|
19
|
+
export declare class SettingsPersistenceError extends BaseError<{
|
|
20
|
+
error: Error;
|
|
21
|
+
}> {
|
|
22
|
+
readonly code: "Mailer/Settings/Persistence";
|
|
23
|
+
constructor(error: Error);
|
|
24
|
+
}
|
package/domain/errors.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { BaseError } from "@webiny/feature/api";
|
|
2
|
+
export class MailValidationError extends BaseError {
|
|
3
|
+
code = "Mailer/SendMail/Validation";
|
|
4
|
+
constructor(errors) {
|
|
5
|
+
super({
|
|
6
|
+
message: "Email params are invalid.",
|
|
7
|
+
data: {
|
|
8
|
+
errors
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export class SettingsValidationError extends BaseError {
|
|
14
|
+
code = "Mailer/Settings/Validation";
|
|
15
|
+
constructor(errors) {
|
|
16
|
+
super({
|
|
17
|
+
message: "Settings validation failed.",
|
|
18
|
+
data: {
|
|
19
|
+
errors
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export class SettingsNotAuthorized extends BaseError {
|
|
25
|
+
code = "Mailer/Settings/NotAuthorized";
|
|
26
|
+
constructor() {
|
|
27
|
+
super({
|
|
28
|
+
message: "Not allowed to update the mailer settings."
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export class SettingsPersistenceError extends BaseError {
|
|
33
|
+
code = "Mailer/Settings/Persistence";
|
|
34
|
+
constructor(error) {
|
|
35
|
+
super({
|
|
36
|
+
message: "Failed to persist settings.",
|
|
37
|
+
data: {
|
|
38
|
+
error
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["BaseError","MailValidationError","code","constructor","errors","message","data","SettingsValidationError","SettingsNotAuthorized","SettingsPersistenceError","error"],"sources":["errors.ts"],"sourcesContent":["import { BaseError } from \"@webiny/feature/api\";\nimport type { ZodError } from \"zod\";\n\nexport class MailValidationError extends BaseError<{ errors: ZodError[\"errors\"] }> {\n override readonly code = \"Mailer/SendMail/Validation\" as const;\n\n constructor(errors: ZodError[\"errors\"]) {\n super({\n message: \"Email params are invalid.\",\n data: {\n errors\n }\n });\n }\n}\n\nexport class SettingsValidationError extends BaseError<{ errors: ZodError[\"errors\"] }> {\n override readonly code = \"Mailer/Settings/Validation\" as const;\n\n constructor(errors: ZodError[\"errors\"]) {\n super({\n message: \"Settings validation failed.\",\n data: {\n errors\n }\n });\n }\n}\n\nexport class SettingsNotAuthorized extends BaseError {\n override readonly code = \"Mailer/Settings/NotAuthorized\" as const;\n\n constructor() {\n super({ message: \"Not allowed to update the mailer settings.\" });\n }\n}\n\nexport class SettingsPersistenceError extends BaseError<{ error: Error }> {\n override readonly code = \"Mailer/Settings/Persistence\" as const;\n\n constructor(error: Error) {\n super({\n message: \"Failed to persist settings.\",\n data: {\n error\n }\n });\n }\n}\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,qBAAqB;AAG/C,OAAO,MAAMC,mBAAmB,SAASD,SAAS,CAAiC;EAC7DE,IAAI,GAAG,4BAA4B;EAErDC,WAAWA,CAACC,MAA0B,EAAE;IACpC,KAAK,CAAC;MACFC,OAAO,EAAE,2BAA2B;MACpCC,IAAI,EAAE;QACFF;MACJ;IACJ,CAAC,CAAC;EACN;AACJ;AAEA,OAAO,MAAMG,uBAAuB,SAASP,SAAS,CAAiC;EACjEE,IAAI,GAAG,4BAA4B;EAErDC,WAAWA,CAACC,MAA0B,EAAE;IACpC,KAAK,CAAC;MACFC,OAAO,EAAE,6BAA6B;MACtCC,IAAI,EAAE;QACFF;MACJ;IACJ,CAAC,CAAC;EACN;AACJ;AAEA,OAAO,MAAMI,qBAAqB,SAASR,SAAS,CAAC;EAC/BE,IAAI,GAAG,+BAA+B;EAExDC,WAAWA,CAAA,EAAG;IACV,KAAK,CAAC;MAAEE,OAAO,EAAE;IAA6C,CAAC,CAAC;EACpE;AACJ;AAEA,OAAO,MAAMI,wBAAwB,SAAST,SAAS,CAAmB;EACpDE,IAAI,GAAG,6BAA6B;EAEtDC,WAAWA,CAACO,KAAY,EAAE;IACtB,KAAK,CAAC;MACFL,OAAO,EAAE,6BAA6B;MACtCC,IAAI,EAAE;QACFI;MACJ;IACJ,CAAC,CAAC;EACN;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MailTransport } from "../../domain/MailTransport/abstractions.js";
|
|
2
|
+
export declare class DummyMailTransport implements MailTransport.Interface {
|
|
3
|
+
readonly name = "Mailer/DummyTransport";
|
|
4
|
+
constructor();
|
|
5
|
+
send(): Promise<{
|
|
6
|
+
result: boolean;
|
|
7
|
+
error: null;
|
|
8
|
+
}>;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["DummyMailTransport","name","constructor","send","result","error"],"sources":["DummyMailTransport.ts"],"sourcesContent":["import { MailTransport } from \"~/domain/MailTransport/abstractions.js\";\n\nexport class DummyMailTransport implements MailTransport.Interface {\n public readonly name = \"Mailer/DummyTransport\";\n\n constructor() {}\n\n async send() {\n return {\n result: true,\n error: null\n };\n }\n}\n"],"mappings":"AAEA,OAAO,MAAMA,kBAAkB,CAAoC;EAC/CC,IAAI,GAAG,uBAAuB;EAE9CC,WAAWA,CAAA,EAAG,CAAC;EAEf,MAAMC,IAAIA,CAAA,EAAG;IACT,OAAO;MACHC,MAAM,EAAE,IAAI;MACZC,KAAK,EAAE;IACX,CAAC;EACL;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type IMailTransport, MailTransportFactory } from "../../domain/MailTransport/abstractions.js";
|
|
2
|
+
declare class DummyMailTransportFactoryImpl implements MailTransportFactory.Interface {
|
|
3
|
+
createTransport(): Promise<IMailTransport>;
|
|
4
|
+
}
|
|
5
|
+
export declare const DummyMailTransportFactory: typeof DummyMailTransportFactoryImpl & {
|
|
6
|
+
__abstraction: import("@webiny/di").Abstraction<import("~/domain/MailTransport/abstractions.js").IMailTransportFactory>;
|
|
7
|
+
};
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { MailTransportFactory } from "../../domain/MailTransport/abstractions.js";
|
|
2
|
+
import { DummyMailTransport } from "./DummyMailTransport.js";
|
|
3
|
+
class DummyMailTransportFactoryImpl {
|
|
4
|
+
async createTransport() {
|
|
5
|
+
return new DummyMailTransport();
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export const DummyMailTransportFactory = MailTransportFactory.createImplementation({
|
|
9
|
+
implementation: DummyMailTransportFactoryImpl,
|
|
10
|
+
dependencies: []
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=DummyMailTransportFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["MailTransportFactory","DummyMailTransport","DummyMailTransportFactoryImpl","createTransport","DummyMailTransportFactory","createImplementation","implementation","dependencies"],"sources":["DummyMailTransportFactory.ts"],"sourcesContent":["import { type IMailTransport, MailTransportFactory } from \"~/domain/MailTransport/abstractions.js\";\nimport { DummyMailTransport } from \"./DummyMailTransport.js\";\n\nclass DummyMailTransportFactoryImpl implements MailTransportFactory.Interface {\n async createTransport(): Promise<IMailTransport> {\n return new DummyMailTransport();\n }\n}\n\nexport const DummyMailTransportFactory = MailTransportFactory.createImplementation({\n implementation: DummyMailTransportFactoryImpl,\n dependencies: []\n});\n"],"mappings":"AAAA,SAA8BA,oBAAoB;AAClD,SAASC,kBAAkB;AAE3B,MAAMC,6BAA6B,CAA2C;EAC1E,MAAMC,eAAeA,CAAA,EAA4B;IAC7C,OAAO,IAAIF,kBAAkB,CAAC,CAAC;EACnC;AACJ;AAEA,OAAO,MAAMG,yBAAyB,GAAGJ,oBAAoB,CAACK,oBAAoB,CAAC;EAC/EC,cAAc,EAAEJ,6BAA6B;EAC7CK,YAAY,EAAE;AAClB,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const DummyTransportFeature: import("@webiny/feature/api/createFeature.js").FeatureDefinition<unknown>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { DummyMailTransportFactory } from "./DummyMailTransportFactory.js";
|
|
3
|
+
export const DummyTransportFeature = createFeature({
|
|
4
|
+
name: "Mailer/DummyTransport",
|
|
5
|
+
register(container) {
|
|
6
|
+
container.register(DummyMailTransportFactory).inSingletonScope();
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createFeature","DummyMailTransportFactory","DummyTransportFeature","name","register","container","inSingletonScope"],"sources":["feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { DummyMailTransportFactory } from \"./DummyMailTransportFactory.js\";\n\nexport const DummyTransportFeature = createFeature({\n name: \"Mailer/DummyTransport\",\n register(container) {\n container.register(DummyMailTransportFactory).inSingletonScope();\n }\n});\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,qBAAqB;AACnD,SAASC,yBAAyB;AAElC,OAAO,MAAMC,qBAAqB,GAAGF,aAAa,CAAC;EAC/CG,IAAI,EAAE,uBAAuB;EAC7BC,QAAQA,CAACC,SAAS,EAAE;IAChBA,SAAS,CAACD,QAAQ,CAACH,yBAAyB,CAAC,CAACK,gBAAgB,CAAC,CAAC;EACpE;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Encryption } from "../../domain/Encryption/abstractions.js";
|
|
2
|
+
declare class PasswordEncryptionImpl implements Encryption.Interface {
|
|
3
|
+
encrypt(value: string): Promise<string>;
|
|
4
|
+
decrypt(value: string): Promise<string>;
|
|
5
|
+
}
|
|
6
|
+
export declare const PasswordEncryption: typeof PasswordEncryptionImpl & {
|
|
7
|
+
__abstraction: import("@webiny/di").Abstraction<import("~/domain/Encryption/abstractions.js").IEncryption>;
|
|
8
|
+
};
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Encryption } from "../../domain/Encryption/abstractions.js";
|
|
2
|
+
import { decrypt, encrypt } from "./utils/password.js";
|
|
3
|
+
import { getSecret } from "./utils/secret.js";
|
|
4
|
+
class PasswordEncryptionImpl {
|
|
5
|
+
async encrypt(value) {
|
|
6
|
+
return encrypt({
|
|
7
|
+
value,
|
|
8
|
+
secret: getSecret()
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
async decrypt(value) {
|
|
12
|
+
return decrypt({
|
|
13
|
+
value,
|
|
14
|
+
secret: getSecret()
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export const PasswordEncryption = Encryption.createImplementation({
|
|
19
|
+
implementation: PasswordEncryptionImpl,
|
|
20
|
+
dependencies: []
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=PasswordEncryption.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Encryption","decrypt","encrypt","getSecret","PasswordEncryptionImpl","value","secret","PasswordEncryption","createImplementation","implementation","dependencies"],"sources":["PasswordEncryption.ts"],"sourcesContent":["import { Encryption } from \"~/domain/Encryption/abstractions.js\";\nimport { decrypt, encrypt } from \"./utils/password.js\";\nimport { getSecret } from \"./utils/secret.js\";\n\nclass PasswordEncryptionImpl implements Encryption.Interface {\n public async encrypt(value: string): Promise<string> {\n return encrypt({ value, secret: getSecret() });\n }\n\n public async decrypt(value: string): Promise<string> {\n return decrypt({ value, secret: getSecret() });\n }\n}\n\nexport const PasswordEncryption = Encryption.createImplementation({\n implementation: PasswordEncryptionImpl,\n dependencies: []\n});\n"],"mappings":"AAAA,SAASA,UAAU;AACnB,SAASC,OAAO,EAAEC,OAAO;AACzB,SAASC,SAAS;AAElB,MAAMC,sBAAsB,CAAiC;EACzD,MAAaF,OAAOA,CAACG,KAAa,EAAmB;IACjD,OAAOH,OAAO,CAAC;MAAEG,KAAK;MAAEC,MAAM,EAAEH,SAAS,CAAC;IAAE,CAAC,CAAC;EAClD;EAEA,MAAaF,OAAOA,CAACI,KAAa,EAAmB;IACjD,OAAOJ,OAAO,CAAC;MAAEI,KAAK;MAAEC,MAAM,EAAEH,SAAS,CAAC;IAAE,CAAC,CAAC;EAClD;AACJ;AAEA,OAAO,MAAMI,kBAAkB,GAAGP,UAAU,CAACQ,oBAAoB,CAAC;EAC9DC,cAAc,EAAEL,sBAAsB;EACtCM,YAAY,EAAE;AAClB,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const EncryptionFeature: import("@webiny/feature/api/createFeature.js").FeatureDefinition<unknown>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { PasswordEncryption } from "./PasswordEncryption.js";
|
|
3
|
+
export const EncryptionFeature = createFeature({
|
|
4
|
+
name: "Mailer/Encryption",
|
|
5
|
+
register(container) {
|
|
6
|
+
container.register(PasswordEncryption).inSingletonScope();
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createFeature","PasswordEncryption","EncryptionFeature","name","register","container","inSingletonScope"],"sources":["feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { PasswordEncryption } from \"./PasswordEncryption.js\";\n\nexport const EncryptionFeature = createFeature({\n name: \"Mailer/Encryption\",\n register(container) {\n container.register(PasswordEncryption).inSingletonScope();\n }\n});\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,qBAAqB;AACnD,SAASC,kBAAkB;AAE3B,OAAO,MAAMC,iBAAiB,GAAGF,aAAa,CAAC;EAC3CG,IAAI,EAAE,mBAAmB;EACzBC,QAAQA,CAACC,SAAS,EAAE;IAChBA,SAAS,CAACD,QAAQ,CAACH,kBAAkB,CAAC,CAACK,gBAAgB,CAAC,CAAC;EAC7D;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import crypto from "node:crypto";
|
|
2
|
+
import WebinyError from "@webiny/error";
|
|
3
|
+
const ALGORITHM = "aes-256-gcm";
|
|
4
|
+
const IV_LENGTH = 12;
|
|
5
|
+
const KEY_LENGTH = 32;
|
|
6
|
+
export const decrypt = params => {
|
|
7
|
+
const {
|
|
8
|
+
value,
|
|
9
|
+
secret
|
|
10
|
+
} = params;
|
|
11
|
+
if (!secret) {
|
|
12
|
+
throw new WebinyError(`Cannot call decrypt without passing the secret.`);
|
|
13
|
+
}
|
|
14
|
+
if (!value) {
|
|
15
|
+
return "";
|
|
16
|
+
}
|
|
17
|
+
try {
|
|
18
|
+
const data = Buffer.from(value, "base64");
|
|
19
|
+
const iv = data.subarray(0, 12);
|
|
20
|
+
const authTag = data.subarray(12, 28);
|
|
21
|
+
const encrypted = data.subarray(28);
|
|
22
|
+
const key = crypto.scryptSync(secret, "salt", 32);
|
|
23
|
+
const decipher = crypto.createDecipheriv(ALGORITHM, key, iv);
|
|
24
|
+
decipher.setAuthTag(authTag);
|
|
25
|
+
const decrypted = Buffer.concat([decipher.update(encrypted), decipher.final()]);
|
|
26
|
+
return decrypted.toString("utf8");
|
|
27
|
+
} catch {
|
|
28
|
+
console.log(`Could not decrypt given encrypted password.`);
|
|
29
|
+
}
|
|
30
|
+
return "";
|
|
31
|
+
};
|
|
32
|
+
export const encrypt = params => {
|
|
33
|
+
const {
|
|
34
|
+
value,
|
|
35
|
+
secret
|
|
36
|
+
} = params;
|
|
37
|
+
if (!secret) {
|
|
38
|
+
throw new WebinyError(`Cannot call decrypt without passing the secret.`);
|
|
39
|
+
}
|
|
40
|
+
if (!value) {
|
|
41
|
+
return "";
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
const key = crypto.scryptSync(secret, "salt", KEY_LENGTH);
|
|
45
|
+
const iv = crypto.randomBytes(IV_LENGTH);
|
|
46
|
+
const cipher = crypto.createCipheriv(ALGORITHM, key, iv);
|
|
47
|
+
const encrypted = Buffer.concat([cipher.update(value, "utf8"), cipher.final()]);
|
|
48
|
+
const authTag = cipher.getAuthTag();
|
|
49
|
+
return Buffer.concat([iv, authTag, encrypted]).toString("base64");
|
|
50
|
+
} catch {
|
|
51
|
+
console.log(`Could not encrypt given password.`);
|
|
52
|
+
}
|
|
53
|
+
return "";
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
//# sourceMappingURL=password.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["crypto","WebinyError","ALGORITHM","IV_LENGTH","KEY_LENGTH","decrypt","params","value","secret","data","Buffer","from","iv","subarray","authTag","encrypted","key","scryptSync","decipher","createDecipheriv","setAuthTag","decrypted","concat","update","final","toString","console","log","encrypt","randomBytes","cipher","createCipheriv","getAuthTag"],"sources":["password.ts"],"sourcesContent":["import crypto from \"node:crypto\";\nimport WebinyError from \"@webiny/error\";\n\nconst ALGORITHM = \"aes-256-gcm\";\nconst IV_LENGTH = 12;\nconst KEY_LENGTH = 32;\n\ninterface Params {\n value?: string | null;\n secret?: string | null;\n}\n\nexport const decrypt = (params: Params): string => {\n const { value, secret } = params;\n if (!secret) {\n throw new WebinyError(`Cannot call decrypt without passing the secret.`);\n }\n if (!value) {\n return \"\";\n }\n try {\n const data = Buffer.from(value, \"base64\");\n\n const iv = data.subarray(0, 12);\n const authTag = data.subarray(12, 28);\n const encrypted = data.subarray(28);\n\n const key = crypto.scryptSync(secret, \"salt\", 32);\n\n const decipher = crypto.createDecipheriv(ALGORITHM, key, iv);\n decipher.setAuthTag(authTag);\n\n const decrypted = Buffer.concat([decipher.update(encrypted), decipher.final()]);\n\n return decrypted.toString(\"utf8\");\n } catch {\n console.log(`Could not decrypt given encrypted password.`);\n }\n return \"\";\n};\n\nexport const encrypt = (params: Params): string => {\n const { value, secret } = params;\n if (!secret) {\n throw new WebinyError(`Cannot call decrypt without passing the secret.`);\n }\n if (!value) {\n return \"\";\n }\n\n try {\n const key = crypto.scryptSync(secret, \"salt\", KEY_LENGTH);\n const iv = crypto.randomBytes(IV_LENGTH);\n const cipher = crypto.createCipheriv(ALGORITHM, key, iv);\n const encrypted = Buffer.concat([cipher.update(value, \"utf8\"), cipher.final()]);\n const authTag = cipher.getAuthTag();\n return Buffer.concat([iv, authTag, encrypted]).toString(\"base64\");\n } catch {\n console.log(`Could not encrypt given password.`);\n }\n return \"\";\n};\n"],"mappings":"AAAA,OAAOA,MAAM,MAAM,aAAa;AAChC,OAAOC,WAAW,MAAM,eAAe;AAEvC,MAAMC,SAAS,GAAG,aAAa;AAC/B,MAAMC,SAAS,GAAG,EAAE;AACpB,MAAMC,UAAU,GAAG,EAAE;AAOrB,OAAO,MAAMC,OAAO,GAAIC,MAAc,IAAa;EAC/C,MAAM;IAAEC,KAAK;IAAEC;EAAO,CAAC,GAAGF,MAAM;EAChC,IAAI,CAACE,MAAM,EAAE;IACT,MAAM,IAAIP,WAAW,CAAC,iDAAiD,CAAC;EAC5E;EACA,IAAI,CAACM,KAAK,EAAE;IACR,OAAO,EAAE;EACb;EACA,IAAI;IACA,MAAME,IAAI,GAAGC,MAAM,CAACC,IAAI,CAACJ,KAAK,EAAE,QAAQ,CAAC;IAEzC,MAAMK,EAAE,GAAGH,IAAI,CAACI,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC;IAC/B,MAAMC,OAAO,GAAGL,IAAI,CAACI,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC;IACrC,MAAME,SAAS,GAAGN,IAAI,CAACI,QAAQ,CAAC,EAAE,CAAC;IAEnC,MAAMG,GAAG,GAAGhB,MAAM,CAACiB,UAAU,CAACT,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;IAEjD,MAAMU,QAAQ,GAAGlB,MAAM,CAACmB,gBAAgB,CAACjB,SAAS,EAAEc,GAAG,EAAEJ,EAAE,CAAC;IAC5DM,QAAQ,CAACE,UAAU,CAACN,OAAO,CAAC;IAE5B,MAAMO,SAAS,GAAGX,MAAM,CAACY,MAAM,CAAC,CAACJ,QAAQ,CAACK,MAAM,CAACR,SAAS,CAAC,EAAEG,QAAQ,CAACM,KAAK,CAAC,CAAC,CAAC,CAAC;IAE/E,OAAOH,SAAS,CAACI,QAAQ,CAAC,MAAM,CAAC;EACrC,CAAC,CAAC,MAAM;IACJC,OAAO,CAACC,GAAG,CAAC,6CAA6C,CAAC;EAC9D;EACA,OAAO,EAAE;AACb,CAAC;AAED,OAAO,MAAMC,OAAO,GAAItB,MAAc,IAAa;EAC/C,MAAM;IAAEC,KAAK;IAAEC;EAAO,CAAC,GAAGF,MAAM;EAChC,IAAI,CAACE,MAAM,EAAE;IACT,MAAM,IAAIP,WAAW,CAAC,iDAAiD,CAAC;EAC5E;EACA,IAAI,CAACM,KAAK,EAAE;IACR,OAAO,EAAE;EACb;EAEA,IAAI;IACA,MAAMS,GAAG,GAAGhB,MAAM,CAACiB,UAAU,CAACT,MAAM,EAAE,MAAM,EAAEJ,UAAU,CAAC;IACzD,MAAMQ,EAAE,GAAGZ,MAAM,CAAC6B,WAAW,CAAC1B,SAAS,CAAC;IACxC,MAAM2B,MAAM,GAAG9B,MAAM,CAAC+B,cAAc,CAAC7B,SAAS,EAAEc,GAAG,EAAEJ,EAAE,CAAC;IACxD,MAAMG,SAAS,GAAGL,MAAM,CAACY,MAAM,CAAC,CAACQ,MAAM,CAACP,MAAM,CAAChB,KAAK,EAAE,MAAM,CAAC,EAAEuB,MAAM,CAACN,KAAK,CAAC,CAAC,CAAC,CAAC;IAC/E,MAAMV,OAAO,GAAGgB,MAAM,CAACE,UAAU,CAAC,CAAC;IACnC,OAAOtB,MAAM,CAACY,MAAM,CAAC,CAACV,EAAE,EAAEE,OAAO,EAAEC,SAAS,CAAC,CAAC,CAACU,QAAQ,CAAC,QAAQ,CAAC;EACrE,CAAC,CAAC,MAAM;IACJC,OAAO,CAACC,GAAG,CAAC,mCAAmC,CAAC;EACpD;EACA,OAAO,EAAE;AACb,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import WebinyError from "@webiny/error";
|
|
2
|
+
export const getSecret = () => {
|
|
3
|
+
const envValue = process.env.WEBINY_API_MAILER_PASSWORD_SECRET;
|
|
4
|
+
const value = String(envValue).trim();
|
|
5
|
+
if (!envValue || !value) {
|
|
6
|
+
throw new WebinyError(`There must be a password secret defined!`, "PASSWORD_SECRET_ERROR");
|
|
7
|
+
}
|
|
8
|
+
return value;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=secret.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["WebinyError","getSecret","envValue","process","env","WEBINY_API_MAILER_PASSWORD_SECRET","value","String","trim"],"sources":["secret.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\n\nexport const getSecret = (): string => {\n const envValue = process.env.WEBINY_API_MAILER_PASSWORD_SECRET;\n\n const value = String(envValue).trim();\n if (!envValue || !value) {\n throw new WebinyError(`There must be a password secret defined!`, \"PASSWORD_SECRET_ERROR\");\n }\n return value;\n};\n"],"mappings":"AAAA,OAAOA,WAAW,MAAM,eAAe;AAEvC,OAAO,MAAMC,SAAS,GAAGA,CAAA,KAAc;EACnC,MAAMC,QAAQ,GAAGC,OAAO,CAACC,GAAG,CAACC,iCAAiC;EAE9D,MAAMC,KAAK,GAAGC,MAAM,CAACL,QAAQ,CAAC,CAACM,IAAI,CAAC,CAAC;EACrC,IAAI,CAACN,QAAQ,IAAI,CAACI,KAAK,EAAE;IACrB,MAAM,IAAIN,WAAW,CAAC,0CAA0C,EAAE,uBAAuB,CAAC;EAC9F;EACA,OAAOM,KAAK;AAChB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { Encryption } from "../../domain/Encryption/abstractions.js";
|
|
3
|
+
import { GetSettingsRepository } from "./abstractions.js";
|
|
4
|
+
import type { TransportSettings } from "../../types.js";
|
|
5
|
+
import { KeyValueStore } from "@webiny/api-core/features/keyValueStore/index.js";
|
|
6
|
+
declare class GetSettingsRepositoryImpl implements GetSettingsRepository.Interface {
|
|
7
|
+
private keyValueStore;
|
|
8
|
+
private encryption;
|
|
9
|
+
constructor(keyValueStore: KeyValueStore.Interface, encryption: Encryption.Interface);
|
|
10
|
+
get(): Promise<Result<TransportSettings | null>>;
|
|
11
|
+
}
|
|
12
|
+
export declare const GetSettingsRepositoryImplementation: typeof GetSettingsRepositoryImpl & {
|
|
13
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IGetSettingsRepository>;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { Encryption } from "../../domain/Encryption/abstractions.js";
|
|
3
|
+
import { GetSettingsRepository } from "./abstractions.js";
|
|
4
|
+
import { KeyValueStore } from "@webiny/api-core/features/keyValueStore/index.js";
|
|
5
|
+
import { MAILER_TRANSPORT_SETTINGS } from "../../constants.js";
|
|
6
|
+
class GetSettingsRepositoryImpl {
|
|
7
|
+
constructor(keyValueStore, encryption) {
|
|
8
|
+
this.keyValueStore = keyValueStore;
|
|
9
|
+
this.encryption = encryption;
|
|
10
|
+
}
|
|
11
|
+
async get() {
|
|
12
|
+
const result = await this.keyValueStore.get(MAILER_TRANSPORT_SETTINGS);
|
|
13
|
+
if (result.isFail()) {
|
|
14
|
+
return Result.ok(null);
|
|
15
|
+
}
|
|
16
|
+
const settings = result.value;
|
|
17
|
+
if (!settings) {
|
|
18
|
+
return Result.ok(null);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Decrypt password if present
|
|
22
|
+
const password = settings.password ? await this.encryption.decrypt(String(settings.password)) : "";
|
|
23
|
+
const transportSettings = {
|
|
24
|
+
host: String(settings.host || ""),
|
|
25
|
+
port: Number(settings.port || 25),
|
|
26
|
+
user: String(settings.user || ""),
|
|
27
|
+
password,
|
|
28
|
+
from: String(settings.from || ""),
|
|
29
|
+
replyTo: settings.replyTo ? String(settings.replyTo) : undefined
|
|
30
|
+
};
|
|
31
|
+
return Result.ok(transportSettings);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export const GetSettingsRepositoryImplementation = GetSettingsRepository.createImplementation({
|
|
35
|
+
implementation: GetSettingsRepositoryImpl,
|
|
36
|
+
dependencies: [KeyValueStore, Encryption]
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=GetSettingsRepository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Result","Encryption","GetSettingsRepository","KeyValueStore","MAILER_TRANSPORT_SETTINGS","GetSettingsRepositoryImpl","constructor","keyValueStore","encryption","get","result","isFail","ok","settings","value","password","decrypt","String","transportSettings","host","port","Number","user","from","replyTo","undefined","GetSettingsRepositoryImplementation","createImplementation","implementation","dependencies"],"sources":["GetSettingsRepository.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { Encryption } from \"~/domain/Encryption/abstractions.js\";\nimport { GetSettingsRepository } from \"./abstractions.js\";\nimport type { TransportSettings } from \"~/types.js\";\nimport { KeyValueStore } from \"@webiny/api-core/features/keyValueStore/index.js\";\nimport { MAILER_TRANSPORT_SETTINGS } from \"~/constants.js\";\n\nclass GetSettingsRepositoryImpl implements GetSettingsRepository.Interface {\n constructor(\n private keyValueStore: KeyValueStore.Interface,\n private encryption: Encryption.Interface\n ) {}\n\n async get(): Promise<Result<TransportSettings | null>> {\n const result = await this.keyValueStore.get<TransportSettings>(MAILER_TRANSPORT_SETTINGS);\n\n if (result.isFail()) {\n return Result.ok(null);\n }\n\n const settings = result.value;\n if (!settings) {\n return Result.ok(null);\n }\n\n // Decrypt password if present\n const password = settings.password\n ? await this.encryption.decrypt(String(settings.password))\n : \"\";\n\n const transportSettings: TransportSettings = {\n host: String(settings.host || \"\"),\n port: Number(settings.port || 25),\n user: String(settings.user || \"\"),\n password,\n from: String(settings.from || \"\"),\n replyTo: settings.replyTo ? String(settings.replyTo) : undefined\n };\n\n return Result.ok(transportSettings);\n }\n}\n\nexport const GetSettingsRepositoryImplementation = GetSettingsRepository.createImplementation({\n implementation: GetSettingsRepositoryImpl,\n dependencies: [KeyValueStore, Encryption]\n});\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,qBAAqB;AAC5C,SAASC,UAAU;AACnB,SAASC,qBAAqB;AAE9B,SAASC,aAAa,QAAQ,kDAAkD;AAChF,SAASC,yBAAyB;AAElC,MAAMC,yBAAyB,CAA4C;EACvEC,WAAWA,CACCC,aAAsC,EACtCC,UAAgC,EAC1C;IAAA,KAFUD,aAAsC,GAAtCA,aAAsC;IAAA,KACtCC,UAAgC,GAAhCA,UAAgC;EACzC;EAEH,MAAMC,GAAGA,CAAA,EAA8C;IACnD,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACH,aAAa,CAACE,GAAG,CAAoBL,yBAAyB,CAAC;IAEzF,IAAIM,MAAM,CAACC,MAAM,CAAC,CAAC,EAAE;MACjB,OAAOX,MAAM,CAACY,EAAE,CAAC,IAAI,CAAC;IAC1B;IAEA,MAAMC,QAAQ,GAAGH,MAAM,CAACI,KAAK;IAC7B,IAAI,CAACD,QAAQ,EAAE;MACX,OAAOb,MAAM,CAACY,EAAE,CAAC,IAAI,CAAC;IAC1B;;IAEA;IACA,MAAMG,QAAQ,GAAGF,QAAQ,CAACE,QAAQ,GAC5B,MAAM,IAAI,CAACP,UAAU,CAACQ,OAAO,CAACC,MAAM,CAACJ,QAAQ,CAACE,QAAQ,CAAC,CAAC,GACxD,EAAE;IAER,MAAMG,iBAAoC,GAAG;MACzCC,IAAI,EAAEF,MAAM,CAACJ,QAAQ,CAACM,IAAI,IAAI,EAAE,CAAC;MACjCC,IAAI,EAAEC,MAAM,CAACR,QAAQ,CAACO,IAAI,IAAI,EAAE,CAAC;MACjCE,IAAI,EAAEL,MAAM,CAACJ,QAAQ,CAACS,IAAI,IAAI,EAAE,CAAC;MACjCP,QAAQ;MACRQ,IAAI,EAAEN,MAAM,CAACJ,QAAQ,CAACU,IAAI,IAAI,EAAE,CAAC;MACjCC,OAAO,EAAEX,QAAQ,CAACW,OAAO,GAAGP,MAAM,CAACJ,QAAQ,CAACW,OAAO,CAAC,GAAGC;IAC3D,CAAC;IAED,OAAOzB,MAAM,CAACY,EAAE,CAACM,iBAAiB,CAAC;EACvC;AACJ;AAEA,OAAO,MAAMQ,mCAAmC,GAAGxB,qBAAqB,CAACyB,oBAAoB,CAAC;EAC1FC,cAAc,EAAEvB,yBAAyB;EACzCwB,YAAY,EAAE,CAAC1B,aAAa,EAAEF,UAAU;AAC5C,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import { GetSettingsUseCase, GetSettingsRepository } from "./abstractions.js";
|
|
3
|
+
import type { TransportSettings } from "../../types.js";
|
|
4
|
+
declare class GetSettingsUseCaseImpl implements GetSettingsUseCase.Interface {
|
|
5
|
+
private repository;
|
|
6
|
+
constructor(repository: GetSettingsRepository.Interface);
|
|
7
|
+
execute(): Promise<Result<TransportSettings | null>>;
|
|
8
|
+
}
|
|
9
|
+
export declare const GetSettingsUseCaseImplementation: typeof GetSettingsUseCaseImpl & {
|
|
10
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IGetSettingsUSeCase>;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { GetSettingsUseCase, GetSettingsRepository } from "./abstractions.js";
|
|
2
|
+
class GetSettingsUseCaseImpl {
|
|
3
|
+
constructor(repository) {
|
|
4
|
+
this.repository = repository;
|
|
5
|
+
}
|
|
6
|
+
execute() {
|
|
7
|
+
return this.repository.get();
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export const GetSettingsUseCaseImplementation = GetSettingsUseCase.createImplementation({
|
|
11
|
+
implementation: GetSettingsUseCaseImpl,
|
|
12
|
+
dependencies: [GetSettingsRepository]
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=GetSettingsUseCase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["GetSettingsUseCase","GetSettingsRepository","GetSettingsUseCaseImpl","constructor","repository","execute","get","GetSettingsUseCaseImplementation","createImplementation","implementation","dependencies"],"sources":["GetSettingsUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { GetSettingsUseCase, GetSettingsRepository } from \"./abstractions.js\";\nimport type { TransportSettings } from \"~/types.js\";\n\nclass GetSettingsUseCaseImpl implements GetSettingsUseCase.Interface {\n constructor(private repository: GetSettingsRepository.Interface) {}\n\n execute(): Promise<Result<TransportSettings | null>> {\n return this.repository.get();\n }\n}\n\nexport const GetSettingsUseCaseImplementation = GetSettingsUseCase.createImplementation({\n implementation: GetSettingsUseCaseImpl,\n dependencies: [GetSettingsRepository]\n});\n"],"mappings":"AACA,SAASA,kBAAkB,EAAEC,qBAAqB;AAGlD,MAAMC,sBAAsB,CAAyC;EACjEC,WAAWA,CAASC,UAA2C,EAAE;IAAA,KAA7CA,UAA2C,GAA3CA,UAA2C;EAAG;EAElEC,OAAOA,CAAA,EAA8C;IACjD,OAAO,IAAI,CAACD,UAAU,CAACE,GAAG,CAAC,CAAC;EAChC;AACJ;AAEA,OAAO,MAAMC,gCAAgC,GAAGP,kBAAkB,CAACQ,oBAAoB,CAAC;EACpFC,cAAc,EAAEP,sBAAsB;EACtCQ,YAAY,EAAE,CAACT,qBAAqB;AACxC,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Result } from "@webiny/feature/api";
|
|
2
|
+
import type { TransportSettings } from "../../types.js";
|
|
3
|
+
export interface IGetSettingsRepository {
|
|
4
|
+
get(): Promise<Result<TransportSettings | null>>;
|
|
5
|
+
}
|
|
6
|
+
export declare const GetSettingsRepository: import("@webiny/di").Abstraction<IGetSettingsRepository>;
|
|
7
|
+
export declare namespace GetSettingsRepository {
|
|
8
|
+
type Interface = IGetSettingsRepository;
|
|
9
|
+
}
|
|
10
|
+
export interface IGetSettingsUSeCase {
|
|
11
|
+
execute(): Promise<Result<TransportSettings | null>>;
|
|
12
|
+
}
|
|
13
|
+
export declare const GetSettingsUseCase: import("@webiny/di").Abstraction<IGetSettingsUSeCase>;
|
|
14
|
+
export declare namespace GetSettingsUseCase {
|
|
15
|
+
type Interface = IGetSettingsUSeCase;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createAbstraction","GetSettingsRepository","GetSettingsUseCase"],"sources":["abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport type { TransportSettings } from \"~/types.js\";\n\nexport interface IGetSettingsRepository {\n get(): Promise<Result<TransportSettings | null>>;\n}\n\nexport const GetSettingsRepository =\n createAbstraction<IGetSettingsRepository>(\"GetSettingsRepository\");\n\nexport namespace GetSettingsRepository {\n export type Interface = IGetSettingsRepository;\n}\n\nexport interface IGetSettingsUSeCase {\n execute(): Promise<Result<TransportSettings | null>>;\n}\n\nexport const GetSettingsUseCase = createAbstraction<IGetSettingsUSeCase>(\"GetSettingsUseCase\");\n\nexport namespace GetSettingsUseCase {\n export type Interface = IGetSettingsUSeCase;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;AAQvD,OAAO,MAAMC,qBAAqB,GAC9BD,iBAAiB,CAAyB,uBAAuB,CAAC;AAUtE,OAAO,MAAME,kBAAkB,GAAGF,iBAAiB,CAAsB,oBAAoB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const GetSettingsFeature: import("@webiny/feature/api/createFeature.js").FeatureDefinition<unknown>;
|