@miguelmorales13/nestkit 0.22.0 → 0.25.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 +182 -5
- package/dist/email/adapters/zeptomail.email.d.ts +27 -0
- package/dist/email/email.module.d.ts +2 -1
- package/dist/email/email.options.d.ts +10 -1
- package/dist/email/index.cjs +90 -10
- package/dist/email/index.d.ts +2 -1
- package/dist/email/index.js +89 -9
- package/dist/index.cjs +5 -5
- package/dist/index.js +6 -6
- package/dist/payments/adapters/mercadopago-connect.d.ts +70 -0
- package/dist/payments/adapters/mercadopago.terminal.d.ts +57 -0
- package/dist/payments/index.cjs +153 -1
- package/dist/payments/index.d.ts +3 -1
- package/dist/payments/index.js +152 -0
- package/dist/payments/payments.port.d.ts +24 -0
- package/dist/push/channels/fcm.channel.d.ts +73 -0
- package/dist/push/channels/webpush.channel.d.ts +62 -0
- package/dist/push/index.cjs +449 -0
- package/dist/push/index.d.ts +9 -0
- package/dist/push/index.js +449 -0
- package/dist/push/push.module.d.ts +40 -0
- package/dist/push/push.options.d.ts +40 -0
- package/dist/push/push.port.d.ts +148 -0
- package/dist/push/push.service.d.ts +31 -0
- package/dist/security/index.cjs +35 -0
- package/dist/security/index.d.ts +2 -0
- package/dist/security/index.js +35 -0
- package/dist/security/signed-state.d.ts +42 -0
- package/package.json +20 -4
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ está listo, la implementación no.
|
|
|
13
13
|
con Google, Apple, Facebook, TikTok, GitHub, Microsoft, Discord, LinkedIn, enlace mágico, passkeys y verificación en dos pasos (`auth/oauth`) o con email y contraseña (`auth`), Stripe, cobro presencial en
|
|
14
14
|
terminal Mercado Pago Point o Clip (`payments`), facturación CFDI 4.0 (`invoicing`), Telegram,
|
|
15
15
|
WhatsApp, Instagram y Facebook Pages (`meta`), subida de archivos (`storage`), correo transaccional con Resend,
|
|
16
|
-
Brevo o SMTP tras un puerto (`email`) y lectura de analítica (`umami`).
|
|
16
|
+
Brevo o SMTP tras un puerto (`email`), push a apps y navegadores con botones (`push`) y lectura de analítica (`umami`).
|
|
17
17
|
|
|
18
18
|
## ¿Para qué proyectos es esto?
|
|
19
19
|
|
|
@@ -1037,6 +1037,78 @@ desaparece sin ruido es un cliente preguntando dónde quedó su dinero.
|
|
|
1037
1037
|
secreto del panel, y el id va **en minúsculas** (lo dice su propia documentación). Los ids reales
|
|
1038
1038
|
son `ORD01J6…`, así que hashearlo como viene rechaza todas las notificaciones legítimas — y el
|
|
1039
1039
|
síntoma parece un ataque, no un bug.
|
|
1040
|
+
- **Solo Point Smart 1 y Point Smart 2 pasan a modo PDV por API.** Confirmado con soporte de
|
|
1041
|
+
Mercado Pago, no es una limitación temporal: un Point Air trae hardware oficial de Mercado Pago,
|
|
1042
|
+
aparece en `listTerminals()` como cualquier otra, hasta puede traer su propio `storeId`/`posId` —
|
|
1043
|
+
y aun así se queda en `standalone` para siempre, porque ese modelo simplemente no tiene modo PDV.
|
|
1044
|
+
`setOperatingMode(ids, 'PDV')` rechaza un id no integrable **antes** de llamar a la API, con un
|
|
1045
|
+
mensaje que nombra el modelo — la respuesta real de Mercado Pago es un `400` seco,
|
|
1046
|
+
`"'$.terminals[0].id' - does not match pattern"`, que no menciona el modelo y parece un id mal
|
|
1047
|
+
formado. `listTerminals()` también marca cada terminal con `integrable`, para filtrar la lista
|
|
1048
|
+
ANTES de que alguien la elija.
|
|
1049
|
+
- **La terminal tiene que pertenecer a una jerarquía Sucursal → Caja → Terminal**, o la Orders API
|
|
1050
|
+
rechaza cualquier cobro con `PA_UNAUTHORIZED_RESULT_FROM_POLICIES` — un 403 que no menciona
|
|
1051
|
+
Sucursales por ningún lado. `createStore()` y `createPos()` arman esa jerarquía. **Antes de
|
|
1052
|
+
llamarlos, revisá `listTerminals()`**: una terminal emparejada alguna vez desde la app de
|
|
1053
|
+
Mercado Pago (celular) ya puede traer su propio `storeId`/`posId` — crear una Sucursal nueva en
|
|
1054
|
+
ese caso no falla, pero le deja al comercio una Sucursal de más en su panel que nadie usa.
|
|
1055
|
+
|
|
1056
|
+
```ts
|
|
1057
|
+
const [terminal] = await pagos.listTerminals();
|
|
1058
|
+
if (!terminal.integrable) throw new Error('Esta terminal no puede operar por API — es un Point Air.');
|
|
1059
|
+
|
|
1060
|
+
let { storeId, posId } = terminal;
|
|
1061
|
+
if (!storeId || !posId) {
|
|
1062
|
+
storeId = await pagos.createStore({
|
|
1063
|
+
userId: sellerMpUserId, // el user_id de la CUENTA CONECTADA, no el de tu aplicación
|
|
1064
|
+
name: 'Sucursal Centro',
|
|
1065
|
+
location: { streetNumber: 'S/N', streetName: 'Centro', cityName: 'CDMX', stateName: 'CDMX', latitude: 19.4326, longitude: -99.1332 },
|
|
1066
|
+
businessHours: { monday: [{ open: '00:00', close: '23:59' }], /* ...los 7 días */ },
|
|
1067
|
+
});
|
|
1068
|
+
posId = await pagos.createPos({ storeId, name: 'Caja 1' });
|
|
1069
|
+
}
|
|
1070
|
+
await pagos.setOperatingMode([terminal.id], 'PDV'); // y reiniciar el aparato
|
|
1071
|
+
```
|
|
1072
|
+
|
|
1073
|
+
#### Mercado Pago marketplace: conectar la cuenta de cada vendedor por OAuth
|
|
1074
|
+
|
|
1075
|
+
`MercadoPagoTerminalPayments` asume un `MERCADOPAGO_ACCESS_TOKEN` fijo — de una sola cuenta. Un
|
|
1076
|
+
marketplace (vos operás la aplicación, cada vendedor conecta la SUYA) necesita, además, `MercadoPagoConnect`:
|
|
1077
|
+
|
|
1078
|
+
```ts
|
|
1079
|
+
import { MercadoPagoConnect } from '@miguelmorales13/nestkit/payments';
|
|
1080
|
+
import { signState, readState } from '@miguelmorales13/nestkit/security';
|
|
1081
|
+
|
|
1082
|
+
const connect = new MercadoPagoConnect({
|
|
1083
|
+
clientId: process.env.MERCADOPAGO_CLIENT_ID!,
|
|
1084
|
+
clientSecret: process.env.MERCADOPAGO_CLIENT_SECRET!,
|
|
1085
|
+
redirectUri: 'https://api.tuapp.com/mercadopago/callback',
|
|
1086
|
+
});
|
|
1087
|
+
|
|
1088
|
+
// 1. Arrancar la conexión — `state` viaja firmado, sin sesión ni cookie:
|
|
1089
|
+
const state = signState({ tenantId, sellerId }, { secret: JWT_SECRET, ttlMs: 20 * 60_000 });
|
|
1090
|
+
const url = connect.authorizationUrl(state);
|
|
1091
|
+
|
|
1092
|
+
// 2. En el callback:
|
|
1093
|
+
const datos = readState(query.state, { secret: JWT_SECRET, ttlMs: 20 * 60_000 });
|
|
1094
|
+
if (!datos) throw new Error('state inválido o caducado');
|
|
1095
|
+
const tokens = await connect.exchangeCode(query.code);
|
|
1096
|
+
await guardar(datos.tenantId, datos.sellerId, tokens); // cifrados — son las llaves del vendedor
|
|
1097
|
+
|
|
1098
|
+
// 3. Para cobrar, con el token de ESE vendedor (nunca uno fijo):
|
|
1099
|
+
const pagosDelVendedor = new MercadoPagoTerminalPayments({ accessToken: tokens.accessToken });
|
|
1100
|
+
```
|
|
1101
|
+
|
|
1102
|
+
`scope=offline_access` va siempre (es el default): sin él, Mercado Pago entrega un access token de
|
|
1103
|
+
un solo uso, sin `refresh_token`, y la conexión deja de funcionar sola el día que expira. El
|
|
1104
|
+
`refresh_token` **rota en cada renovación** (`connect.refresh(tokens.refreshToken)`) — hay que
|
|
1105
|
+
persistir el resultado completo, no solo el access token nuevo.
|
|
1106
|
+
|
|
1107
|
+
`signState`/`readState` (`@miguelmorales13/nestkit/security`) son genéricos, no específicos de
|
|
1108
|
+
Mercado Pago: sirven para cualquier flujo de "conectar una cuenta de terceros por OAuth" que no
|
|
1109
|
+
quiera depender de una cookie — que en un consent screen con pasos extra (2FA, verificación por
|
|
1110
|
+
teléfono) puede desaparecer antes de que el navegador vuelva. El payload firmado es libre
|
|
1111
|
+
(`Record<string, string>`); qué va adentro lo decide quien conecta, no la librería.
|
|
1040
1112
|
|
|
1041
1113
|
**Probar sin terminal.** Con credenciales de prueba existe un equipo virtual, serie `SBX0000001`
|
|
1042
1114
|
(`NEWLAND_N950__SBX0000001`), y un endpoint que le impone el estado final a una orden — el webhook
|
|
@@ -1637,10 +1709,105 @@ directo a la biometría sin hoja de selección). Al registrar:
|
|
|
1637
1709
|
`startRegistration({ optionsJSON: options })` y `POST /auth/passkeys/register`. Un
|
|
1638
1710
|
`NotAllowedError` es la persona cancelando, no un fallo.
|
|
1639
1711
|
|
|
1712
|
+
### `push` — notificaciones push con botones y redirección, a apps (FCM) y navegadores (Web Push)
|
|
1713
|
+
|
|
1714
|
+
Un puerto y dos canales a la vez: un usuario tiene un iPhone (Firebase Cloud Messaging) **y** un
|
|
1715
|
+
navegador (Web Push con VAPID), y `send()` manda a cada dispositivo por el suyo. FCM va por su API
|
|
1716
|
+
HTTP v1 con `fetch` —sin `firebase-admin`, que arrastra medio Google Cloud para lo que es un POST
|
|
1717
|
+
con un bearer—; el token de acceso se obtiene firmando un JWT con la cuenta de servicio.
|
|
1718
|
+
|
|
1719
|
+
```ts
|
|
1720
|
+
import { PushModule, PUSH, PUSH_DEVICE_STORE, type PushPort } from '@miguelmorales13/nestkit/push';
|
|
1721
|
+
|
|
1722
|
+
@Module({
|
|
1723
|
+
imports: [
|
|
1724
|
+
PushModule.forRoot({
|
|
1725
|
+
// fcm: lee FIREBASE_SERVICE_ACCOUNT (el JSON) o FIREBASE_SERVICE_ACCOUNT_FILE / GOOGLE_APPLICATION_CREDENTIALS (ruta)
|
|
1726
|
+
// webPush: lee VAPID_SUBJECT, VAPID_PUBLIC_KEY, VAPID_PRIVATE_KEY
|
|
1727
|
+
imports: [MiStoreModule],
|
|
1728
|
+
deviceStore: { provide: PUSH_DEVICE_STORE, useExisting: MiStore }, // opcional: habilita sendToUser + poda
|
|
1729
|
+
}),
|
|
1730
|
+
],
|
|
1731
|
+
})
|
|
1732
|
+
export class AppModule {}
|
|
1733
|
+
```
|
|
1734
|
+
|
|
1735
|
+
```ts
|
|
1736
|
+
@Injectable()
|
|
1737
|
+
export class RecordatoriosService {
|
|
1738
|
+
constructor(@Inject(PUSH) private readonly push: PushPort) {}
|
|
1739
|
+
|
|
1740
|
+
async pesoDiario(userId: string) {
|
|
1741
|
+
await this.push.sendToUser(userId, {
|
|
1742
|
+
title: t('push.peso.titulo'), // I18nMessage o string; se traduce con { lang }
|
|
1743
|
+
body: t('push.peso.cuerpo'),
|
|
1744
|
+
link: 'https://app.miapp.mx/peso', // a dónde va un toque en la notificación
|
|
1745
|
+
actions: [
|
|
1746
|
+
{ id: 'registrar', title: 'Registrar', link: 'https://app.miapp.mx/peso/nuevo' },
|
|
1747
|
+
{ id: 'luego', title: 'Más tarde' },
|
|
1748
|
+
],
|
|
1749
|
+
category: 'PESO', // iOS: la UNNotificationCategory que registró la app
|
|
1750
|
+
androidChannelId: 'recordatorios',
|
|
1751
|
+
collapseKey: 'peso-diario', // reemplaza la de ayer en vez de apilarla
|
|
1752
|
+
data: { screen: 'peso' },
|
|
1753
|
+
}, { lang: user.locale });
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1756
|
+
```
|
|
1757
|
+
|
|
1758
|
+
`send(devices, message)` devuelve `{ sent, failed, ids }` y **nunca lanza por un dispositivo**: cada
|
|
1759
|
+
fallo trae `code` y `stale`. `stale: true` es la plataforma diciendo que ese dispositivo ya no existe
|
|
1760
|
+
(app desinstalada, token rotado, suscripción caducada — `UNREGISTERED`/`SENDER_ID_MISMATCH` en FCM,
|
|
1761
|
+
`404`/`410` en Web Push) y **solo eso**: un `INVALID_ARGUMENT` no borra nada, porque puede ser el
|
|
1762
|
+
payload y borrar por eso pierde un dispositivo vivo. `sendToUser` manda a todos los dispositivos que
|
|
1763
|
+
`PushDeviceStorePort.listByUser` devuelva y borra los `stale` con `remove(id)`. Registrar dispositivos
|
|
1764
|
+
(upsert por token, plataforma, agente) sigue siendo del proyecto.
|
|
1765
|
+
|
|
1766
|
+
**Sin credenciales, la API arranca igual** — un aviso en el log, `channels()` en `false` y cada envío
|
|
1767
|
+
falla con `channel_not_configured`. Es distinto de `email` a propósito: la cuenta de servicio de
|
|
1768
|
+
Firebase suele ser un paso manual post-deploy, y un canal de push caído no puede tumbar toda la API.
|
|
1769
|
+
`whenUnconfigured: 'throw'` devuelve la regla estricta. Un canal **pedido** y roto (JSON inválido,
|
|
1770
|
+
VAPID incompleto) sí lanza.
|
|
1771
|
+
|
|
1772
|
+
**Botones y redirección, con la verdad de cada plataforma.** Un mismo mensaje sale en cuatro
|
|
1773
|
+
dialectos, y lo que una plataforma no puede mostrar viaja en `data` (`link`, `actions`, `category`,
|
|
1774
|
+
como strings) para que la app lo haga:
|
|
1775
|
+
|
|
1776
|
+
| | Toque en la notificación | Botones (`actions`) |
|
|
1777
|
+
|---|---|---|
|
|
1778
|
+
| **Web** (FCM o Web Push) | `link` nativo (`fcm_options.link`, solo `https`) | nativos; el *service worker* enruta cada uno |
|
|
1779
|
+
| **iOS** | la app lee `data.link` en `onMessageOpenedApp` | por `category`: la app registra una `UNNotificationCategory` con esos botones y el mismo id |
|
|
1780
|
+
| **Android** | la app lee `data.link` | **no existen** en la notificación de sistema. Con `dataOnly: true` el mensaje va sin bloque `notification`, la app lo recibe en segundo plano y la pinta ella (p. ej. `flutter_local_notifications`) con botones |
|
|
1781
|
+
|
|
1782
|
+
`dataOnly` en iOS se manda como push de fondo (`content-available`, prioridad 5, `apns-push-type:
|
|
1783
|
+
background`, que APNs exige o lo descarta). Una imagen en iOS necesita una Notification Service
|
|
1784
|
+
Extension; el mensaje ya lleva `mutable-content: 1` para que pueda descargarla.
|
|
1785
|
+
|
|
1786
|
+
El *service worker* para Web Push, que es donde se decide qué botón abre qué:
|
|
1787
|
+
|
|
1788
|
+
```js
|
|
1789
|
+
self.addEventListener('push', (e) => {
|
|
1790
|
+
const m = e.data.json(); // { title, body, icon, image, badge, tag, link, actions: [{ action, title, icon, link }], data }
|
|
1791
|
+
e.waitUntil(self.registration.showNotification(m.title, { body: m.body, icon: m.icon, image: m.image, tag: m.tag, actions: m.actions, data: m }));
|
|
1792
|
+
});
|
|
1793
|
+
self.addEventListener('notificationclick', (e) => {
|
|
1794
|
+
e.notification.close();
|
|
1795
|
+
const m = e.notification.data;
|
|
1796
|
+
const url = (m.actions?.find((a) => a.action === e.action) ?? {}).link ?? m.link;
|
|
1797
|
+
if (url) e.waitUntil(clients.openWindow(url));
|
|
1798
|
+
});
|
|
1799
|
+
```
|
|
1800
|
+
|
|
1801
|
+
Temas de FCM: `sendToTopic('noticias', message)`, `subscribeToTopic(tokens, 'noticias')`,
|
|
1802
|
+
`unsubscribeFromTopic`. `priority` (`high` despierta el dispositivo), `ttlSeconds`, `badge`, `sound` e
|
|
1803
|
+
`imageUrl` se traducen a lo que cada plataforma llama igual. `web-push` se carga perezosamente y solo
|
|
1804
|
+
si hay canal web; para Web Push el proyecto expone la `VAPID_PUBLIC_KEY` al navegador y guarda la
|
|
1805
|
+
suscripción que `PushManager.subscribe()` devuelve.
|
|
1806
|
+
|
|
1640
1807
|
### `email` — correo transaccional con el proveedor como configuración
|
|
1641
1808
|
|
|
1642
1809
|
Un puerto, `EmailPort`, y el proveedor detrás se elige en una línea: **Resend**, **Brevo** (antes
|
|
1643
|
-
Sendinblue) o **cualquier servidor SMTP** vía Nodemailer. Mismo patrón que `storage`: nada en la
|
|
1810
|
+
Sendinblue), **ZeptoMail** (Zoho) o **cualquier servidor SMTP** vía Nodemailer. Mismo patrón que `storage`: nada en la
|
|
1644
1811
|
app depende de un cliente concreto, así que cambiar de proveedor no toca ninguna llamada.
|
|
1645
1812
|
|
|
1646
1813
|
```ts
|
|
@@ -1650,6 +1817,7 @@ import { EmailModule } from '@miguelmorales13/nestkit/email';
|
|
|
1650
1817
|
imports: [
|
|
1651
1818
|
EmailModule.forRoot({ provider: 'brevo' }), // lee BREVO_API_KEY y EMAIL_FROM
|
|
1652
1819
|
// EmailModule.forRoot({ provider: 'resend', from: 'Mi App <hola@miapp.mx>' }),
|
|
1820
|
+
// EmailModule.forRoot({ provider: 'zeptomail' }), // lee ZEPTOMAIL_API_KEY y EMAIL_FROM
|
|
1653
1821
|
// EmailModule.forRoot({ provider: 'smtp', smtp: { host, port: 587, user, password } }),
|
|
1654
1822
|
// EmailModule.forRoot({ provider: 'memory' }), // pruebas y desarrollo: nadie recibe nada
|
|
1655
1823
|
],
|
|
@@ -1679,7 +1847,7 @@ export class NotificationsService {
|
|
|
1679
1847
|
|
|
1680
1848
|
Lo que no pases en código sale del entorno: `EMAIL_PROVIDER`, `EMAIL_FROM`, `EMAIL_REPLY_TO`;
|
|
1681
1849
|
`RESEND_API_KEY`; `SMTP_HOST`, `SMTP_PORT`, `SMTP_SECURE`, `SMTP_USER`, `SMTP_PASSWORD`;
|
|
1682
|
-
`BREVO_API_KEY`. **No hay proveedor por defecto**: sin `provider` ni `EMAIL_PROVIDER` el módulo
|
|
1850
|
+
`BREVO_API_KEY`; `ZEPTOMAIL_API_KEY`, `ZEPTOMAIL_BASE_URL`. **No hay proveedor por defecto**: sin `provider` ni `EMAIL_PROVIDER` el módulo
|
|
1683
1851
|
falla al cablear, no en el primer envío. Lo mismo si el proveedor elegido no tiene credenciales.
|
|
1684
1852
|
|
|
1685
1853
|
El mensaje es el mismo para los tres —`from`, `to`/`cc`/`bcc`, `replyTo`, `subject`, `text`/`html`,
|
|
@@ -1695,6 +1863,13 @@ de su lista** (pdf, docx, xlsx, csv, png, jpg, zip… — un `.exe` o un `.json`
|
|
|
1695
1863
|
SMTP (`smtp-relay.brevo.com:587`, login + clave SMTP) también funciona con `provider: 'smtp'`, por
|
|
1696
1864
|
si se prefiere.
|
|
1697
1865
|
|
|
1866
|
+
**ZeptoMail** (el servicio transaccional de Zoho, centavos por correo) también va por REST con
|
|
1867
|
+
`fetch`: un `POST /email` con el token del Mail Agent en `Authorization: Zoho-enczapikey <token>`.
|
|
1868
|
+
Cosas a saber: el dominio del `from` debe estar verificado en ZeptoMail (SPF + DKIM) o responde 4xx;
|
|
1869
|
+
el token vive en un centro de datos, así que una cuenta `.eu`, `.in` o `.com.au` debe poner su host
|
|
1870
|
+
en `ZEPTOMAIL_BASE_URL` (`https://api.zeptomail.eu/v1.1`) o todo envío da 401; no tiene campo de
|
|
1871
|
+
etiquetas, por lo que los `tags` salen como cabeceras `X-Tag-<nombre>` como en SMTP.
|
|
1872
|
+
|
|
1698
1873
|
Los SDKs de Resend y Nodemailer se cargan **perezosamente en el primer envío**: una app en Brevo no
|
|
1699
1874
|
instala ninguno de los dos. `memory` guarda cada mensaje en `MemoryEmail.sent` — el buzón de salida
|
|
1700
1875
|
de las pruebas.
|
|
@@ -1885,13 +2060,15 @@ trae los datos.
|
|
|
1885
2060
|
| `@miguelmorales13/nestkit/auth/oauth` | `OAuthAuthModule`, `OAuthAuthService`, `createOAuthController`, `googleProvider`, `appleProvider`, `facebookProvider`, `tiktokProvider`, `githubProvider`, `microsoftProvider`, `discordProvider`, `linkedinProvider`, `OAuthStorePort`, `RefreshTokenStorePort`, `MagicLinkStorePort`, `MagicLinkSenderPort`, `TwoFactorStorePort`, `PasskeyStorePort`, `WebAuthnPort`, stores en memoria, `totp`/`verifyTotp` |
|
|
1886
2061
|
| `@miguelmorales13/nestkit/umami` | `UmamiModule`, `UmamiService` — lectura de la API de analítica |
|
|
1887
2062
|
| `@miguelmorales13/nestkit/invoicing` | `InvoicingModule`, `INVOICING`, `InvoicingPort`, adaptadores `FacturapiInvoicing`/`FacturamaInvoicing` — CFDI 4.0 |
|
|
1888
|
-
| `@miguelmorales13/nestkit/payments` | `PaymentsModule`, `TERMINAL_PAYMENTS`, `TerminalPaymentsPort`, adaptadores `MercadoPagoTerminalPayments`/`ClipTerminalPayments`, `createTerminalPaymentsWebhookController` |
|
|
2063
|
+
| `@miguelmorales13/nestkit/payments` | `PaymentsModule`, `TERMINAL_PAYMENTS`, `TerminalPaymentsPort`, adaptadores `MercadoPagoTerminalPayments`/`ClipTerminalPayments`, `MercadoPagoConnect` (OAuth marketplace), `isIntegrableTerminalModel`, `createTerminalPaymentsWebhookController` |
|
|
1889
2064
|
| `@miguelmorales13/nestkit/storage` | `StorageModule`, `STORAGE`, `StoragePort`, adaptadores `LocalStorage`/`S3Storage`/`BunnyStorage` |
|
|
1890
|
-
| `@miguelmorales13/nestkit/
|
|
2065
|
+
| `@miguelmorales13/nestkit/push` | `PushModule`, `PUSH`, `PushPort`, `PUSH_DEVICE_STORE`, `PushDeviceStorePort`, canales `FcmChannel`/`WebPushChannel`, `toFcmMessage` |
|
|
2066
|
+
| `@miguelmorales13/nestkit/email` | `EmailModule`, `EMAIL`, `EmailPort`, adaptadores `ResendEmail`/`SmtpEmail`/`BrevoEmail`/`ZeptoMailEmail`/`MemoryEmail` |
|
|
1891
2067
|
| `@miguelmorales13/nestkit/email/resend` | `ResendModule`, `RESEND_CLIENT` |
|
|
1892
2068
|
| `@miguelmorales13/nestkit/email/nodemailer` | `NodemailerModule`, `NODEMAILER_TRANSPORT` |
|
|
1893
2069
|
| `@miguelmorales13/nestkit/i18n` | `I18nModule`, `t`, `translate`, `currentLanguage`, `I18nInterceptor`, `TranslatorPort`, `NestI18nTranslator`, `translateOr` |
|
|
1894
2070
|
| `@miguelmorales13/nestkit/bootstrap` | `applyNestKitDefaults` |
|
|
2071
|
+
| `@miguelmorales13/nestkit/security` | `signState`/`readState` — CSRF de un flujo OAuth "conectar cuenta" firmado, sin cookie ni sesión |
|
|
1895
2072
|
|
|
1896
2073
|
## Cambios recientes
|
|
1897
2074
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ZeptoMailEmailOptions } from '../email.options.js';
|
|
2
|
+
import { type EmailMessage, type EmailPort, type SentEmail } from '../email.port.js';
|
|
3
|
+
/**
|
|
4
|
+
* ZeptoMail (Zoho's transactional service) over its REST API — one `POST
|
|
5
|
+
* /email` with the Send Mail token in `Authorization: Zoho-enczapikey <token>`.
|
|
6
|
+
* No SDK, for the same reason as `brevo`: the call is a dozen lines of `fetch`.
|
|
7
|
+
*
|
|
8
|
+
* The token is per Mail Agent and lives in a data centre: a `.eu`, `.in` or
|
|
9
|
+
* `.com.au` account must point `baseUrl` at its own host
|
|
10
|
+
* (`https://api.zeptomail.eu/v1.1`), or every send answers 401.
|
|
11
|
+
*
|
|
12
|
+
* The `from` domain has to be verified in ZeptoMail (SPF + DKIM) before it
|
|
13
|
+
* sends; until then the API answers 4xx and this adapter raises it.
|
|
14
|
+
* Attachments travel base64-encoded inside the JSON. `tags` have no field
|
|
15
|
+
* here, so they go out as `X-Tag-<name>` headers, as in the SMTP adapter.
|
|
16
|
+
*/
|
|
17
|
+
export declare class ZeptoMailEmail implements EmailPort {
|
|
18
|
+
private readonly options;
|
|
19
|
+
private readonly defaults;
|
|
20
|
+
private readonly baseUrl;
|
|
21
|
+
private readonly fetchImpl;
|
|
22
|
+
constructor(options: ZeptoMailEmailOptions, defaults?: {
|
|
23
|
+
from?: string;
|
|
24
|
+
replyTo?: string;
|
|
25
|
+
});
|
|
26
|
+
send(input: EmailMessage): Promise<SentEmail>;
|
|
27
|
+
}
|
|
@@ -8,7 +8,8 @@ import { type EmailPort } from './email.port.js';
|
|
|
8
8
|
*
|
|
9
9
|
* Recognised vars: `EMAIL_PROVIDER`, `EMAIL_FROM`, `EMAIL_REPLY_TO`; resend
|
|
10
10
|
* `RESEND_API_KEY`; smtp `SMTP_HOST`, `SMTP_PORT`, `SMTP_SECURE`, `SMTP_USER`,
|
|
11
|
-
* `SMTP_PASSWORD`; brevo `BREVO_API_KEY`, `BREVO_BASE_URL
|
|
11
|
+
* `SMTP_PASSWORD`; brevo `BREVO_API_KEY`, `BREVO_BASE_URL`; zeptomail `ZEPTOMAIL_API_KEY`,
|
|
12
|
+
* `ZEPTOMAIL_BASE_URL`.
|
|
12
13
|
*/
|
|
13
14
|
export declare function resolveEmailOptions(options?: EmailOptions): EmailOptions;
|
|
14
15
|
/** Constructs the adapter the options select, failing loudly on missing config. */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** DI token carrying the resolved {@link EmailOptions}. */
|
|
2
2
|
export declare const EMAIL_OPTIONS: unique symbol;
|
|
3
3
|
/** Which adapter backs the {@link EmailPort}. */
|
|
4
|
-
export type EmailProvider = 'resend' | 'smtp' | 'brevo' | 'memory';
|
|
4
|
+
export type EmailProvider = 'resend' | 'smtp' | 'brevo' | 'zeptomail' | 'memory';
|
|
5
5
|
export interface ResendEmailOptions {
|
|
6
6
|
apiKey: string;
|
|
7
7
|
}
|
|
@@ -26,6 +26,14 @@ export interface BrevoEmailOptions {
|
|
|
26
26
|
/** For tests. Defaults to the global `fetch`. */
|
|
27
27
|
fetchImpl?: typeof fetch;
|
|
28
28
|
}
|
|
29
|
+
export interface ZeptoMailEmailOptions {
|
|
30
|
+
/** The Mail Agent's Send Mail token (the value after `Zoho-enczapikey`). */
|
|
31
|
+
apiKey: string;
|
|
32
|
+
/** Defaults to `https://api.zeptomail.com/v1.1`; other data centres use `.eu`, `.in`, `.com.au`… */
|
|
33
|
+
baseUrl?: string;
|
|
34
|
+
/** For tests. Defaults to the global `fetch`. */
|
|
35
|
+
fetchImpl?: typeof fetch;
|
|
36
|
+
}
|
|
29
37
|
export interface EmailOptions {
|
|
30
38
|
/** Read from `EMAIL_PROVIDER` when omitted. There is no default: a misconfigured app must not send nowhere in silence. */
|
|
31
39
|
provider?: EmailProvider;
|
|
@@ -36,4 +44,5 @@ export interface EmailOptions {
|
|
|
36
44
|
resend?: ResendEmailOptions;
|
|
37
45
|
smtp?: SmtpEmailOptions;
|
|
38
46
|
brevo?: BrevoEmailOptions;
|
|
47
|
+
zeptomail?: ZeptoMailEmailOptions;
|
|
39
48
|
}
|
package/dist/email/index.cjs
CHANGED
|
@@ -28,19 +28,19 @@ var EMAIL_OPTIONS = /* @__PURE__ */ Symbol("EMAIL_OPTIONS");
|
|
|
28
28
|
|
|
29
29
|
// src/email/address.ts
|
|
30
30
|
var NAMED = /^\s*(?:"?([^"]*)"?\s*)?<\s*([^<>\s]+)\s*>\s*$/;
|
|
31
|
-
function parseAddress(
|
|
32
|
-
if (typeof
|
|
33
|
-
return
|
|
31
|
+
function parseAddress(address2) {
|
|
32
|
+
if (typeof address2 !== "string") {
|
|
33
|
+
return address2.name ? { email: address2.email.trim(), name: address2.name } : { email: address2.email.trim() };
|
|
34
34
|
}
|
|
35
|
-
const match = NAMED.exec(
|
|
35
|
+
const match = NAMED.exec(address2);
|
|
36
36
|
if (match) {
|
|
37
37
|
const name = _optionalChain([match, 'access', _ => _[1], 'optionalAccess', _2 => _2.trim, 'call', _3 => _3()]);
|
|
38
38
|
return name ? { email: match[2], name } : { email: match[2] };
|
|
39
39
|
}
|
|
40
|
-
return { email:
|
|
40
|
+
return { email: address2.trim() };
|
|
41
41
|
}
|
|
42
|
-
function formatAddress(
|
|
43
|
-
const { email, name } = parseAddress(
|
|
42
|
+
function formatAddress(address2) {
|
|
43
|
+
const { email, name } = parseAddress(address2);
|
|
44
44
|
if (!name) return email;
|
|
45
45
|
const safe = /[(),:;<>@[\]"]/.test(name) ? `"${name.replace(/"/g, '\\"')}"` : name;
|
|
46
46
|
return `${safe} <${email}>`;
|
|
@@ -239,6 +239,81 @@ var SmtpEmail = class {
|
|
|
239
239
|
}
|
|
240
240
|
};
|
|
241
241
|
|
|
242
|
+
// src/email/adapters/zeptomail.email.ts
|
|
243
|
+
var PROVIDER4 = "zeptomail";
|
|
244
|
+
var DEFAULT_BASE_URL2 = "https://api.zeptomail.com/v1.1";
|
|
245
|
+
var address = (value) => {
|
|
246
|
+
const { email, name } = parseAddress(value);
|
|
247
|
+
return name ? { address: email, name } : { address: email };
|
|
248
|
+
};
|
|
249
|
+
var recipient = (value) => ({ email_address: address(value) });
|
|
250
|
+
var ZeptoMailEmail = class {
|
|
251
|
+
constructor(options, defaults = {}) {
|
|
252
|
+
this.options = options;
|
|
253
|
+
this.defaults = defaults;
|
|
254
|
+
if (!options.apiKey) {
|
|
255
|
+
throw new Error('EmailModule: provider "zeptomail" selected but no apiKey / ZEPTOMAIL_API_KEY set.');
|
|
256
|
+
}
|
|
257
|
+
this.baseUrl = (_nullishCoalesce(options.baseUrl, () => ( DEFAULT_BASE_URL2))).replace(/\/$/, "");
|
|
258
|
+
this.fetchImpl = _nullishCoalesce(options.fetchImpl, () => ( globalThis.fetch));
|
|
259
|
+
}
|
|
260
|
+
async send(input) {
|
|
261
|
+
const message = completeMessage(input, this.defaults);
|
|
262
|
+
const body = {
|
|
263
|
+
from: address(message.from),
|
|
264
|
+
to: toList(message.to).map(recipient),
|
|
265
|
+
subject: message.subject
|
|
266
|
+
};
|
|
267
|
+
const cc = toList(message.cc).map(recipient);
|
|
268
|
+
const bcc = toList(message.bcc).map(recipient);
|
|
269
|
+
if (cc.length) body.cc = cc;
|
|
270
|
+
if (bcc.length) body.bcc = bcc;
|
|
271
|
+
if (message.replyTo) body.reply_to = [address(message.replyTo)];
|
|
272
|
+
if (message.html) body.htmlbody = message.html;
|
|
273
|
+
if (message.text) body.textbody = message.text;
|
|
274
|
+
const headers = {
|
|
275
|
+
...message.headers,
|
|
276
|
+
...Object.fromEntries(Object.entries(_nullishCoalesce(message.tags, () => ( {}))).map(([k, v]) => [`X-Tag-${k}`, v]))
|
|
277
|
+
};
|
|
278
|
+
if (Object.keys(headers).length) body.mime_headers = headers;
|
|
279
|
+
if (_optionalChain([message, 'access', _15 => _15.attachments, 'optionalAccess', _16 => _16.length])) {
|
|
280
|
+
body.attachments = message.attachments.map((a) => ({
|
|
281
|
+
name: a.filename,
|
|
282
|
+
content: attachmentBuffer(a.content).toString("base64"),
|
|
283
|
+
mime_type: _nullishCoalesce(a.contentType, () => ( "application/octet-stream"))
|
|
284
|
+
}));
|
|
285
|
+
}
|
|
286
|
+
let response;
|
|
287
|
+
try {
|
|
288
|
+
response = await this.fetchImpl(`${this.baseUrl}/email`, {
|
|
289
|
+
method: "POST",
|
|
290
|
+
headers: {
|
|
291
|
+
authorization: `Zoho-enczapikey ${this.options.apiKey}`,
|
|
292
|
+
"content-type": "application/json",
|
|
293
|
+
accept: "application/json"
|
|
294
|
+
},
|
|
295
|
+
body: JSON.stringify(body)
|
|
296
|
+
});
|
|
297
|
+
} catch (cause) {
|
|
298
|
+
throw new EmailProviderException(
|
|
299
|
+
PROVIDER4,
|
|
300
|
+
0,
|
|
301
|
+
{ error: cause instanceof Error ? cause.message : String(cause) },
|
|
302
|
+
`${PROVIDER4} is unreachable`
|
|
303
|
+
);
|
|
304
|
+
}
|
|
305
|
+
const text = await response.text();
|
|
306
|
+
let parsed = text;
|
|
307
|
+
try {
|
|
308
|
+
parsed = text ? JSON.parse(text) : void 0;
|
|
309
|
+
} catch (e2) {
|
|
310
|
+
}
|
|
311
|
+
if (!response.ok) throw new EmailProviderException(PROVIDER4, response.status, parsed);
|
|
312
|
+
const id = _nullishCoalesce(_optionalChain([parsed, 'optionalAccess', _17 => _17.request_id]), () => ( null));
|
|
313
|
+
return { id, provider: PROVIDER4 };
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
|
|
242
317
|
// src/email/email.module.ts
|
|
243
318
|
var env = (k) => process.env[k] || void 0;
|
|
244
319
|
function resolveEmailOptions(options = {}) {
|
|
@@ -254,7 +329,8 @@ function resolveEmailOptions(options = {}) {
|
|
|
254
329
|
user: env("SMTP_USER"),
|
|
255
330
|
password: env("SMTP_PASSWORD")
|
|
256
331
|
} : void 0))),
|
|
257
|
-
brevo: _nullishCoalesce(options.brevo, () => ( (env("BREVO_API_KEY") ? { apiKey: env("BREVO_API_KEY"), baseUrl: env("BREVO_BASE_URL") } : void 0)))
|
|
332
|
+
brevo: _nullishCoalesce(options.brevo, () => ( (env("BREVO_API_KEY") ? { apiKey: env("BREVO_API_KEY"), baseUrl: env("BREVO_BASE_URL") } : void 0))),
|
|
333
|
+
zeptomail: _nullishCoalesce(options.zeptomail, () => ( (env("ZEPTOMAIL_API_KEY") ? { apiKey: env("ZEPTOMAIL_API_KEY"), baseUrl: env("ZEPTOMAIL_BASE_URL") } : void 0)))
|
|
258
334
|
};
|
|
259
335
|
}
|
|
260
336
|
function createEmailAdapter(options = {}) {
|
|
@@ -270,10 +346,13 @@ function createEmailAdapter(options = {}) {
|
|
|
270
346
|
case "brevo":
|
|
271
347
|
if (!resolved.brevo) throw new Error('EmailModule: provider "brevo" selected but no brevo options / BREVO_API_KEY set.');
|
|
272
348
|
return new BrevoEmail(resolved.brevo, defaults);
|
|
349
|
+
case "zeptomail":
|
|
350
|
+
if (!resolved.zeptomail) throw new Error('EmailModule: provider "zeptomail" selected but no zeptomail options / ZEPTOMAIL_API_KEY set.');
|
|
351
|
+
return new ZeptoMailEmail(resolved.zeptomail, defaults);
|
|
273
352
|
case "memory":
|
|
274
353
|
return new MemoryEmail(defaults);
|
|
275
354
|
case void 0:
|
|
276
|
-
throw new Error("EmailModule: no provider selected. Pass `provider` or set EMAIL_PROVIDER (resend | smtp | brevo | memory).");
|
|
355
|
+
throw new Error("EmailModule: no provider selected. Pass `provider` or set EMAIL_PROVIDER (resend | smtp | brevo | zeptomail | memory).");
|
|
277
356
|
default:
|
|
278
357
|
throw new Error(`EmailModule: unknown provider "${String(resolved.provider)}".`);
|
|
279
358
|
}
|
|
@@ -311,4 +390,5 @@ EmailModule = exports.EmailModule = _chunk2REOCMUDcjs.__decorateClass.call(void
|
|
|
311
390
|
|
|
312
391
|
|
|
313
392
|
|
|
314
|
-
|
|
393
|
+
|
|
394
|
+
exports.BrevoEmail = BrevoEmail; exports.EMAIL = EMAIL; exports.EMAIL_OPTIONS = EMAIL_OPTIONS; exports.EmailModule = EmailModule; exports.EmailProviderException = EmailProviderException; exports.MemoryEmail = MemoryEmail; exports.ResendEmail = ResendEmail; exports.SmtpEmail = SmtpEmail; exports.ZeptoMailEmail = ZeptoMailEmail; exports.createEmailAdapter = createEmailAdapter; exports.formatAddress = formatAddress; exports.parseAddress = parseAddress; exports.resolveEmailOptions = resolveEmailOptions;
|
package/dist/email/index.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
export { EMAIL, EmailProviderException } from './email.port.js';
|
|
2
2
|
export type { EmailPort, EmailMessage, EmailAddress, EmailAttachment, SentEmail } from './email.port.js';
|
|
3
3
|
export { EMAIL_OPTIONS } from './email.options.js';
|
|
4
|
-
export type { EmailOptions, EmailProvider, ResendEmailOptions, SmtpEmailOptions, BrevoEmailOptions, } from './email.options.js';
|
|
4
|
+
export type { EmailOptions, EmailProvider, ResendEmailOptions, SmtpEmailOptions, BrevoEmailOptions, ZeptoMailEmailOptions, } from './email.options.js';
|
|
5
5
|
export { EmailModule, createEmailAdapter, resolveEmailOptions } from './email.module.js';
|
|
6
6
|
export { parseAddress, formatAddress } from './address.js';
|
|
7
7
|
export { BrevoEmail } from './adapters/brevo.email.js';
|
|
8
8
|
export { ResendEmail } from './adapters/resend.email.js';
|
|
9
9
|
export type { ResendLike } from './adapters/resend.email.js';
|
|
10
|
+
export { ZeptoMailEmail } from './adapters/zeptomail.email.js';
|
|
10
11
|
export { SmtpEmail } from './adapters/smtp.email.js';
|
|
11
12
|
export type { TransporterLike } from './adapters/smtp.email.js';
|
|
12
13
|
export { MemoryEmail } from './adapters/memory.email.js';
|
package/dist/email/index.js
CHANGED
|
@@ -28,19 +28,19 @@ import { Global, Module } from "@nestjs/common";
|
|
|
28
28
|
|
|
29
29
|
// src/email/address.ts
|
|
30
30
|
var NAMED = /^\s*(?:"?([^"]*)"?\s*)?<\s*([^<>\s]+)\s*>\s*$/;
|
|
31
|
-
function parseAddress(
|
|
32
|
-
if (typeof
|
|
33
|
-
return
|
|
31
|
+
function parseAddress(address2) {
|
|
32
|
+
if (typeof address2 !== "string") {
|
|
33
|
+
return address2.name ? { email: address2.email.trim(), name: address2.name } : { email: address2.email.trim() };
|
|
34
34
|
}
|
|
35
|
-
const match = NAMED.exec(
|
|
35
|
+
const match = NAMED.exec(address2);
|
|
36
36
|
if (match) {
|
|
37
37
|
const name = match[1]?.trim();
|
|
38
38
|
return name ? { email: match[2], name } : { email: match[2] };
|
|
39
39
|
}
|
|
40
|
-
return { email:
|
|
40
|
+
return { email: address2.trim() };
|
|
41
41
|
}
|
|
42
|
-
function formatAddress(
|
|
43
|
-
const { email, name } = parseAddress(
|
|
42
|
+
function formatAddress(address2) {
|
|
43
|
+
const { email, name } = parseAddress(address2);
|
|
44
44
|
if (!name) return email;
|
|
45
45
|
const safe = /[(),:;<>@[\]"]/.test(name) ? `"${name.replace(/"/g, '\\"')}"` : name;
|
|
46
46
|
return `${safe} <${email}>`;
|
|
@@ -239,6 +239,81 @@ var SmtpEmail = class {
|
|
|
239
239
|
}
|
|
240
240
|
};
|
|
241
241
|
|
|
242
|
+
// src/email/adapters/zeptomail.email.ts
|
|
243
|
+
var PROVIDER4 = "zeptomail";
|
|
244
|
+
var DEFAULT_BASE_URL2 = "https://api.zeptomail.com/v1.1";
|
|
245
|
+
var address = (value) => {
|
|
246
|
+
const { email, name } = parseAddress(value);
|
|
247
|
+
return name ? { address: email, name } : { address: email };
|
|
248
|
+
};
|
|
249
|
+
var recipient = (value) => ({ email_address: address(value) });
|
|
250
|
+
var ZeptoMailEmail = class {
|
|
251
|
+
constructor(options, defaults = {}) {
|
|
252
|
+
this.options = options;
|
|
253
|
+
this.defaults = defaults;
|
|
254
|
+
if (!options.apiKey) {
|
|
255
|
+
throw new Error('EmailModule: provider "zeptomail" selected but no apiKey / ZEPTOMAIL_API_KEY set.');
|
|
256
|
+
}
|
|
257
|
+
this.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL2).replace(/\/$/, "");
|
|
258
|
+
this.fetchImpl = options.fetchImpl ?? globalThis.fetch;
|
|
259
|
+
}
|
|
260
|
+
async send(input) {
|
|
261
|
+
const message = completeMessage(input, this.defaults);
|
|
262
|
+
const body = {
|
|
263
|
+
from: address(message.from),
|
|
264
|
+
to: toList(message.to).map(recipient),
|
|
265
|
+
subject: message.subject
|
|
266
|
+
};
|
|
267
|
+
const cc = toList(message.cc).map(recipient);
|
|
268
|
+
const bcc = toList(message.bcc).map(recipient);
|
|
269
|
+
if (cc.length) body.cc = cc;
|
|
270
|
+
if (bcc.length) body.bcc = bcc;
|
|
271
|
+
if (message.replyTo) body.reply_to = [address(message.replyTo)];
|
|
272
|
+
if (message.html) body.htmlbody = message.html;
|
|
273
|
+
if (message.text) body.textbody = message.text;
|
|
274
|
+
const headers = {
|
|
275
|
+
...message.headers,
|
|
276
|
+
...Object.fromEntries(Object.entries(message.tags ?? {}).map(([k, v]) => [`X-Tag-${k}`, v]))
|
|
277
|
+
};
|
|
278
|
+
if (Object.keys(headers).length) body.mime_headers = headers;
|
|
279
|
+
if (message.attachments?.length) {
|
|
280
|
+
body.attachments = message.attachments.map((a) => ({
|
|
281
|
+
name: a.filename,
|
|
282
|
+
content: attachmentBuffer(a.content).toString("base64"),
|
|
283
|
+
mime_type: a.contentType ?? "application/octet-stream"
|
|
284
|
+
}));
|
|
285
|
+
}
|
|
286
|
+
let response;
|
|
287
|
+
try {
|
|
288
|
+
response = await this.fetchImpl(`${this.baseUrl}/email`, {
|
|
289
|
+
method: "POST",
|
|
290
|
+
headers: {
|
|
291
|
+
authorization: `Zoho-enczapikey ${this.options.apiKey}`,
|
|
292
|
+
"content-type": "application/json",
|
|
293
|
+
accept: "application/json"
|
|
294
|
+
},
|
|
295
|
+
body: JSON.stringify(body)
|
|
296
|
+
});
|
|
297
|
+
} catch (cause) {
|
|
298
|
+
throw new EmailProviderException(
|
|
299
|
+
PROVIDER4,
|
|
300
|
+
0,
|
|
301
|
+
{ error: cause instanceof Error ? cause.message : String(cause) },
|
|
302
|
+
`${PROVIDER4} is unreachable`
|
|
303
|
+
);
|
|
304
|
+
}
|
|
305
|
+
const text = await response.text();
|
|
306
|
+
let parsed = text;
|
|
307
|
+
try {
|
|
308
|
+
parsed = text ? JSON.parse(text) : void 0;
|
|
309
|
+
} catch {
|
|
310
|
+
}
|
|
311
|
+
if (!response.ok) throw new EmailProviderException(PROVIDER4, response.status, parsed);
|
|
312
|
+
const id = parsed?.request_id ?? null;
|
|
313
|
+
return { id, provider: PROVIDER4 };
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
|
|
242
317
|
// src/email/email.module.ts
|
|
243
318
|
var env = (k) => process.env[k] || void 0;
|
|
244
319
|
function resolveEmailOptions(options = {}) {
|
|
@@ -254,7 +329,8 @@ function resolveEmailOptions(options = {}) {
|
|
|
254
329
|
user: env("SMTP_USER"),
|
|
255
330
|
password: env("SMTP_PASSWORD")
|
|
256
331
|
} : void 0),
|
|
257
|
-
brevo: options.brevo ?? (env("BREVO_API_KEY") ? { apiKey: env("BREVO_API_KEY"), baseUrl: env("BREVO_BASE_URL") } : void 0)
|
|
332
|
+
brevo: options.brevo ?? (env("BREVO_API_KEY") ? { apiKey: env("BREVO_API_KEY"), baseUrl: env("BREVO_BASE_URL") } : void 0),
|
|
333
|
+
zeptomail: options.zeptomail ?? (env("ZEPTOMAIL_API_KEY") ? { apiKey: env("ZEPTOMAIL_API_KEY"), baseUrl: env("ZEPTOMAIL_BASE_URL") } : void 0)
|
|
258
334
|
};
|
|
259
335
|
}
|
|
260
336
|
function createEmailAdapter(options = {}) {
|
|
@@ -270,10 +346,13 @@ function createEmailAdapter(options = {}) {
|
|
|
270
346
|
case "brevo":
|
|
271
347
|
if (!resolved.brevo) throw new Error('EmailModule: provider "brevo" selected but no brevo options / BREVO_API_KEY set.');
|
|
272
348
|
return new BrevoEmail(resolved.brevo, defaults);
|
|
349
|
+
case "zeptomail":
|
|
350
|
+
if (!resolved.zeptomail) throw new Error('EmailModule: provider "zeptomail" selected but no zeptomail options / ZEPTOMAIL_API_KEY set.');
|
|
351
|
+
return new ZeptoMailEmail(resolved.zeptomail, defaults);
|
|
273
352
|
case "memory":
|
|
274
353
|
return new MemoryEmail(defaults);
|
|
275
354
|
case void 0:
|
|
276
|
-
throw new Error("EmailModule: no provider selected. Pass `provider` or set EMAIL_PROVIDER (resend | smtp | brevo | memory).");
|
|
355
|
+
throw new Error("EmailModule: no provider selected. Pass `provider` or set EMAIL_PROVIDER (resend | smtp | brevo | zeptomail | memory).");
|
|
277
356
|
default:
|
|
278
357
|
throw new Error(`EmailModule: unknown provider "${String(resolved.provider)}".`);
|
|
279
358
|
}
|
|
@@ -307,6 +386,7 @@ export {
|
|
|
307
386
|
MemoryEmail,
|
|
308
387
|
ResendEmail,
|
|
309
388
|
SmtpEmail,
|
|
389
|
+
ZeptoMailEmail,
|
|
310
390
|
createEmailAdapter,
|
|
311
391
|
formatAddress,
|
|
312
392
|
parseAddress,
|
package/dist/index.cjs
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
var _chunkSPTDXUEDcjs = require('./chunk-SPTDXUED.cjs');
|
|
6
|
+
require('./chunk-KVBQBT3D.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunkRF75KC63cjs = require('./chunk-RF75KC63.cjs');
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
var _chunkHVHYZXBBcjs = require('./chunk-HVHYZXBB.cjs');
|
|
17
|
-
require('./chunk-H2EHN366.cjs');
|
|
18
17
|
|
|
19
18
|
|
|
20
19
|
|
|
@@ -22,6 +21,7 @@ require('./chunk-H2EHN366.cjs');
|
|
|
22
21
|
|
|
23
22
|
|
|
24
23
|
var _chunkAPUFKA4Kcjs = require('./chunk-APUFKA4K.cjs');
|
|
24
|
+
require('./chunk-H2EHN366.cjs');
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
|