@venizia/ignis 0.4.8-15 → 0.4.8-17
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/dist/esm/base/applications/base.js.map +1 -1
- package/dist/esm/components/api-reference/common/types.d.ts +6 -3
- package/dist/esm/components/api-reference/common/types.js.map +1 -1
- package/dist/esm/components/api-reference/component.js +8 -3
- package/dist/esm/components/api-reference/component.js.map +1 -1
- package/dist/esm/components/auth/authenticate/component.js +2 -1
- package/dist/esm/components/auth/authenticate/component.js.map +1 -1
- package/dist/esm/components/auth/authenticate/controllers/factory.d.ts +2 -2
- package/dist/esm/components/auth/authenticate/services/bearer/abstract.service.d.ts +5 -3
- package/dist/esm/components/auth/authenticate/services/bearer/abstract.service.js +18 -1
- package/dist/esm/components/auth/authenticate/services/bearer/abstract.service.js.map +1 -1
- package/dist/esm/components/auth/authorize/adapters/common/types.d.ts +1 -2
- package/dist/esm/components/auth/authorize/adapters/common/types.js.map +1 -1
- package/dist/esm/components/mail/common/types/message.d.ts +4 -4
- package/dist/esm/components/mail/common/types/message.js.map +1 -1
- package/dist/esm/components/mail/common/types/options.d.ts +54 -10
- package/dist/esm/components/mail/common/types/options.js.map +1 -1
- package/dist/esm/components/mail/common/types/template.d.ts +2 -2
- package/dist/esm/components/mail/common/types/template.js.map +1 -1
- package/dist/esm/components/mail/helpers/transporters/amazon-ses-transporter.helper.js +7 -2
- package/dist/esm/components/mail/helpers/transporters/amazon-ses-transporter.helper.js.map +1 -1
- package/dist/esm/components/mail/helpers/transporters/mailgun-transporter.helper.d.ts +2 -3
- package/dist/esm/components/mail/helpers/transporters/mailgun-transporter.helper.js.map +1 -1
- package/dist/esm/components/mail/helpers/transporters/nodemail-transporter.helper.d.ts +2 -3
- package/dist/esm/components/mail/helpers/transporters/nodemail-transporter.helper.js.map +1 -1
- package/dist/esm/components/mail/services/mail.service.d.ts +1 -2
- package/dist/esm/components/mail/services/mail.service.js.map +1 -1
- package/dist/esm/components/mail/services/template.service.d.ts +3 -4
- package/dist/esm/components/mail/services/template.service.js +1 -1
- package/dist/esm/components/mail/services/template.service.js.map +1 -1
- package/dist/esm/components/mail/utilities/header.utility.d.ts +1 -1
- package/dist/esm/components/mail/utilities/header.utility.js +1 -1
- package/dist/esm/components/mail/utilities/header.utility.js.map +1 -1
- package/dist/esm/components/mail/utilities/type.utility.d.ts +2 -3
- package/dist/esm/components/mail/utilities/type.utility.js +6 -7
- package/dist/esm/components/mail/utilities/type.utility.js.map +1 -1
- package/dist/esm/components/socket-io/handlers/bun.handler.d.ts +13 -3
- package/dist/esm/components/socket-io/handlers/bun.handler.js.map +1 -1
- package/dist/esm/components/static-asset/common/types.d.ts +35 -13
- package/dist/esm/components/static-asset/common/types.js.map +1 -1
- package/dist/esm/components/static-asset/controller/factory.d.ts +2 -2
- package/dist/esm/components/static-asset/controller/routes/context.d.ts +4 -3
- package/dist/esm/components/static-asset/controller/routes/context.js.map +1 -1
- package/dist/esm/components/static-asset/utilities/meta-link.utility.d.ts +5 -5
- package/dist/esm/components/static-asset/utilities/meta-link.utility.js.map +1 -1
- package/dist/esm/components/static-asset/utilities/toggle.utility.d.ts +3 -11
- package/dist/esm/components/static-asset/utilities/toggle.utility.js +3 -14
- package/dist/esm/components/static-asset/utilities/toggle.utility.js.map +1 -1
- package/dist/esm/testing/assert-application-boots.d.ts +2 -2
- package/dist/esm/testing/assert-application-boots.js +6 -2
- package/dist/esm/testing/assert-application-boots.js.map +1 -1
- package/dist/presets/app/preset.json +4 -4
- package/dist/presets/lib/preset.json +3 -3
- package/dist/presets/shared/preset.json +1 -1
- package/package.json +8 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abstract.service.js","sourceRoot":"","sources":["../../../../../../../src/components/auth/authenticate/services/bearer/abstract.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAE7C,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,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,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,IAEpB;QACC,MAAM,EAAE,OAAO,EAAE,eAAe,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC;QAEjD,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACzC,OAAO,OAA2B,CAAC;QACrC,CAAC;QAED,IAAI,CAAC,MAAM;aACR,GAAG,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC;aAC7B,KAAK,CAAC,sCAAsC,EAAE,OAAO,EAAE,eAAe,CAAC,CAAC;QAE3E,MAAM,EAAE,GAAQ,EAAE,CAAC;QAEnB,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;YAC1B,IAAI,0BAA0B,CAAC,iBAAiB,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC1D,EAAE,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;gBACvB,SAAS;YACX,CAAC;YAED,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC;gBAC1C,OAAO,EAAE,GAAG;gBACZ,MAAM,EAAE,IAAI,CAAC,iBAAiB;aAC/B,CAAC,CAAC;YACH,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC;gBAC5C,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC;gBACrB,MAAM,EAAE,IAAI,CAAC,iBAAiB;aAC/B,CAAC,CAAC;YAEH,EAAE,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC,gBAAgB,CAAC,EAAE,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC,CAAC;QACzF,CAAC;QAED,OAAO,EAAE,CAAC;IACZ,CAAC","sourcesContent":["import type { AESAlgorithmType } from '@venizia/ignis-helpers';\nimport { AES } from '@venizia/ignis-helpers';\nimport type { ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport { HTTP } from '@venizia/ignis-helpers/common';\nimport { getError, RecordUtility } from '@venizia/ignis-helpers/core';\nimport type {\n IJWTClaimsOptions,\n IJWTIssueClaims,\n IJWTTokenPayload,\n IJWTVerifyOptions,\n IPayloadFieldCodec,\n TContext,\n TGetTokenExpiresFn,\n} from '@venizia/ignis-kernel';\nimport {\n Authentication,\n AuthenticationErrors,\n BaseService,\n ServiceAssertion,\n} from '@venizia/ignis-kernel';\nimport type { Env } from 'hono';\nimport { JoseLoader } from '../jose-loader';\nimport type { JWTPayload, JWTVerifyOptions, JWTVerifyResult, SignJWT } from 'jose';\n\n/** What a token service is configured with for claims: the required `claims`, the `verify` checks, and the removed `sign` it refuses. */\nexport interface IClaimsConfigSource {\n claims?: unknown;\n verify?: unknown;\n /** Removed: refused with a message that points to `claims`. */\n sign?: unknown;\n}\n\n/** What {@link AbstractBearerTokenService.resolveClaimsConfig} answers: the validated claims and the verify options jose receives. */\nexport interface IResolvedClaimsConfig {\n claims: IJWTClaimsOptions;\n verify: JWTVerifyOptions & { algorithms: string[] };\n}\n\n/** Abstract base for Bearer-token services (JWS, JWKS) with optional AES payload encryption. */\nexport abstract class AbstractBearerTokenService<E extends Env = Env> extends BaseService {\n /** Standard JWT fields that are never encrypted. */\n static readonly JWT_COMMON_FIELDS = new Set<keyof JWTPayload>([\n 'iss',\n 'sub',\n 'aud',\n 'jti',\n 'nbf',\n 'exp',\n 'iat',\n ]);\n\n protected aes: AES | null = null;\n protected applicationSecret: string | null = null;\n protected fieldCodecs: Map<string, IPayloadFieldCodec> = new Map();\n\n /** Configured `iss` / `aud`: stamped on every issued token, authoritative over anything the payload carries, and required on every verified one. */\n protected claimOptions: IJWTClaimsOptions | null = null;\n\n /** What jose verifies against: the claims, the algorithm pin and the `verify` checks. */\n protected verifyOptions: JWTVerifyOptions | null = null;\n\n /** The keys a `claims` object may hold. */\n static readonly CLAIM_KEYS: ReadonlyArray<string> = ['issuer', 'audience'];\n\n /**\n * Validates the claims configuration of a token service and answers what the service uses. It throws, naming the\n * key, when `claims.issuer` is missing or empty, when `claims.audience` is present but not a non-empty string or a\n * non-empty list of them, when `claims` holds another key, when the removed `sign` or `verify.issuer` /\n * `verify.audience` is still passed, and when no algorithm is pinned. `claims.audience` is optional: without it\n * no `aud` is stamped and none is checked.\n * `pinnedAlgorithms` is what the service signs with; a verifier has none and requires `verify.algorithms`.\n * The component calls it at boot, and a service calls it when it is built, so neither can start without them.\n */\n static resolveClaimsConfig(opts: {\n scope: string;\n options: IClaimsConfigSource;\n pinnedAlgorithms?: string[];\n }): IResolvedClaimsConfig {\n const { scope, options, pinnedAlgorithms } = opts;\n const fail = (detail: string) =>\n getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: `[${scope}] ${detail}`,\n });\n\n if (options.sign !== undefined) {\n throw fail(\n '`sign` was removed | put the issuer and the audience in `claims: { issuer, audience }`: they are stamped on every token and required on every verified one',\n );\n }\n\n if (options.verify !== undefined && !RecordUtility.isPlainRecord(options.verify)) {\n throw fail(\n 'verify must be an object | its checks (maxTokenAge, subject, ...) would be dropped silently',\n );\n }\n\n const verify = RecordUtility.isPlainRecord(options.verify) ? options.verify : {};\n\n for (const key of AbstractBearerTokenService.CLAIM_KEYS) {\n if (key in verify) {\n throw fail(\n `verify.${key} was removed | set claims.${key}: it is stamped on every token and required on every verified one`,\n );\n }\n }\n\n const { claims } = options;\n\n if (!RecordUtility.isPlainRecord(claims)) {\n throw fail(\n 'claims is required | pass claims: { issuer: string, audience: string | string[] }: a token signed with the same key for another purpose must not authenticate a request',\n );\n }\n\n const unknown = Object.keys(claims).filter(\n (key) => !AbstractBearerTokenService.CLAIM_KEYS.includes(key),\n );\n\n if (unknown.length > 0) {\n throw fail(\n `claims holds unknown keys ${JSON.stringify(unknown)} | accepted: ${AbstractBearerTokenService.CLAIM_KEYS.join(', ')}`,\n );\n }\n\n const { issuer, audience } = claims;\n const isName = (value: unknown): value is string =>\n typeof value === 'string' && value.trim().length > 0;\n\n if (!isName(issuer)) {\n throw fail('claims.issuer is required | a non-empty string');\n }\n\n // Optional, but a present value is checked: `null`, `''` and `[]` are mistakes, not \"no audience\".\n if (\n audience !== undefined &&\n !isName(audience) &&\n !(Array.isArray(audience) && audience.length > 0 && audience.every(isName))\n ) {\n throw fail(\n 'claims.audience must be a non-empty string or a non-empty list of them | or leave it out',\n );\n }\n\n const resolvedAudience = Array.isArray(audience) ? [...audience] : audience;\n\n const algorithms = verify.algorithms ?? pinnedAlgorithms;\n\n if (!Array.isArray(algorithms) || algorithms.length === 0 || !algorithms.every(isName)) {\n throw fail(\n \"verify.algorithms is required | the accepted JWS algorithms, for example ['RS256']: a verifier cannot know what the issuer signs with\",\n );\n }\n\n if (algorithms.some((algorithm) => algorithm.trim().toLowerCase() === 'none')) {\n throw fail(\"the algorithm 'none' is refused | a token with no signature verifies nothing\");\n }\n\n return {\n claims: { issuer, ...(resolvedAudience === undefined ? {} : { audience: resolvedAudience }) },\n verify: {\n ...(verify as IJWTVerifyOptions),\n issuer,\n ...(resolvedAudience === undefined ? {} : { audience: resolvedAudience }),\n algorithms: [...algorithms],\n },\n };\n }\n\n /** Validates the claims configuration (see {@link AbstractBearerTokenService.resolveClaimsConfig}) and keeps the result. */\n protected configureClaims(opts: {\n options: IClaimsConfigSource;\n pinnedAlgorithms?: string[];\n }): void {\n const resolved = AbstractBearerTokenService.resolveClaimsConfig({\n scope: this.scope,\n options: opts.options,\n pinnedAlgorithms: opts.pinnedAlgorithms,\n });\n\n this.claimOptions = resolved.claims;\n this.verifyOptions = resolved.verify;\n }\n\n /** Configures AES payload encryption and field codecs. Both aesAlgorithm and applicationSecret required to activate encryption. */\n protected configurePayloadEncryption(opts: {\n aesAlgorithm?: AESAlgorithmType;\n applicationSecret?: string;\n fieldCodecs?: IPayloadFieldCodec[];\n }): void {\n const { aesAlgorithm = 'aes-256-cbc', applicationSecret, fieldCodecs } = opts;\n\n if (fieldCodecs) {\n for (const codec of fieldCodecs) {\n this.fieldCodecs.set(codec.key, codec);\n }\n }\n\n if (!applicationSecret) {\n return;\n }\n\n this.aes = AES.withAlgorithm(aesAlgorithm);\n this.applicationSecret = applicationSecret;\n }\n\n extractCredentials(context: TContext<E, string>): { type: string; token: string } {\n const request = context.req;\n\n const authHeaderValue = request.header('Authorization');\n\n if (!authHeaderValue) {\n throw getError({\n error: AuthenticationErrors.HEADER_MISSING,\n message: 'Unauthorized user! Missing authorization header',\n });\n }\n\n if (!authHeaderValue.startsWith(Authentication.TYPE_BEARER)) {\n throw getError({\n error: AuthenticationErrors.SCHEME_INVALID,\n message: 'Unauthorized user! Invalid schema of request token!',\n });\n }\n\n const parts = authHeaderValue.split(' ');\n\n if (parts.length !== 2) {\n throw getError({\n error: AuthenticationErrors.HEADER_MALFORMED,\n message: `Authorization header value is invalid format. It must follow the pattern: 'Bearer xx.yy.zz' where xx.yy.zz is a valid JWT token.`,\n });\n }\n\n const [tokenType, tokenValue] = parts;\n\n return { type: tokenType, token: tokenValue };\n }\n\n async verify(opts: { type: string; token: string }): Promise<IJWTTokenPayload> {\n const { token } = opts;\n\n if (!token) {\n this.logger.for(this.verify.name).error('Missing token for validating request!');\n throw getError({\n error: AuthenticationErrors.TOKEN_MISSING,\n message: '[verify] Invalid request token!',\n });\n }\n\n try {\n await this.assertNotServiceAssertion({ token });\n const result = await this.doVerify(token);\n\n return result;\n } catch (error) {\n // No log here - `cause` carries the reason (JWTExpired, signature mismatch) to the error handler, which logs the request once. An expired token is the caller's problem, hence `warn`.\n throw getError({\n error: AuthenticationErrors.TOKEN_INVALID,\n message: '[verify] Invalid or expired token',\n logLevel: 'warn',\n cause: error,\n });\n }\n }\n\n /**\n * A service assertion (`typ: svc+jwt`) is not a user token. When a JWKS issuer shares the key of the service\n * assertions and the names collide, an assertion would otherwise verify here, so the user-token path refuses it.\n */\n protected async assertNotServiceAssertion(opts: { token: string }): Promise<void> {\n const { decodeProtectedHeader } = await JoseLoader.load();\n const { typ } = decodeProtectedHeader(opts.token);\n const kind = typeof typ === 'string' ? typ.toLowerCase().replace(/^application\\//, '') : '';\n\n if (kind === ServiceAssertion.TYP) {\n throw getError({\n error: AuthenticationErrors.TOKEN_INVALID,\n message: '[verify] A service assertion is not a user token',\n });\n }\n }\n\n async generate(opts: {\n payload: IJWTTokenPayload;\n getTokenExpiresFn?: TGetTokenExpiresFn;\n /** Per-token registered claims. The supported way to vary `aud` / `sub`; the payload is not. */\n claims?: IJWTIssueClaims;\n }): Promise<string> {\n const { payload, claims, getTokenExpiresFn = this.getDefaultTokenExpiresFn() } = opts;\n\n if (!payload) {\n throw getError({\n error: AuthenticationErrors.TOKEN_PAYLOAD_INVALID,\n message: '[generate] Invalid token payload!',\n });\n }\n\n const signer = await this.getSigner({ payload, getTokenExpiresFn, claims });\n\n try {\n const result = await this.getSigningKey();\n const rs = await signer.sign(result);\n\n return rs;\n } catch (error) {\n this.logger.for(this.generate.name).error('Failed to generate token | Error: %s', error);\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: '[generate] Failed to generate token',\n });\n }\n }\n\n /** A `null` is written as `null` whatever the field's codec is: a codec converts a value, and `null` is none. */\n protected serializeField(opts: { key: string; value: any }): string {\n const { key, value } = opts;\n const codec = value === null ? undefined : this.fieldCodecs.get(key);\n\n if (codec) {\n return codec.serialize({ value });\n }\n\n return JSON.stringify(value);\n }\n\n /**\n * With `applicationSecret` set, AES-encrypts the key and the value of every claim outside `JWT_COMMON_FIELDS`;\n * without it, returns the payload as is. A `null` claim is encrypted like any other value and decodes as `null`,\n * so the token decodes to the same payload with encryption on or off and `null` stays distinct from absent. An\n * `undefined` claim is skipped, as JSON drops it.\n */\n async encryptPayload(payload: IJWTTokenPayload): Promise<Record<string, any>> {\n if (!this.aes || !this.applicationSecret) {\n return payload;\n }\n\n const rs: Record<string, string> = {};\n\n const keys = Object.keys(payload);\n\n for (const key of keys) {\n const value = payload[key];\n\n if (AbstractBearerTokenService.JWT_COMMON_FIELDS.has(key)) {\n rs[key] = value;\n continue;\n }\n\n // Only `undefined` is skipped: JSON drops it too, so the claim is absent either way. `null` is a value, and\n // `serializeField` writes it as `null`, which `deserializeField` reads back, so an encrypted token decodes the\n // same payload as a plain one.\n if (value === undefined) {\n continue;\n }\n\n const encryptedKey = await this.aes.encrypt({\n message: key,\n secret: this.applicationSecret,\n });\n\n const serialized = this.serializeField({ key, value });\n\n const encryptedValue = await this.aes.encrypt({\n message: serialized,\n secret: this.applicationSecret,\n });\n rs[encryptedKey] = encryptedValue;\n }\n\n return rs;\n }\n\n /** The text `null` reads as `null` before any codec sees it, the other half of {@link serializeField}. */\n protected deserializeField(opts: { key: string; value: string }) {\n const { key, value } = opts;\n const codec = value === 'null' ? undefined : this.fieldCodecs.get(key);\n\n if (codec) {\n return codec.deserialize({ raw: value });\n }\n\n return JSON.parse(value);\n }\n\n /**\n * Stamps the configured `iss` / `aud` onto a signer, plus any per-token claims the caller passed.\n *\n * The configured value is AUTHORITATIVE. `iss` and `aud` are in `JWT_COMMON_FIELDS`, so they ride\n * through the AES envelope in the clear and an application-shaped payload can carry them - an\n * issuer identity any payload could overwrite would not be an identity. A conflicting payload\n * claim is overwritten and reported.\n *\n * Per-token audience is an explicit argument rather than a smuggled payload key, so the caller\n * that legitimately needs one says so.\n */\n protected applySignClaims(opts: {\n signer: SignJWT;\n payload: Record<string, any>;\n claims?: IJWTIssueClaims;\n }): SignJWT {\n const { signer, payload, claims } = opts;\n const configured = this.claimOptions;\n\n const issuer = claims?.issuer ?? configured?.issuer;\n const audience = claims?.audience ?? configured?.audience;\n\n const logger = this.logger.for(this.applySignClaims.name);\n\n if (issuer !== undefined) {\n if (payload.iss !== undefined && payload.iss !== issuer) {\n logger.warn(\n 'Payload iss overridden by the configured issuer | payload: %s | configured: %s',\n payload.iss,\n issuer,\n );\n }\n\n signer.setIssuer(issuer);\n }\n\n if (audience !== undefined) {\n if (payload.aud !== undefined) {\n logger.warn('Payload aud overridden | payload: %j | applied: %j', payload.aud, audience);\n }\n\n signer.setAudience(audience);\n }\n\n if (claims?.subject !== undefined) {\n signer.setSubject(claims.subject);\n }\n\n if (claims?.jwtId !== undefined) {\n signer.setJti(claims.jwtId);\n }\n\n return signer;\n }\n\n async decryptPayload(opts: {\n result: JWTVerifyResult<IJWTTokenPayload>;\n }): Promise<IJWTTokenPayload> {\n const { payload, protectedHeader } = opts.result;\n\n if (!this.aes || !this.applicationSecret) {\n return payload as IJWTTokenPayload;\n }\n\n this.logger\n .for(this.decryptPayload.name)\n .debug('JWT Token | payload: %j | header: %j', payload, protectedHeader);\n\n const rs: any = {};\n\n for (const key in payload) {\n if (AbstractBearerTokenService.JWT_COMMON_FIELDS.has(key)) {\n rs[key] = payload[key];\n continue;\n }\n\n const decryptedKey = await this.aes.decrypt({\n message: key,\n secret: this.applicationSecret,\n });\n const decryptedValue = await this.aes.decrypt({\n message: payload[key],\n secret: this.applicationSecret,\n });\n\n rs[decryptedKey] = this.deserializeField({ key: decryptedKey, value: decryptedValue });\n }\n\n return rs;\n }\n\n protected abstract doVerify(token: string): Promise<IJWTTokenPayload>;\n\n abstract getSigner(opts: {\n payload: IJWTTokenPayload;\n getTokenExpiresFn: TGetTokenExpiresFn;\n claims?: IJWTIssueClaims;\n }): Promise<SignJWT>;\n\n protected abstract getSigningKey(): ValueOrPromise<Uint8Array | CryptoKey>;\n\n protected abstract getDefaultTokenExpiresFn(): TGetTokenExpiresFn;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"abstract.service.js","sourceRoot":"","sources":["../../../../../../../src/components/auth/authenticate/services/bearer/abstract.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAE7C,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAUtE,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,WAAW,EACX,gBAAgB,GACjB,MAAM,uBAAuB,CAAC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YACnD,MAAM,QAAQ,CAAC;gBACb,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY;gBAC9C,OAAO,EAAE,uDAAuD;aACjE,CAAC,CAAC;QACL,CAAC;QAED,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,oEAAoE;IAC5D,MAAM,CAAC,cAAc,CAAC,KAA8B;QAC1D,OAAO,QAAQ,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC;IACzD,CAAC","sourcesContent":["import type { AESAlgorithmType } from '@venizia/ignis-helpers';\nimport { AES } from '@venizia/ignis-helpers';\nimport type { ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport { HTTP } from '@venizia/ignis-helpers/common';\nimport { getError, RecordUtility } from '@venizia/ignis-helpers/core';\nimport type {\n IJWTClaimsOptions,\n IJWTIssueClaims,\n IJWTTokenPayload,\n IJWTVerifyOptions,\n IPayloadFieldCodec,\n TContext,\n TGetTokenExpiresFn,\n} from '@venizia/ignis-kernel';\nimport {\n Authentication,\n AuthenticationErrors,\n BaseService,\n ServiceAssertion,\n} from '@venizia/ignis-kernel';\nimport type { Env } from 'hono';\nimport { JoseLoader } from '../jose-loader';\nimport type { JWTPayload, JWTVerifyOptions, JWTVerifyResult, SignJWT } from 'jose';\n\n/** What a token service is configured with for claims: the required `claims`, the `verify` checks, and the removed `sign` it refuses. */\nexport interface IClaimsConfigSource {\n claims?: unknown;\n verify?: unknown;\n /** Removed: refused with a message that points to `claims`. */\n sign?: unknown;\n}\n\n/** What {@link AbstractBearerTokenService.resolveClaimsConfig} answers: the validated claims and the verify options jose receives. */\nexport interface IResolvedClaimsConfig {\n claims: IJWTClaimsOptions;\n verify: JWTVerifyOptions & { algorithms: string[] };\n}\n\n/** Abstract base for Bearer-token services (JWS, JWKS) with optional AES payload encryption. */\nexport abstract class AbstractBearerTokenService<E extends Env = Env> extends BaseService {\n /** Standard JWT fields that are never encrypted. */\n static readonly JWT_COMMON_FIELDS = new Set<keyof JWTPayload>([\n 'iss',\n 'sub',\n 'aud',\n 'jti',\n 'nbf',\n 'exp',\n 'iat',\n ]);\n\n protected aes: AES | null = null;\n protected applicationSecret: string | null = null;\n protected fieldCodecs: Map<string, IPayloadFieldCodec> = new Map();\n\n /** Configured `iss` / `aud`: stamped on every issued token, authoritative over anything the payload carries, and required on every verified one. */\n protected claimOptions: IJWTClaimsOptions | null = null;\n\n /** What jose verifies against: the claims, the algorithm pin and the `verify` checks. */\n protected verifyOptions: JWTVerifyOptions | null = null;\n\n /** The keys a `claims` object may hold. */\n static readonly CLAIM_KEYS: ReadonlyArray<string> = ['issuer', 'audience'];\n\n /**\n * Validates the claims configuration of a token service and answers what the service uses. It throws, naming the\n * key, when `claims.issuer` is missing or empty, when `claims.audience` is present but not a non-empty string or a\n * non-empty list of them, when `claims` holds another key, when the removed `sign` or `verify.issuer` /\n * `verify.audience` is still passed, and when no algorithm is pinned. `claims.audience` is optional: without it\n * no `aud` is stamped and none is checked.\n * `pinnedAlgorithms` is what the service signs with; a verifier has none and requires `verify.algorithms`.\n * The component calls it at boot, and a service calls it when it is built, so neither can start without them.\n */\n static resolveClaimsConfig(opts: {\n scope: string;\n options: IClaimsConfigSource;\n pinnedAlgorithms?: string[];\n }): IResolvedClaimsConfig {\n const { scope, options, pinnedAlgorithms } = opts;\n const fail = (detail: string) =>\n getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: `[${scope}] ${detail}`,\n });\n\n if (options.sign !== undefined) {\n throw fail(\n '`sign` was removed | put the issuer and the audience in `claims: { issuer, audience }`: they are stamped on every token and required on every verified one',\n );\n }\n\n if (options.verify !== undefined && !RecordUtility.isPlainRecord(options.verify)) {\n throw fail(\n 'verify must be an object | its checks (maxTokenAge, subject, ...) would be dropped silently',\n );\n }\n\n const verify = RecordUtility.isPlainRecord(options.verify) ? options.verify : {};\n\n for (const key of AbstractBearerTokenService.CLAIM_KEYS) {\n if (key in verify) {\n throw fail(\n `verify.${key} was removed | set claims.${key}: it is stamped on every token and required on every verified one`,\n );\n }\n }\n\n const { claims } = options;\n\n if (!RecordUtility.isPlainRecord(claims)) {\n throw fail(\n 'claims is required | pass claims: { issuer: string, audience: string | string[] }: a token signed with the same key for another purpose must not authenticate a request',\n );\n }\n\n const unknown = Object.keys(claims).filter(\n (key) => !AbstractBearerTokenService.CLAIM_KEYS.includes(key),\n );\n\n if (unknown.length > 0) {\n throw fail(\n `claims holds unknown keys ${JSON.stringify(unknown)} | accepted: ${AbstractBearerTokenService.CLAIM_KEYS.join(', ')}`,\n );\n }\n\n const { issuer, audience } = claims;\n const isName = (value: unknown): value is string =>\n typeof value === 'string' && value.trim().length > 0;\n\n if (!isName(issuer)) {\n throw fail('claims.issuer is required | a non-empty string');\n }\n\n // Optional, but a present value is checked: `null`, `''` and `[]` are mistakes, not \"no audience\".\n if (\n audience !== undefined &&\n !isName(audience) &&\n !(Array.isArray(audience) && audience.length > 0 && audience.every(isName))\n ) {\n throw fail(\n 'claims.audience must be a non-empty string or a non-empty list of them | or leave it out',\n );\n }\n\n const resolvedAudience = Array.isArray(audience) ? [...audience] : audience;\n\n const algorithms = verify.algorithms ?? pinnedAlgorithms;\n\n if (!Array.isArray(algorithms) || algorithms.length === 0 || !algorithms.every(isName)) {\n throw fail(\n \"verify.algorithms is required | the accepted JWS algorithms, for example ['RS256']: a verifier cannot know what the issuer signs with\",\n );\n }\n\n if (algorithms.some((algorithm) => algorithm.trim().toLowerCase() === 'none')) {\n throw fail(\"the algorithm 'none' is refused | a token with no signature verifies nothing\");\n }\n\n return {\n claims: { issuer, ...(resolvedAudience === undefined ? {} : { audience: resolvedAudience }) },\n verify: {\n ...(verify as IJWTVerifyOptions),\n issuer,\n ...(resolvedAudience === undefined ? {} : { audience: resolvedAudience }),\n algorithms: [...algorithms],\n },\n };\n }\n\n /** Validates the claims configuration (see {@link AbstractBearerTokenService.resolveClaimsConfig}) and keeps the result. */\n protected configureClaims(opts: {\n options: IClaimsConfigSource;\n pinnedAlgorithms?: string[];\n }): void {\n const resolved = AbstractBearerTokenService.resolveClaimsConfig({\n scope: this.scope,\n options: opts.options,\n pinnedAlgorithms: opts.pinnedAlgorithms,\n });\n\n this.claimOptions = resolved.claims;\n this.verifyOptions = resolved.verify;\n }\n\n /** Configures AES payload encryption and field codecs. Both aesAlgorithm and applicationSecret required to activate encryption. */\n protected configurePayloadEncryption(opts: {\n aesAlgorithm?: AESAlgorithmType;\n applicationSecret?: string;\n fieldCodecs?: IPayloadFieldCodec[];\n }): void {\n const { aesAlgorithm = 'aes-256-cbc', applicationSecret, fieldCodecs } = opts;\n\n if (fieldCodecs) {\n for (const codec of fieldCodecs) {\n this.fieldCodecs.set(codec.key, codec);\n }\n }\n\n if (!applicationSecret) {\n return;\n }\n\n this.aes = AES.withAlgorithm(aesAlgorithm);\n this.applicationSecret = applicationSecret;\n }\n\n extractCredentials(context: TContext<E, string>): { type: string; token: string } {\n const request = context.req;\n\n const authHeaderValue = request.header('Authorization');\n\n if (!authHeaderValue) {\n throw getError({\n error: AuthenticationErrors.HEADER_MISSING,\n message: 'Unauthorized user! Missing authorization header',\n });\n }\n\n if (!authHeaderValue.startsWith(Authentication.TYPE_BEARER)) {\n throw getError({\n error: AuthenticationErrors.SCHEME_INVALID,\n message: 'Unauthorized user! Invalid schema of request token!',\n });\n }\n\n const parts = authHeaderValue.split(' ');\n\n if (parts.length !== 2) {\n throw getError({\n error: AuthenticationErrors.HEADER_MALFORMED,\n message: `Authorization header value is invalid format. It must follow the pattern: 'Bearer xx.yy.zz' where xx.yy.zz is a valid JWT token.`,\n });\n }\n\n const [tokenType, tokenValue] = parts;\n\n return { type: tokenType, token: tokenValue };\n }\n\n async verify(opts: { type: string; token: string }): Promise<IJWTTokenPayload> {\n const { token } = opts;\n\n if (!token) {\n this.logger.for(this.verify.name).error('Missing token for validating request!');\n throw getError({\n error: AuthenticationErrors.TOKEN_MISSING,\n message: '[verify] Invalid request token!',\n });\n }\n\n try {\n await this.assertNotServiceAssertion({ token });\n const result = await this.doVerify(token);\n\n return result;\n } catch (error) {\n // No log here - `cause` carries the reason (JWTExpired, signature mismatch) to the error handler, which logs the request once. An expired token is the caller's problem, hence `warn`.\n throw getError({\n error: AuthenticationErrors.TOKEN_INVALID,\n message: '[verify] Invalid or expired token',\n logLevel: 'warn',\n cause: error,\n });\n }\n }\n\n /**\n * A service assertion (`typ: svc+jwt`) is not a user token. When a JWKS issuer shares the key of the service\n * assertions and the names collide, an assertion would otherwise verify here, so the user-token path refuses it.\n */\n protected async assertNotServiceAssertion(opts: { token: string }): Promise<void> {\n const { decodeProtectedHeader } = await JoseLoader.load();\n const { typ } = decodeProtectedHeader(opts.token);\n const kind = typeof typ === 'string' ? typ.toLowerCase().replace(/^application\\//, '') : '';\n\n if (kind === ServiceAssertion.TYP) {\n throw getError({\n error: AuthenticationErrors.TOKEN_INVALID,\n message: '[verify] A service assertion is not a user token',\n });\n }\n }\n\n async generate(opts: {\n payload: IJWTTokenPayload;\n getTokenExpiresFn?: TGetTokenExpiresFn;\n /** Per-token registered claims. The supported way to vary `aud` / `sub`; the payload is not. */\n claims?: IJWTIssueClaims;\n }): Promise<string> {\n const { payload, claims, getTokenExpiresFn = this.getDefaultTokenExpiresFn() } = opts;\n\n if (!payload) {\n throw getError({\n error: AuthenticationErrors.TOKEN_PAYLOAD_INVALID,\n message: '[generate] Invalid token payload!',\n });\n }\n\n const signer = await this.getSigner({ payload, getTokenExpiresFn, claims });\n\n try {\n const result = await this.getSigningKey();\n const rs = await signer.sign(result);\n\n return rs;\n } catch (error) {\n this.logger.for(this.generate.name).error('Failed to generate token | Error: %s', error);\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: '[generate] Failed to generate token',\n });\n }\n }\n\n /** A `null` is written as `null` whatever the field's codec is: a codec converts a value, and `null` is none. */\n protected serializeField(opts: { key: string; value: unknown }): string {\n const { key, value } = opts;\n const codec = value === null ? undefined : this.fieldCodecs.get(key);\n\n if (codec) {\n return codec.serialize({ value });\n }\n\n return JSON.stringify(value);\n }\n\n /**\n * With `applicationSecret` set, AES-encrypts the key and the value of every claim outside `JWT_COMMON_FIELDS`;\n * without it, returns the payload as is. A `null` claim is encrypted like any other value and decodes as `null`,\n * so the token decodes to the same payload with encryption on or off and `null` stays distinct from absent. An\n * `undefined` claim is skipped, as JSON drops it.\n */\n async encryptPayload(payload: IJWTTokenPayload): Promise<Record<string, unknown>> {\n if (!this.aes || !this.applicationSecret) {\n return payload;\n }\n\n const rs: Record<string, unknown> = {};\n\n const keys = Object.keys(payload);\n\n for (const key of keys) {\n const value = payload[key];\n\n if (AbstractBearerTokenService.JWT_COMMON_FIELDS.has(key)) {\n rs[key] = value;\n continue;\n }\n\n // Only `undefined` is skipped: JSON drops it too, so the claim is absent either way. `null` is a value, and\n // `serializeField` writes it as `null`, which `deserializeField` reads back, so an encrypted token decodes the\n // same payload as a plain one.\n if (value === undefined) {\n continue;\n }\n\n const encryptedKey = await this.aes.encrypt({\n message: key,\n secret: this.applicationSecret,\n });\n\n const serialized = this.serializeField({ key, value });\n\n const encryptedValue = await this.aes.encrypt({\n message: serialized,\n secret: this.applicationSecret,\n });\n rs[encryptedKey] = encryptedValue;\n }\n\n return rs;\n }\n\n /** The text `null` reads as `null` before any codec sees it, the other half of {@link serializeField}. */\n protected deserializeField(opts: { key: string; value: string }) {\n const { key, value } = opts;\n const codec = value === 'null' ? undefined : this.fieldCodecs.get(key);\n\n if (codec) {\n return codec.deserialize({ raw: value });\n }\n\n return JSON.parse(value);\n }\n\n /**\n * Stamps the configured `iss` / `aud` onto a signer, plus any per-token claims the caller passed.\n *\n * The configured value is AUTHORITATIVE. `iss` and `aud` are in `JWT_COMMON_FIELDS`, so they ride\n * through the AES envelope in the clear and an application-shaped payload can carry them - an\n * issuer identity any payload could overwrite would not be an identity. A conflicting payload\n * claim is overwritten and reported.\n *\n * Per-token audience is an explicit argument rather than a smuggled payload key, so the caller\n * that legitimately needs one says so.\n */\n protected applySignClaims(opts: {\n signer: SignJWT;\n payload: Record<string, unknown>;\n claims?: IJWTIssueClaims;\n }): SignJWT {\n const { signer, payload, claims } = opts;\n const configured = this.claimOptions;\n\n const issuer = claims?.issuer ?? configured?.issuer;\n const audience = claims?.audience ?? configured?.audience;\n\n const logger = this.logger.for(this.applySignClaims.name);\n\n if (issuer !== undefined) {\n if (payload.iss !== undefined && payload.iss !== issuer) {\n logger.warn(\n 'Payload iss overridden by the configured issuer | payload: %s | configured: %s',\n payload.iss,\n issuer,\n );\n }\n\n signer.setIssuer(issuer);\n }\n\n if (audience !== undefined) {\n if (payload.aud !== undefined) {\n logger.warn('Payload aud overridden | payload: %j | applied: %j', payload.aud, audience);\n }\n\n signer.setAudience(audience);\n }\n\n if (claims?.subject !== undefined) {\n signer.setSubject(claims.subject);\n }\n\n if (claims?.jwtId !== undefined) {\n signer.setJti(claims.jwtId);\n }\n\n return signer;\n }\n\n async decryptPayload(opts: {\n result: JWTVerifyResult<IJWTTokenPayload>;\n }): Promise<IJWTTokenPayload> {\n const { payload, protectedHeader } = opts.result;\n\n if (!this.aes || !this.applicationSecret) {\n return payload as IJWTTokenPayload;\n }\n\n this.logger\n .for(this.decryptPayload.name)\n .debug('JWT Token | payload: %j | header: %j', payload, protectedHeader);\n\n const rs: Record<string, unknown> = {};\n\n for (const key in payload) {\n if (AbstractBearerTokenService.JWT_COMMON_FIELDS.has(key)) {\n rs[key] = payload[key];\n continue;\n }\n\n const decryptedKey = await this.aes.decrypt({\n message: key,\n secret: this.applicationSecret,\n });\n const encryptedValue = payload[key];\n\n if (typeof encryptedValue !== 'string') {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_4.Unauthorized,\n message: '[decryptPayload] An encrypted claim is not a string',\n });\n }\n\n const decryptedValue = await this.aes.decrypt({\n message: encryptedValue,\n secret: this.applicationSecret,\n });\n\n rs[decryptedKey] = this.deserializeField({ key: decryptedKey, value: decryptedValue });\n }\n\n if (!AbstractBearerTokenService.isTokenPayload(rs)) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_4.Unauthorized,\n message: '[decryptPayload] The decrypted claims carry no userId',\n });\n }\n\n return rs;\n }\n\n /** A decrypted claim set is a payload only if it names its user. */\n private static isTokenPayload(value: Record<string, unknown>): value is IJWTTokenPayload {\n return 'userId' in value && value.userId !== undefined;\n }\n\n protected abstract doVerify(token: string): Promise<IJWTTokenPayload>;\n\n abstract getSigner(opts: {\n payload: IJWTTokenPayload;\n getTokenExpiresFn: TGetTokenExpiresFn;\n claims?: IJWTIssueClaims;\n }): Promise<SignJWT>;\n\n protected abstract getSigningKey(): ValueOrPromise<Uint8Array | CryptoKey>;\n\n protected abstract getDefaultTokenExpiresFn(): TGetTokenExpiresFn;\n}\n"]}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { IdType } from '../../../../../base/index.js';
|
|
2
|
-
import type { AnyType } from '@venizia/ignis-helpers/common';
|
|
3
2
|
import type { PgDatabase, PgQueryResultHKT } from 'drizzle-orm/pg-core';
|
|
4
3
|
/** Filter passed to loadFilteredPolicy: which principal's policies to load. */
|
|
5
4
|
export interface ICasbinPolicyFilter {
|
|
@@ -9,7 +8,7 @@ export interface ICasbinPolicyFilter {
|
|
|
9
8
|
};
|
|
10
9
|
}
|
|
11
10
|
/** Drizzle connector for policy queries, typed on the shared `PgDatabase` base so postgres-js fits too. Declared here rather than imported from `@/connectors/postgres`: components depend on a minimal local contract, never a connector class. */
|
|
12
|
-
export type TCasbinPolicyConnector = PgDatabase<PgQueryResultHKT, Record<string,
|
|
11
|
+
export type TCasbinPolicyConnector = PgDatabase<PgQueryResultHKT, Record<string, unknown>>;
|
|
13
12
|
/** Minimal source the adapters depend on - any drizzle-backed datasource satisfies it. */
|
|
14
13
|
export interface ICasbinPolicySource {
|
|
15
14
|
/** A datasource that opens on first use opens here; one that opens at start resolves at once. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../src/components/auth/authorize/adapters/common/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { IdType } from '@/base';\nimport type {
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../src/components/auth/authorize/adapters/common/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { IdType } from '@/base';\nimport type { PgDatabase, PgQueryResultHKT } from 'drizzle-orm/pg-core';\n\n/** Filter passed to loadFilteredPolicy: which principal's policies to load. */\nexport interface ICasbinPolicyFilter {\n principal: { type: string; id: IdType };\n}\n\n/** Drizzle connector for policy queries, typed on the shared `PgDatabase` base so postgres-js fits too. Declared here rather than imported from `@/connectors/postgres`: components depend on a minimal local contract, never a connector class. */\nexport type TCasbinPolicyConnector = PgDatabase<PgQueryResultHKT, Record<string, unknown>>;\n\n/** Minimal source the adapters depend on - any drizzle-backed datasource satisfies it. */\nexport interface ICasbinPolicySource {\n /** A datasource that opens on first use opens here; one that opens at start resolves at once. */\n ensureOpen?(): Promise<void>;\n\n /** Preferred: lazily wires the driver on first read and survives pool rotation, mirroring repositories. */\n getConnector?(): TCasbinPolicyConnector;\n\n /** Back-compat: a pre-wired connector. Prefer getConnector on a real datasource. */\n connector?: TCasbinPolicyConnector;\n}\n\n/** Maps a logical table onto its physical name + schema. */\nexport interface IScopedCasbinTable {\n tableName: string;\n schemaName?: string;\n}\n\n/** All physical mapping the ScopedCasbinAdapter needs. App provides this; framework stays decoupled. */\nexport interface IScopedCasbinEntities {\n policyDefinition: IScopedCasbinTable & {\n metadata?: { columnName: string };\n };\n\n /** Permission catalog (id, code, ...). */\n permission: IScopedCasbinTable;\n\n /** Principal type labels used as casbin name prefixes. */\n principals: { user: string; role: string };\n\n /** Domain type labels (e.g. ['Merchant', 'Organizer']). */\n domainTypes: string[];\n\n /** Soft-delete handling for both tables. */\n softDelete?: { use: false } | { use: true; columnName: string };\n}\n"]}
|
|
@@ -8,7 +8,7 @@ export interface IMailAttachment {
|
|
|
8
8
|
content?: string | Buffer | Uint8Array | Readable | ReadableStream<Uint8Array>;
|
|
9
9
|
encoding?: BufferEncoding;
|
|
10
10
|
cid?: string;
|
|
11
|
-
[key: string]:
|
|
11
|
+
[key: string]: unknown;
|
|
12
12
|
}
|
|
13
13
|
/** A mail to send. `to` needs at least one recipient, `subject` is required, and at least one of `text` or `html` must be set; `from` falls back to the options' `from` (with `fromName`). */
|
|
14
14
|
export interface IMailMessage {
|
|
@@ -28,13 +28,13 @@ export interface IMailMessage {
|
|
|
28
28
|
attachments?: IMailAttachment[];
|
|
29
29
|
headers?: Record<string, string>;
|
|
30
30
|
requireValidate?: boolean;
|
|
31
|
-
[key: string]:
|
|
31
|
+
[key: string]: unknown;
|
|
32
32
|
}
|
|
33
33
|
/** Outcome of one send: `success` plus the provider `messageId`, or an `error` string when the send failed. */
|
|
34
34
|
export interface IMailSendResult {
|
|
35
35
|
success: boolean;
|
|
36
36
|
messageId?: string;
|
|
37
|
-
response?:
|
|
37
|
+
response?: unknown;
|
|
38
38
|
error?: string;
|
|
39
39
|
}
|
|
40
40
|
/** A mail provider backend. `verify` checks the connection or credentials; `close`, when present, releases the client. */
|
|
@@ -51,7 +51,7 @@ export interface IMailService {
|
|
|
51
51
|
}): Promise<IMailSendResult[]>;
|
|
52
52
|
sendTemplate(opts: {
|
|
53
53
|
templateName: string;
|
|
54
|
-
data: Record<string,
|
|
54
|
+
data: Record<string, unknown>;
|
|
55
55
|
recipients: string | string[];
|
|
56
56
|
options?: Partial<IMailMessage>;
|
|
57
57
|
}): Promise<IMailSendResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../../../../../src/components/mail/common/types/message.ts"],"names":[],"mappings":"","sourcesContent":["import type { Readable } from 'node:stream';\n\n/** One attachment on an `IMailMessage`. Give `content` or `path`; `cid` makes the part inline, referenced as `cid:<value>` from the HTML body. */\nexport interface IMailAttachment {\n filename?: string;\n contentType?: string;\n /** A file under the mail options' `attachmentRoot`; refused when no root is set. */\n path?: string;\n content?: string | Buffer | Uint8Array | Readable | ReadableStream<Uint8Array>;\n encoding?: BufferEncoding;\n cid?: string;\n [key: string]:
|
|
1
|
+
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../../../../../src/components/mail/common/types/message.ts"],"names":[],"mappings":"","sourcesContent":["import type { Readable } from 'node:stream';\n\n/** One attachment on an `IMailMessage`. Give `content` or `path`; `cid` makes the part inline, referenced as `cid:<value>` from the HTML body. */\nexport interface IMailAttachment {\n filename?: string;\n contentType?: string;\n /** A file under the mail options' `attachmentRoot`; refused when no root is set. */\n path?: string;\n content?: string | Buffer | Uint8Array | Readable | ReadableStream<Uint8Array>;\n encoding?: BufferEncoding;\n cid?: string;\n [key: string]: unknown;\n}\n\n/** A mail to send. `to` needs at least one recipient, `subject` is required, and at least one of `text` or `html` must be set; `from` falls back to the options' `from` (with `fromName`). */\nexport interface IMailMessage {\n /**\n * Sender of this message.\n *\n * @default the mail options' `from` with `fromName`, else `MailDefaults.FALLBACK_FROM`\n */\n from?: string;\n to: string | string[];\n cc?: string | string[];\n bcc?: string | string[];\n replyTo?: string;\n subject: string;\n text?: string;\n html?: string;\n attachments?: IMailAttachment[];\n headers?: Record<string, string>;\n requireValidate?: boolean;\n [key: string]: unknown;\n}\n\n/** Outcome of one send: `success` plus the provider `messageId`, or an `error` string when the send failed. */\nexport interface IMailSendResult {\n success: boolean;\n messageId?: string;\n response?: unknown;\n error?: string;\n}\n\n/** A mail provider backend. `verify` checks the connection or credentials; `close`, when present, releases the client. */\nexport interface IMailTransport {\n send(message: IMailMessage): Promise<IMailSendResult>;\n verify(): Promise<boolean>;\n close?(): Promise<void>;\n}\n\n/** The service callers use to send mail; wraps the configured `IMailTransport`. */\nexport interface IMailService {\n send(message: IMailMessage): Promise<IMailSendResult>;\n sendBatch(\n messages: IMailMessage[],\n options?: {\n concurrency?: number;\n },\n ): Promise<IMailSendResult[]>;\n sendTemplate(opts: {\n templateName: string;\n data: Record<string, unknown>;\n recipients: string | string[];\n options?: Partial<IMailMessage>;\n }): Promise<IMailSendResult>;\n verify(): Promise<boolean>;\n}\n"]}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { AnyType } from '@venizia/ignis-helpers/common';
|
|
2
1
|
import type SMTPTransport from 'nodemailer/lib/smtp-transport';
|
|
3
2
|
import type { IMailTransport } from './message.js';
|
|
4
3
|
/** Options shared by every mail provider. */
|
|
@@ -48,15 +47,19 @@ export interface ICustomMailOptions extends IBaseMailOptions {
|
|
|
48
47
|
/** Mail options with an arbitrary provider name and config; accepted by the type, but the transport provider throws on a name it does not support. */
|
|
49
48
|
export interface IGenericMailOptions extends IBaseMailOptions {
|
|
50
49
|
provider: string;
|
|
51
|
-
config: Record<string,
|
|
50
|
+
config: Record<string, unknown>;
|
|
52
51
|
}
|
|
53
52
|
/** Options passed to the mail component, discriminated by `provider`. */
|
|
54
53
|
export type TMailOptions = INodemailerMailOptions | IAmazonSesMailOptions | IMailgunMailOptions | ICustomMailOptions | IGenericMailOptions;
|
|
55
54
|
/** Nodemailer `createTransport` argument: a transport instance, SMTP options or a connection URL. */
|
|
56
55
|
export type TNodemailerConfig = SMTPTransport | SMTPTransport.Options | string;
|
|
57
|
-
/** Mailgun client options (`mailgun.js`) plus the sending `domain`. */
|
|
58
|
-
export type TMailgunConfig =
|
|
56
|
+
/** Mailgun client options (`mailgun.js`) plus the sending `domain`; the transport throws on a missing `username`, `key` or `domain`. */
|
|
57
|
+
export type TMailgunConfig = {
|
|
58
|
+
username: string;
|
|
59
|
+
key: string;
|
|
59
60
|
domain: string;
|
|
61
|
+
url?: string;
|
|
62
|
+
[option: string]: unknown;
|
|
60
63
|
};
|
|
61
64
|
/**
|
|
62
65
|
* The peer module itself, handed over by an application that already holds it. A `bun build
|
|
@@ -66,10 +69,31 @@ export type TMailgunConfig = AnyType & {
|
|
|
66
69
|
* a compile error rather than a boot crash.
|
|
67
70
|
*/
|
|
68
71
|
export type TNodemailerModule = {
|
|
69
|
-
createTransport
|
|
72
|
+
createTransport(config: TNodemailerConfig): INodemailerTransporter;
|
|
70
73
|
};
|
|
74
|
+
/** The part of a `nodemailer` transporter the transport calls. */
|
|
75
|
+
export interface INodemailerTransporter {
|
|
76
|
+
sendMail(mailOptions: object): Promise<{
|
|
77
|
+
messageId?: string;
|
|
78
|
+
response?: unknown;
|
|
79
|
+
}>;
|
|
80
|
+
verify(): Promise<unknown>;
|
|
81
|
+
close(): void;
|
|
82
|
+
}
|
|
83
|
+
/** The result of one `mailgun.js` send; `id` is the message id. */
|
|
84
|
+
export interface IMailgunSendResult {
|
|
85
|
+
id?: string;
|
|
86
|
+
}
|
|
87
|
+
/** The part of the `mailgun.js` messages client the transport calls. */
|
|
88
|
+
export interface IMailgunMessagesClient {
|
|
89
|
+
create(domain: string, message: object): Promise<IMailgunSendResult>;
|
|
90
|
+
}
|
|
71
91
|
/** The `mailgun.js` class, as a constructor taking the form-data implementation. */
|
|
72
|
-
export type TMailgunModule = new (formData:
|
|
92
|
+
export type TMailgunModule = new (formData: typeof FormData) => {
|
|
93
|
+
client(config: object): {
|
|
94
|
+
messages: IMailgunMessagesClient;
|
|
95
|
+
};
|
|
96
|
+
};
|
|
73
97
|
/** Amazon SES client configuration: `region` is required; `credentials` and `endpoint` are optional. */
|
|
74
98
|
export type TAmazonSesConfig = {
|
|
75
99
|
region: string;
|
|
@@ -80,14 +104,34 @@ export type TAmazonSesConfig = {
|
|
|
80
104
|
};
|
|
81
105
|
endpoint?: string;
|
|
82
106
|
};
|
|
107
|
+
/** The part of an `@aws-sdk/client-sesv2` client the transport calls; `send` resolves with the command's output. */
|
|
108
|
+
export interface IAmazonSesClient {
|
|
109
|
+
send(command: object): Promise<unknown>;
|
|
110
|
+
destroy?(): void;
|
|
111
|
+
}
|
|
112
|
+
/** The input of a `SendEmailCommand`: the sender, the recipients and the raw MIME body. */
|
|
113
|
+
export interface IAmazonSesSendEmailInput {
|
|
114
|
+
FromEmailAddress?: string;
|
|
115
|
+
Destination: {
|
|
116
|
+
ToAddresses: string[];
|
|
117
|
+
CcAddresses?: string[];
|
|
118
|
+
BccAddresses?: string[];
|
|
119
|
+
};
|
|
120
|
+
ReplyToAddresses?: string[];
|
|
121
|
+
Content: {
|
|
122
|
+
Raw: {
|
|
123
|
+
Data: Uint8Array;
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
}
|
|
83
127
|
/** Same story as {@link TNodemailerModule} - a compiled binary hands this over explicitly since there is no `node_modules` to resolve `@aws-sdk/client-sesv2` against. */
|
|
84
|
-
export type TAmazonSesModule<TConfig
|
|
128
|
+
export type TAmazonSesModule<TConfig = TAmazonSesConfig, TClient extends IAmazonSesClient = IAmazonSesClient> = {
|
|
85
129
|
SESv2Client: new (config: TConfig) => TClient;
|
|
86
|
-
SendEmailCommand: new (input:
|
|
87
|
-
GetAccountCommand: new (input
|
|
130
|
+
SendEmailCommand: new (input: IAmazonSesSendEmailInput) => object;
|
|
131
|
+
GetAccountCommand: new (input: object) => object;
|
|
88
132
|
};
|
|
89
133
|
/** An Amazon SES client with the command classes the transport sends and verifies with. */
|
|
90
134
|
export type TAmazonSesClient = Pick<TAmazonSesModule, 'SendEmailCommand' | 'GetAccountCommand'> & {
|
|
91
|
-
client:
|
|
135
|
+
client: IAmazonSesClient;
|
|
92
136
|
};
|
|
93
137
|
//# sourceMappingURL=options.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../../../../../src/components/mail/common/types/options.ts"],"names":[],"mappings":"","sourcesContent":["import type
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../../../../../src/components/mail/common/types/options.ts"],"names":[],"mappings":"","sourcesContent":["import type SMTPTransport from 'nodemailer/lib/smtp-transport';\nimport type { IMailTransport } from './message';\n\n/** Options shared by every mail provider. */\nexport interface IBaseMailOptions {\n /**\n * Sender used when a message sets none.\n *\n * @default MailDefaults.FALLBACK_FROM\n */\n from?: string;\n fromName?: string;\n /**\n * The only directory an `attachment.path` may be read from; `path` is resolved against it and\n * refused if it lands outside, symlinks included. Unset, every `path` is refused.\n */\n attachmentRoot?: string;\n /**\n * Bytes of attachment content one message may carry, all attachments together.\n *\n * @default MailDefaults.MAX_ATTACHMENT_BYTES\n */\n maxAttachmentBytes?: number;\n}\n\n/** Mail options for the `nodemailer` provider; `module` hands over the `nodemailer` module instead of loading it by name. */\nexport interface INodemailerMailOptions extends IBaseMailOptions {\n provider: 'nodemailer';\n config: TNodemailerConfig;\n module?: TNodemailerModule;\n}\n\n/** Mail options for the `mailgun` provider; `config` needs `username`, `key` and `domain`, and `module` hands over the `mailgun.js` module. */\nexport interface IMailgunMailOptions extends IBaseMailOptions {\n provider: 'mailgun';\n config: TMailgunConfig;\n module?: TMailgunModule;\n}\n\n/** Mail options for the `amazon-ses` provider (SES HTTPS API); use `nodemailer` for SES over SMTP. */\nexport interface IAmazonSesMailOptions extends IBaseMailOptions {\n provider: 'amazon-ses';\n config: TAmazonSesConfig;\n module?: TAmazonSesModule;\n}\n\n/** Mail options for the `custom` provider; `config` is the transport to use as is. */\nexport interface ICustomMailOptions extends IBaseMailOptions {\n provider: 'custom';\n config: IMailTransport;\n}\n\n/** Mail options with an arbitrary provider name and config; accepted by the type, but the transport provider throws on a name it does not support. */\nexport interface IGenericMailOptions extends IBaseMailOptions {\n provider: string;\n config: Record<string, unknown>;\n}\n\n/** Options passed to the mail component, discriminated by `provider`. */\nexport type TMailOptions =\n | INodemailerMailOptions\n | IAmazonSesMailOptions\n | IMailgunMailOptions\n | ICustomMailOptions\n | IGenericMailOptions;\n\n/** Nodemailer `createTransport` argument: a transport instance, SMTP options or a connection URL. */\nexport type TNodemailerConfig = SMTPTransport | SMTPTransport.Options | string;\n\n/** Mailgun client options (`mailgun.js`) plus the sending `domain`; the transport throws on a missing `username`, `key` or `domain`. */\nexport type TMailgunConfig = {\n username: string;\n key: string;\n domain: string;\n url?: string;\n [option: string]: unknown;\n};\n\n/**\n * The peer module itself, handed over by an application that already holds it. A `bun build\n * --compile` binary carries no `node_modules`, so the runtime lookup these transports fall back to\n * has nothing to resolve against - passing the module through the options is what a compiled\n * application does instead. Typed as the shape each transport actually uses, so a wrong module is\n * a compile error rather than a boot crash.\n */\nexport type TNodemailerModule = {\n createTransport(config: TNodemailerConfig): INodemailerTransporter;\n};\n\n/** The part of a `nodemailer` transporter the transport calls. */\nexport interface INodemailerTransporter {\n sendMail(mailOptions: object): Promise<{ messageId?: string; response?: unknown }>;\n verify(): Promise<unknown>;\n close(): void;\n}\n\n/** The result of one `mailgun.js` send; `id` is the message id. */\nexport interface IMailgunSendResult {\n id?: string;\n}\n\n/** The part of the `mailgun.js` messages client the transport calls. */\nexport interface IMailgunMessagesClient {\n create(domain: string, message: object): Promise<IMailgunSendResult>;\n}\n\n/** The `mailgun.js` class, as a constructor taking the form-data implementation. */\nexport type TMailgunModule = new (formData: typeof FormData) => {\n client(config: object): { messages: IMailgunMessagesClient };\n};\n\n/** Amazon SES client configuration: `region` is required; `credentials` and `endpoint` are optional. */\nexport type TAmazonSesConfig = {\n region: string;\n credentials?: { accessKeyId: string; secretAccessKey: string; sessionToken?: string };\n endpoint?: string;\n};\n\n/** The part of an `@aws-sdk/client-sesv2` client the transport calls; `send` resolves with the command's output. */\nexport interface IAmazonSesClient {\n send(command: object): Promise<unknown>;\n destroy?(): void;\n}\n\n/** The input of a `SendEmailCommand`: the sender, the recipients and the raw MIME body. */\nexport interface IAmazonSesSendEmailInput {\n FromEmailAddress?: string;\n Destination: { ToAddresses: string[]; CcAddresses?: string[]; BccAddresses?: string[] };\n ReplyToAddresses?: string[];\n Content: { Raw: { Data: Uint8Array } };\n}\n\n/** Same story as {@link TNodemailerModule} - a compiled binary hands this over explicitly since there is no `node_modules` to resolve `@aws-sdk/client-sesv2` against. */\nexport type TAmazonSesModule<\n TConfig = TAmazonSesConfig,\n TClient extends IAmazonSesClient = IAmazonSesClient,\n> = {\n SESv2Client: new (config: TConfig) => TClient;\n SendEmailCommand: new (input: IAmazonSesSendEmailInput) => object;\n GetAccountCommand: new (input: object) => object;\n};\n\n/** An Amazon SES client with the command classes the transport sends and verifies with. */\nexport type TAmazonSesClient = Pick<TAmazonSesModule, 'SendEmailCommand' | 'GetAccountCommand'> & {\n client: IAmazonSesClient;\n};\n"]}
|
|
@@ -11,7 +11,7 @@ export interface IMailTemplateEngine {
|
|
|
11
11
|
render(opts: {
|
|
12
12
|
templateData?: string;
|
|
13
13
|
templateName?: string;
|
|
14
|
-
data: Record<string,
|
|
14
|
+
data: Record<string, unknown>;
|
|
15
15
|
requireValidate?: boolean;
|
|
16
16
|
/** @default MailTemplateFormats.HTML */
|
|
17
17
|
format?: TMailTemplateFormat;
|
|
@@ -22,7 +22,7 @@ export interface IMailTemplateEngine {
|
|
|
22
22
|
}): void;
|
|
23
23
|
validateTemplateData(opts: {
|
|
24
24
|
template: string;
|
|
25
|
-
data: Record<string,
|
|
25
|
+
data: Record<string, unknown>;
|
|
26
26
|
}): {
|
|
27
27
|
isValid: boolean;
|
|
28
28
|
missingKeys: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../../../../../src/components/mail/common/types/template.ts"],"names":[],"mappings":"","sourcesContent":["import type { TMailTemplateFormat } from '../constants';\n\n/** A registered mail template: `content` is the body, `subject` and `description` are optional. */\nexport interface ITemplate {\n name: string;\n content?: string;\n subject?: string;\n description?: string;\n}\n\n/** Stores and renders mail templates. Render with a registered `templateName` or inline `templateData`. */\nexport interface IMailTemplateEngine {\n render(opts: {\n templateData?: string;\n templateName?: string;\n data: Record<string,
|
|
1
|
+
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../../../../../src/components/mail/common/types/template.ts"],"names":[],"mappings":"","sourcesContent":["import type { TMailTemplateFormat } from '../constants';\n\n/** A registered mail template: `content` is the body, `subject` and `description` are optional. */\nexport interface ITemplate {\n name: string;\n content?: string;\n subject?: string;\n description?: string;\n}\n\n/** Stores and renders mail templates. Render with a registered `templateName` or inline `templateData`. */\nexport interface IMailTemplateEngine {\n render(opts: {\n templateData?: string;\n templateName?: string;\n data: Record<string, unknown>;\n requireValidate?: boolean;\n /** @default MailTemplateFormats.HTML */\n format?: TMailTemplateFormat;\n }): string;\n registerTemplate(opts: { name: string; content: string }): void;\n validateTemplateData(opts: { template: string; data: Record<string, unknown> }): {\n isValid: boolean;\n missingKeys: string[];\n allKeys: string[];\n };\n getTemplate(name: string): ITemplate | undefined;\n listTemplates(): ITemplate[];\n hasTemplate(name: string): boolean;\n removeTemplate(name: string): boolean;\n}\n"]}
|
|
@@ -42,9 +42,12 @@ export class AmazonSesTransportHelper extends BaseHelper {
|
|
|
42
42
|
},
|
|
43
43
|
});
|
|
44
44
|
const result = await this.client.send(command);
|
|
45
|
+
const messageId = typeof result === 'object' && result !== null
|
|
46
|
+
? Reflect.get(result, 'MessageId')
|
|
47
|
+
: undefined;
|
|
45
48
|
return {
|
|
46
49
|
success: true,
|
|
47
|
-
messageId:
|
|
50
|
+
messageId: typeof messageId === 'string' ? messageId : undefined,
|
|
48
51
|
response: result,
|
|
49
52
|
};
|
|
50
53
|
}
|
|
@@ -64,7 +67,9 @@ export class AmazonSesTransportHelper extends BaseHelper {
|
|
|
64
67
|
logger.info('Verifying Amazon SES account status');
|
|
65
68
|
const command = new this.getAccountCommandConstructor({});
|
|
66
69
|
const result = await this.client.send(command);
|
|
67
|
-
const enabled = result
|
|
70
|
+
const enabled = typeof result === 'object' &&
|
|
71
|
+
result !== null &&
|
|
72
|
+
Reflect.get(result, 'SendingEnabled') === true;
|
|
68
73
|
logger.info('Amazon SES account status: %s', enabled ? 'enabled' : 'disabled');
|
|
69
74
|
return enabled;
|
|
70
75
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"amazon-ses-transporter.helper.js","sourceRoot":"","sources":["../../../../../../src/components/mail/helpers/transporters/amazon-ses-transporter.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AACrD,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QACpD,IAAI,CAAC,4BAA4B,GAAG,iBAAiB,CAAC;IACxD,CAAC;IAED,uFAAuF;IAC7E,WAAW,CAAC,MAAwB;QAC5C,MAAM,SAAS,GACb,IAAI,CAAC,MAAM,IAAI,aAAa,CAAC,QAAQ,CAAmB,EAAE,MAAM,EAAE,uBAAuB,EAAE,CAAC,CAAC;QAE/F,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC,WAAW,CAAC;YACvC,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,QAAQ,EAAE,MAAM,CAAC,QAAQ;SAC1B,CAAC,CAAC;QAEH,OAAO;YACL,MAAM;YACN,gBAAgB,EAAE,SAAS,CAAC,gBAAgB;YAC5C,iBAAiB,EAAE,SAAS,CAAC,iBAAiB;SAC/C,CAAC;IACJ,CAAC;IAED,uFAAuF;IAC/E,cAAc,CAAC,MAAwB;QAC7C,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAClB,OAAO;QACT,CAAC;QAED,MAAM,QAAQ,CAAC;YACb,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,mBAAmB;YACrD,KAAK,EAAE,UAAU,CAAC,qBAAqB;YACvC,OAAO,EAAE,mDAAmD;SAC7D,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { HTTP } from '@venizia/ignis-helpers/common';\nimport { ErrorUtility, ModuleUtility, type AnyType } from '@venizia/ignis-helpers';\nimport { BaseHelper, getError } from '@venizia/ignis-helpers/core';\nimport {\n MailErrors,\n type IMailMessage,\n type IMailSendResult,\n type IMailTransport,\n type TAmazonSesClient,\n type TAmazonSesConfig,\n type TAmazonSesModule,\n} from '../../common';\nimport { MailAddressUtility, MailMimeUtility } from '../../utilities';\nimport { MailAttachmentUtility } from '../../utilities/attachment.utility';\n\n/** Amazon SES transport over the HTTPS API (`@aws-sdk/client-sesv2`), sending each message as a raw MIME body. */\nexport class AmazonSesTransportHelper extends BaseHelper implements IMailTransport {\n private client: AnyType;\n private sendEmailCommandConstructor: AnyType;\n private getAccountCommandConstructor: AnyType;\n private module?: TAmazonSesModule<TAmazonSesConfig>;\n\n constructor(opts: { config: TAmazonSesConfig; module?: TAmazonSesModule }) {\n super({ scope: AmazonSesTransportHelper.name });\n\n this.module = opts.module;\n this.configure(opts.config);\n }\n\n // ------------------------------------------------------------------------------------\n async send(message: IMailMessage): Promise<IMailSendResult> {\n const logger = this.logger.for(this.send.name);\n\n try {\n logger.debug('Sending email with Amazon SES to: %s', message.to);\n\n const rawMessage = await MailMimeUtility.buildRawMessage({ message });\n const command = new this.sendEmailCommandConstructor({\n // `FromEmailAddress` carries the same RFC 5321/5322 mailbox syntax as the raw `From:`\n // header and is subject to the same 7-bit-ASCII requirement - encoding it separately\n // here (instead of passing `message.from` through untouched) is what keeps a non-ASCII\n // display name from reaching the SES API as raw UTF-8 bytes.\n FromEmailAddress: message.from\n ? MailMimeUtility.formatAddressHeader({ value: message.from })\n : message.from,\n Destination: {\n ToAddresses: MailAddressUtility.splitList({ value: message.to }),\n CcAddresses: message.cc ? MailAddressUtility.splitList({ value: message.cc }) : undefined,\n BccAddresses: message.bcc\n ? MailAddressUtility.splitList({ value: message.bcc })\n : undefined,\n },\n // No `ReplyToAddresses` here: `MailMimeUtility.buildRawMessage` already writes a single, RFC\n // 2047-encoded `Reply-To` header into the raw content. Setting both sends the same\n // address through two channels SES treats independently - a client can end up showing a\n // reply-to derived from whichever one SES prioritizes, and the other becomes a silent,\n // unencoded duplicate that skipped the address encoding path entirely.\n Content: {\n Raw: { Data: rawMessage },\n },\n });\n\n const result = await this.client.send(command);\n\n return {\n success: true,\n messageId: result.MessageId,\n response: result,\n };\n } catch (error) {\n logger.error(\n 'Amazon SES send failed | error: %s',\n error instanceof Error ? error.message : error,\n );\n MailAttachmentUtility.release({ attachments: message.attachments });\n\n return {\n success: false,\n error: ErrorUtility.toError({ error }).message,\n };\n }\n }\n\n // ------------------------------------------------------------------------------------\n async verify(): Promise<boolean> {\n const logger = this.logger.for(this.verify.name);\n\n try {\n logger.info('Verifying Amazon SES account status');\n\n const command = new this.getAccountCommandConstructor({});\n const result = await this.client.send(command);\n const enabled = result.SendingEnabled === true;\n\n logger.info('Amazon SES account status: %s', enabled ? 'enabled' : 'disabled');\n\n return enabled;\n } catch (error) {\n logger.error(\n 'Amazon SES verification failed | error: %s',\n error instanceof Error ? error.message : error,\n );\n\n return false;\n }\n }\n\n // ------------------------------------------------------------------------------------\n async close(): Promise<void> {\n this.logger.for(this.close.name).info('Closing Amazon SES client');\n this.client.destroy?.();\n }\n\n // ------------------------------------------------------------------------------------\n configure(config: TAmazonSesConfig): void {\n this.validateConfig(config);\n\n const { client, SendEmailCommand, GetAccountCommand } = this.buildClient(config);\n\n this.client = client;\n this.sendEmailCommandConstructor = SendEmailCommand;\n this.getAccountCommandConstructor = GetAccountCommand;\n }\n\n // ------------------------------------------------------------------------------------\n protected buildClient(config: TAmazonSesConfig): TAmazonSesClient {\n const sesModule =\n this.module ?? ModuleUtility.loadSync<TAmazonSesModule>({ module: '@aws-sdk/client-sesv2' });\n\n const client = new sesModule.SESv2Client({\n region: config.region,\n credentials: config.credentials,\n endpoint: config.endpoint,\n });\n\n return {\n client,\n SendEmailCommand: sesModule.SendEmailCommand,\n GetAccountCommand: sesModule.GetAccountCommand,\n };\n }\n\n // ------------------------------------------------------------------------------------\n private validateConfig(config: TAmazonSesConfig): void {\n if (config.region) {\n return;\n }\n\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n error: MailErrors.INVALID_CONFIGURATION,\n message: 'Invalid Amazon SES Configuration | Missing region',\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"amazon-ses-transporter.helper.js","sourceRoot":"","sources":["../../../../../../src/components/mail/helpers/transporters/amazon-ses-transporter.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AACrD,OAAO,EAAE,YAAY,EAA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B,CAAC;IAED,uFAAuF;IACvF,SAAS,CAAC,MAAwB;QAChC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;QAE5B,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAEjF,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,2BAA2B,GAAG,gBAAgB,CAAC;QACpD,IAAI,CAAC,4BAA4B,GAAG,iBAAiB,CAAC;IACxD,CAAC;IAED,uFAAuF;IAC7E,WAAW,CAAC,MAAwB;QAC5C,MAAM,SAAS,GACb,IAAI,CAAC,MAAM,IAAI,aAAa,CAAC,QAAQ,CAAmB,EAAE,MAAM,EAAE,uBAAuB,EAAE,CAAC,CAAC;QAE/F,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC,WAAW,CAAC;YACvC,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,QAAQ,EAAE,MAAM,CAAC,QAAQ;SAC1B,CAAC,CAAC;QAEH,OAAO;YACL,MAAM;YACN,gBAAgB,EAAE,SAAS,CAAC,gBAAgB;YAC5C,iBAAiB,EAAE,SAAS,CAAC,iBAAiB;SAC/C,CAAC;IACJ,CAAC;IAED,uFAAuF;IAC/E,cAAc,CAAC,MAAwB;QAC7C,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAClB,OAAO;QACT,CAAC;QAED,MAAM,QAAQ,CAAC;YACb,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,mBAAmB;YACrD,KAAK,EAAE,UAAU,CAAC,qBAAqB;YACvC,OAAO,EAAE,mDAAmD;SAC7D,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { HTTP } from '@venizia/ignis-helpers/common';\nimport { ErrorUtility, ModuleUtility } from '@venizia/ignis-helpers';\nimport { BaseHelper, getError } from '@venizia/ignis-helpers/core';\nimport {\n MailErrors,\n type IMailMessage,\n type IMailSendResult,\n type IAmazonSesClient,\n type IMailTransport,\n type TAmazonSesClient,\n type TAmazonSesConfig,\n type TAmazonSesModule,\n} from '../../common';\nimport { MailAddressUtility, MailMimeUtility } from '../../utilities';\nimport { MailAttachmentUtility } from '../../utilities/attachment.utility';\n\n/** Amazon SES transport over the HTTPS API (`@aws-sdk/client-sesv2`), sending each message as a raw MIME body. */\nexport class AmazonSesTransportHelper extends BaseHelper implements IMailTransport {\n private client: IAmazonSesClient;\n private sendEmailCommandConstructor: TAmazonSesClient['SendEmailCommand'];\n private getAccountCommandConstructor: TAmazonSesClient['GetAccountCommand'];\n private module?: TAmazonSesModule;\n\n constructor(opts: { config: TAmazonSesConfig; module?: TAmazonSesModule }) {\n super({ scope: AmazonSesTransportHelper.name });\n\n this.module = opts.module;\n this.configure(opts.config);\n }\n\n // ------------------------------------------------------------------------------------\n async send(message: IMailMessage): Promise<IMailSendResult> {\n const logger = this.logger.for(this.send.name);\n\n try {\n logger.debug('Sending email with Amazon SES to: %s', message.to);\n\n const rawMessage = await MailMimeUtility.buildRawMessage({ message });\n const command = new this.sendEmailCommandConstructor({\n // `FromEmailAddress` carries the same RFC 5321/5322 mailbox syntax as the raw `From:`\n // header and is subject to the same 7-bit-ASCII requirement - encoding it separately\n // here (instead of passing `message.from` through untouched) is what keeps a non-ASCII\n // display name from reaching the SES API as raw UTF-8 bytes.\n FromEmailAddress: message.from\n ? MailMimeUtility.formatAddressHeader({ value: message.from })\n : message.from,\n Destination: {\n ToAddresses: MailAddressUtility.splitList({ value: message.to }),\n CcAddresses: message.cc ? MailAddressUtility.splitList({ value: message.cc }) : undefined,\n BccAddresses: message.bcc\n ? MailAddressUtility.splitList({ value: message.bcc })\n : undefined,\n },\n // No `ReplyToAddresses` here: `MailMimeUtility.buildRawMessage` already writes a single, RFC\n // 2047-encoded `Reply-To` header into the raw content. Setting both sends the same\n // address through two channels SES treats independently - a client can end up showing a\n // reply-to derived from whichever one SES prioritizes, and the other becomes a silent,\n // unencoded duplicate that skipped the address encoding path entirely.\n Content: {\n Raw: { Data: rawMessage },\n },\n });\n\n const result = await this.client.send(command);\n\n const messageId: unknown =\n typeof result === 'object' && result !== null\n ? Reflect.get(result, 'MessageId')\n : undefined;\n\n return {\n success: true,\n messageId: typeof messageId === 'string' ? messageId : undefined,\n response: result,\n };\n } catch (error) {\n logger.error(\n 'Amazon SES send failed | error: %s',\n error instanceof Error ? error.message : error,\n );\n MailAttachmentUtility.release({ attachments: message.attachments });\n\n return {\n success: false,\n error: ErrorUtility.toError({ error }).message,\n };\n }\n }\n\n // ------------------------------------------------------------------------------------\n async verify(): Promise<boolean> {\n const logger = this.logger.for(this.verify.name);\n\n try {\n logger.info('Verifying Amazon SES account status');\n\n const command = new this.getAccountCommandConstructor({});\n const result = await this.client.send(command);\n const enabled =\n typeof result === 'object' &&\n result !== null &&\n Reflect.get(result, 'SendingEnabled') === true;\n\n logger.info('Amazon SES account status: %s', enabled ? 'enabled' : 'disabled');\n\n return enabled;\n } catch (error) {\n logger.error(\n 'Amazon SES verification failed | error: %s',\n error instanceof Error ? error.message : error,\n );\n\n return false;\n }\n }\n\n // ------------------------------------------------------------------------------------\n async close(): Promise<void> {\n this.logger.for(this.close.name).info('Closing Amazon SES client');\n this.client.destroy?.();\n }\n\n // ------------------------------------------------------------------------------------\n configure(config: TAmazonSesConfig): void {\n this.validateConfig(config);\n\n const { client, SendEmailCommand, GetAccountCommand } = this.buildClient(config);\n\n this.client = client;\n this.sendEmailCommandConstructor = SendEmailCommand;\n this.getAccountCommandConstructor = GetAccountCommand;\n }\n\n // ------------------------------------------------------------------------------------\n protected buildClient(config: TAmazonSesConfig): TAmazonSesClient {\n const sesModule =\n this.module ?? ModuleUtility.loadSync<TAmazonSesModule>({ module: '@aws-sdk/client-sesv2' });\n\n const client = new sesModule.SESv2Client({\n region: config.region,\n credentials: config.credentials,\n endpoint: config.endpoint,\n });\n\n return {\n client,\n SendEmailCommand: sesModule.SendEmailCommand,\n GetAccountCommand: sesModule.GetAccountCommand,\n };\n }\n\n // ------------------------------------------------------------------------------------\n private validateConfig(config: TAmazonSesConfig): void {\n if (config.region) {\n return;\n }\n\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n error: MailErrors.INVALID_CONFIGURATION,\n message: 'Invalid Amazon SES Configuration | Missing region',\n });\n }\n}\n"]}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { AnyType } from '@venizia/ignis-helpers/common';
|
|
2
1
|
import { BaseHelper } from '@venizia/ignis-helpers/core';
|
|
3
|
-
import type { IMailMessage, IMailSendResult, IMailTransport, TMailgunConfig, TMailgunModule } from '../../common/index.js';
|
|
2
|
+
import type { IMailgunMessagesClient, IMailMessage, IMailSendResult, IMailTransport, TMailgunConfig, TMailgunModule } from '../../common/index.js';
|
|
4
3
|
/** Mailgun transport (`mailgun.js`). The constructor throws when `username`, `key` or `domain` is missing. */
|
|
5
4
|
export declare class MailgunTransportHelper extends BaseHelper implements IMailTransport {
|
|
6
5
|
private client;
|
|
@@ -14,7 +13,7 @@ export declare class MailgunTransportHelper extends BaseHelper implements IMailT
|
|
|
14
13
|
/** Credentials and domain are checked here, not on the first send; the error never echoes a credential value back. */
|
|
15
14
|
private validateConfig;
|
|
16
15
|
/** Client factory seam - overridden in tests to run the helper without the mailgun.js peer. */
|
|
17
|
-
protected buildClient(config: TMailgunConfig):
|
|
16
|
+
protected buildClient(config: TMailgunConfig): IMailgunMessagesClient;
|
|
18
17
|
send(message: IMailMessage): Promise<IMailSendResult>;
|
|
19
18
|
verify(): Promise<boolean>;
|
|
20
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mailgun-transporter.helper.js","sourceRoot":"","sources":["../../../../../../src/components/mail/helpers/transporters/mailgun-transporter.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"mailgun-transporter.helper.js","sourceRoot":"","sources":["../../../../../../src/components/mail/helpers/transporters/mailgun-transporter.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAUrE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAE3E,8GAA8G;AAC9G,MAAM,OAAO,sBAAuB,SAAQ,UAAU;IAKpD,YAAY,IAAyD;QACnE,KAAK,CAAC,EAAE,KAAK,EAAE,sBAAsB,CAAC,IAAI,EAAE,CAAC,CAAC;QAE9C,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC;IAED,SAAS,CAAC,MAAsB;QAC9B,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;QAE5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IACzC,CAAC;IAED,sHAAsH;IAC9G,cAAc,CAAC,MAAsB;QAC3C,MAAM,WAAW,GAAI,CAAC,UAAU,EAAE,KAAK,EAAE,QAAQ,CAAW,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE;YAC1E,OAAO,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC;QACxB,CAAC,CAAC,CAAC;QAEH,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC7B,OAAO;QACT,CAAC;QAED,IAAI,CAAC,MAAM;aACR,GAAG,CAAC,IAAI,CAAC,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AAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,8CAA8C,CAAC,CAAC;YAEvF,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,qCAAqC,EAAE,KAAK,CAAC,CAAC;YAEtF,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF","sourcesContent":["import { HTTP } from '@venizia/ignis-helpers/common';\nimport { BaseHelper, getError } from '@venizia/ignis-helpers/core';\nimport { ErrorUtility, ModuleUtility } from '@venizia/ignis-helpers';\nimport type {\n IMailAttachment,\n IMailgunMessagesClient,\n IMailMessage,\n IMailSendResult,\n IMailTransport,\n TMailgunConfig,\n TMailgunModule,\n} from '../../common';\nimport { MailErrors } from '../../common';\nimport { MailAttachmentUtility } from '../../utilities/attachment.utility';\n\n/** Mailgun transport (`mailgun.js`). The constructor throws when `username`, `key` or `domain` is missing. */\nexport class MailgunTransportHelper extends BaseHelper implements IMailTransport {\n private client: IMailgunMessagesClient;\n private domain: string;\n private module?: TMailgunModule;\n\n constructor(opts: { config: TMailgunConfig; module?: TMailgunModule }) {\n super({ scope: MailgunTransportHelper.name });\n\n this.module = opts.module;\n this.configure(opts.config);\n }\n\n configure(config: TMailgunConfig) {\n this.validateConfig(config);\n\n this.domain = config.domain;\n this.client = this.buildClient(config);\n }\n\n /** Credentials and domain are checked here, not on the first send; the error never echoes a credential value back. */\n private validateConfig(config: TMailgunConfig): void {\n const missingKeys = (['username', 'key', 'domain'] as const).filter((key) => {\n return !config?.[key];\n });\n\n if (missingKeys.length === 0) {\n return;\n }\n\n this.logger\n .for(this.configure.name)\n .error('Invalid Mailgun configuration | Missing keys: %s', missingKeys.join(', '));\n\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n error: MailErrors.INVALID_CONFIGURATION,\n message: `Invalid Mailgun configuration | Missing required keys: ${missingKeys.join(', ')}`,\n });\n }\n\n /** Client factory seam - overridden in tests to run the helper without the mailgun.js peer. */\n protected buildClient(config: TMailgunConfig): IMailgunMessagesClient {\n const Mailgun = this.module ?? ModuleUtility.loadSync<TMailgunModule>({ module: 'mailgun.js' });\n const mailgun = new Mailgun(FormData);\n const client = mailgun.client(config);\n\n return client.messages;\n }\n\n async send(message: IMailMessage): Promise<IMailSendResult> {\n try {\n const mailgunMessage: Record<string, unknown> = {\n from: message.from,\n to: Array.isArray(message.to) ? message.to : [message.to],\n subject: message.subject,\n text: message.text,\n html: message.html,\n cc: message.cc,\n bcc: message.bcc,\n };\n\n if (message.replyTo) {\n mailgunMessage['h:Reply-To'] = message.replyTo;\n }\n\n if (message.headers) {\n Object.entries(message.headers).forEach(([key, value]) => {\n mailgunMessage[`h:${key}`] = value;\n });\n }\n\n if (message.attachments && message.attachments.length > 0) {\n // No root: MailService resolved paths already; one that reaches here is refused, not read.\n const attachments = await MailAttachmentUtility.resolve({\n attachments: message.attachments,\n });\n\n // Mailgun reads `inline` parts by file name: `cid:<name>` in the HTML, so the cid is the name.\n const toPart = (attachment: IMailAttachment, filename?: string) => ({\n filename: filename ?? attachment.filename,\n data: attachment.content,\n contentType: attachment.contentType,\n });\n\n mailgunMessage.attachment = attachments\n .filter((attachment) => !attachment.cid)\n .map((attachment) => toPart(attachment));\n mailgunMessage.inline = attachments\n .filter((attachment) => attachment.cid)\n .map((attachment) => toPart(attachment, attachment.cid));\n }\n\n this.logger.for(this.send.name).debug('Sending email with Mailgun to: %s', mailgunMessage.to);\n const result = await this.client.create(this.domain, mailgunMessage);\n\n return {\n success: true,\n messageId: result.id,\n response: result,\n };\n } catch (error) {\n this.logger.for(this.send.name).error('Mailgun send failed: %s', error);\n MailAttachmentUtility.release({ attachments: message.attachments });\n\n return {\n success: false,\n error: ErrorUtility.toError({ error }).message,\n };\n }\n }\n\n async verify(): Promise<boolean> {\n try {\n this.logger.for(this.verify.name).info('Verifying Mailgun API connection');\n // Mailgun has no verify endpoint - a test-mode send is the lightweight credential check.\n await this.client.create(this.domain, {\n from: 'verify@' + this.domain,\n to: ['verify@' + this.domain],\n subject: 'Verification Test',\n text: 'This is a verification test',\n 'o:testmode': 'yes', // Use test mode to avoid actually sending\n });\n\n this.logger.for(this.verify.name).info('Mailgun API connection verified successfully');\n\n return true;\n } catch (error) {\n this.logger.for(this.verify.name).error('Mailgun API verification failed: %s', error);\n\n return false;\n }\n }\n}\n"]}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { AnyType } from '@venizia/ignis-helpers/common';
|
|
2
1
|
import { BaseHelper } from '@venizia/ignis-helpers/core';
|
|
3
|
-
import type { IMailMessage, IMailSendResult, IMailTransport, TNodemailerConfig, TNodemailerModule } from '../../common/index.js';
|
|
2
|
+
import type { IMailMessage, IMailSendResult, IMailTransport, INodemailerTransporter, TNodemailerConfig, TNodemailerModule } from '../../common/index.js';
|
|
4
3
|
/** SMTP transport on `nodemailer`, with its file and URL access switched off. */
|
|
5
4
|
export declare class NodemailerTransportHelper extends BaseHelper implements IMailTransport {
|
|
6
5
|
private transporter;
|
|
@@ -11,7 +10,7 @@ export declare class NodemailerTransportHelper extends BaseHelper implements IMa
|
|
|
11
10
|
});
|
|
12
11
|
configure(config: TNodemailerConfig): void;
|
|
13
12
|
/** Client factory seam - overridden in tests to run the helper without a real SMTP client. */
|
|
14
|
-
protected buildTransporter(config: TNodemailerConfig):
|
|
13
|
+
protected buildTransporter(config: TNodemailerConfig): INodemailerTransporter;
|
|
15
14
|
send(message: IMailMessage): Promise<IMailSendResult>;
|
|
16
15
|
verify(): Promise<boolean>;
|
|
17
16
|
close(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodemail-transporter.helper.js","sourceRoot":"","sources":["../../../../../../src/components/mail/helpers/transporters/nodemail-transporter.helper.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"nodemail-transporter.helper.js","sourceR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AAO;gBACL,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,YAAY,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,OAAO;aAC/C,CAAC;QACJ,CAAC;IACH,CAAC;IAED,KAAK,CAAC,MAAM;QACV,IAAI,CAAC;YACH,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;YACpE,MAAM,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC;YAChC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAC;YAEhF,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,8BAA8B,EAAE,KAAK,CAAC,CAAC;YAE/E,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED,KAAK,CAAC,KAAK;QACT,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;QACtE,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;IAC3B,CAAC;CACF","sourcesContent":["import { BaseHelper } from '@venizia/ignis-helpers/core';\nimport { ErrorUtility, ModuleUtility } from '@venizia/ignis-helpers';\nimport type {\n IMailMessage,\n IMailSendResult,\n IMailTransport,\n INodemailerTransporter,\n TNodemailerConfig,\n TNodemailerModule,\n} from '../../common';\nimport { MailAttachmentUtility } from '../../utilities/attachment.utility';\nimport { MailBodyUtility } from '../../utilities/body.utility';\n\n/** SMTP transport on `nodemailer`, with its file and URL access switched off. */\nexport class NodemailerTransportHelper extends BaseHelper implements IMailTransport {\n private transporter: INodemailerTransporter;\n private module?: TNodemailerModule;\n\n constructor(opts: { config: TNodemailerConfig; module?: TNodemailerModule }) {\n super({ scope: NodemailerTransportHelper.name });\n\n this.module = opts.module;\n this.configure(opts.config);\n }\n\n configure(config: TNodemailerConfig) {\n this.transporter = this.buildTransporter(config);\n }\n\n /** Client factory seam - overridden in tests to run the helper without a real SMTP client. */\n protected buildTransporter(config: TNodemailerConfig): INodemailerTransporter {\n const nodemailer =\n this.module ?? ModuleUtility.loadSync<TNodemailerModule>({ module: 'nodemailer' });\n\n return nodemailer.createTransport(config);\n }\n\n async send(message: IMailMessage): Promise<IMailSendResult> {\n try {\n MailBodyUtility.assertIsText({ message });\n\n // No root: MailService resolved paths already; one that reaches here is refused, not read.\n let attachments: Awaited<ReturnType<typeof MailAttachmentUtility.resolve>> | undefined;\n\n if (message.attachments) {\n const resolved = await MailAttachmentUtility.resolve({ attachments: message.attachments });\n attachments = resolved;\n }\n\n const mailOptions = {\n from: message.from,\n to: Array.isArray(message.to) ? message.to.join(', ') : message.to,\n cc: message.cc,\n bcc: message.bcc,\n replyTo: message.replyTo,\n subject: message.subject,\n text: message.text,\n html: message.html,\n attachments,\n headers: message.headers,\n // Nodemailer's own switches: no field it is handed can make it open a file or fetch a URL.\n disableFileAccess: true,\n disableUrlAccess: true,\n };\n\n this.logger.for(this.send.name).debug('Sending email with nodemailer to: %s', mailOptions.to);\n const info = await this.transporter.sendMail(mailOptions);\n\n return {\n success: true,\n messageId: info.messageId,\n response: info.response,\n };\n } catch (error) {\n this.logger.for(this.send.name).error('Nodemailer send failed: %s', error);\n MailAttachmentUtility.release({ attachments: message.attachments });\n\n return {\n success: false,\n error: ErrorUtility.toError({ error }).message,\n };\n }\n }\n\n async verify(): Promise<boolean> {\n try {\n this.logger.for(this.verify.name).info('Verifying SMTP connection');\n await this.transporter.verify();\n this.logger.for(this.verify.name).info('SMTP connection verified successfully');\n\n return true;\n } catch (error) {\n this.logger.for(this.verify.name).error('SMTP verification failed: %s', error);\n\n return false;\n }\n }\n\n async close(): Promise<void> {\n this.logger.for(this.close.name).info('Closing nodemailer transport');\n this.transporter.close();\n }\n}\n"]}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { BaseService } from '@venizia/ignis-kernel';
|
|
2
2
|
import type { IMailMessage, IMailSendResult, IMailService, IMailTemplateEngine, IMailTransport, TMailOptions } from '../common/index.js';
|
|
3
|
-
import { type AnyType } from '@venizia/ignis-helpers/common';
|
|
4
3
|
/** Sends mail through the bound transport. `send` validates the message, applies the attachment policy and defaults `from`; failures are thrown as application errors with a mail message code, except `sendBatch`, which reports each failure in its result. */
|
|
5
4
|
export declare class MailService extends BaseService implements IMailService {
|
|
6
5
|
protected options: TMailOptions;
|
|
@@ -13,7 +12,7 @@ export declare class MailService extends BaseService implements IMailService {
|
|
|
13
12
|
}): Promise<IMailSendResult[]>;
|
|
14
13
|
sendTemplate(opts: {
|
|
15
14
|
templateName: string;
|
|
16
|
-
data: Record<string,
|
|
15
|
+
data: Record<string, unknown>;
|
|
17
16
|
recipients: string | string[];
|
|
18
17
|
options?: Partial<IMailMessage>;
|
|
19
18
|
}): Promise<IMailSendResult>;
|