@classytic/notifications 2.7.0 → 2.9.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/CHANGELOG.md +75 -0
- package/README.md +90 -1
- package/dist/channels/index.d.mts +1 -1
- package/dist/channels/index.mjs +1 -1
- package/dist/errors-DCOaQvhV.d.mts +37 -0
- package/dist/index.d.mts +5 -4
- package/dist/index.mjs +3 -3
- package/dist/providers/index.d.mts +13 -0
- package/dist/providers/index.mjs +33 -7
- package/dist/push/index.d.mts +310 -0
- package/dist/push/index.mjs +1004 -0
- package/dist/{status-webhook-D7Hrr71A.mjs → status-webhook-D1lNssTZ.mjs} +20 -2
- package/dist/{status-webhook-BlhPvRnD.d.mts → status-webhook-Pg_jRXwp.d.mts} +8 -38
- package/dist/{telegram.channel-DnVdyq8_.mjs → telegram.channel-0XRkIXmt.mjs} +37 -3
- package/dist/{telegram.channel-CzQH7Wa8.d.mts → telegram.channel-8DKyn1og.d.mts} +1 -1
- package/dist/{types-DyUMfkyr.d.mts → types-BNjSzlcY.d.mts} +58 -18
- package/dist/utils/index.d.mts +4 -3
- package/dist/utils/index.mjs +2 -2
- package/package.json +9 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,81 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to `@classytic/notifications` will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [2.9.0] - 2026-11-23
|
|
6
|
+
|
|
7
|
+
### Added: `@classytic/notifications/push`, FCM HTTP v1 and APNs HTTP/2 with no SDK
|
|
8
|
+
|
|
9
|
+
Generalised from the push stack of a production incident-management app (FCM through
|
|
10
|
+
`firebase-admin` there; here straight HTTP v1). Node built-ins only (`node:crypto`, `node:http2`,
|
|
11
|
+
`fetch`), so the "zero required dependencies" promise holds. A new subpath and tsdown entry: the root
|
|
12
|
+
entry never loads `node:http2`.
|
|
13
|
+
|
|
14
|
+
- `fcmProvider(options)`: service-account JWT (RS256) exchanged for an OAuth2 access token, cached
|
|
15
|
+
until 60 s before expiry, ONE shared refresh for concurrent sends; a 401 refreshes and retries once.
|
|
16
|
+
- `apnsProvider(options)`: ES256 provider token reused for `tokenTtlMs` (default 50 min, validated to
|
|
17
|
+
Apple's 20 to 60 min window), one HTTP/2 session per host reused and reopened after GOAWAY / close /
|
|
18
|
+
error, ref'd only while streams are in flight; sandbox / production host from
|
|
19
|
+
`credentials.environment`; `apns-push-type`, `apns-priority`, `apns-topic`, `apns-expiration`,
|
|
20
|
+
`apns-collapse-id`; interruption levels with `critical` only when `allowCriticalAlerts`.
|
|
21
|
+
- `pushRouter({ android, ios, web, defaultPlatform })`: dispatch on `message.platform`; a platform
|
|
22
|
+
with no provider is a `PushRejectedError` (`platform-disabled`), never a dead token.
|
|
23
|
+
- Dead tokens: FCM `UNREGISTERED` / `INVALID_ARGUMENT` naming the token and APNs 410 /
|
|
24
|
+
`BadDeviceToken` throw `InvalidPushTokenError` (`reason`) after calling `onInvalidToken(token, reason)`.
|
|
25
|
+
`SENDER_ID_MISMATCH` and `DeviceTokenNotForTopic` are `PushRejectedError` and keep the device (a
|
|
26
|
+
configuration mix-up must not wipe every device row).
|
|
27
|
+
- Transient errors (429, 5xx, timeout, network) are `TransientPushError` with `retryAfterMs` from
|
|
28
|
+
`Retry-After`; a provider-wide 429 / 503 with `Retry-After` pauses that provider instance (fails fast)
|
|
29
|
+
until the time passes; a per-device 429 does not.
|
|
30
|
+
- `PushCredentialsError` for missing / malformed / refused credentials, naming fields only.
|
|
31
|
+
- Credentials as a value or a function (`CredentialsSource`), re-resolved per send; a changed `version`
|
|
32
|
+
(or field fingerprint) re-imports the key and drops cached tokens. `parseFcmServiceAccount`,
|
|
33
|
+
`validateFcmCredentials`, `validateApnsCredentials`.
|
|
34
|
+
- Content-free pushes: `createContentFreeBuilder` and the `contentFreeOnly` provider guard.
|
|
35
|
+
- `onDelivery` structured events (`PushDeliveryEvent`): token suffix + hash, status, reason, latency.
|
|
36
|
+
- `maxConcurrency` per provider instance (FCM 100, APNs 500 by default).
|
|
37
|
+
|
|
38
|
+
### Added: delivery hints and data-only pushes on the root `PushProvider`
|
|
39
|
+
|
|
40
|
+
- `PushProviderMessage` (named, exported) gains optional `platform`, `priority`, `ttlSeconds`,
|
|
41
|
+
`interruptionLevel`, `contentAvailable`, `sound`, `channelId`, `category`; `PushProvider` gains an
|
|
42
|
+
optional `close()`. `PushChannel` forwards each from `payload.data`.
|
|
43
|
+
- `PushChannel` sends a data-only push (no title, no body) only when `data.contentAvailable` or
|
|
44
|
+
`data.dataOnly` is `true`; without the flag such a send is still skipped, as before.
|
|
45
|
+
|
|
46
|
+
### Added: `Retry-After` in `withRetry`
|
|
47
|
+
|
|
48
|
+
`withRetry` (and so `NotificationService`) waits at least an error's `retryAfterMs` (found on the error
|
|
49
|
+
or its `cause` chain, `retryAfterHint`); a hint above `maxDelay` stops retrying instead of shortening the
|
|
50
|
+
wait. Errors without the field back off exactly as before.
|
|
51
|
+
|
|
52
|
+
Pinned by `tests/push-fcm.test.ts`, `tests/push-apns.test.ts` (local fake FCM over HTTP and APNs over
|
|
53
|
+
h2c, generated keys, no network), `tests/push-router-payload.test.ts`, `tests/types/push-contract.ts`.
|
|
54
|
+
Design notes: `DESIGN.md`.
|
|
55
|
+
|
|
56
|
+
## [2.8.0] — 2026-11-09
|
|
57
|
+
|
|
58
|
+
### Added: custom SMTP without authentication, and `requireTLS`
|
|
59
|
+
|
|
60
|
+
An IP-allow-listed relay (an enterprise mail gateway that accepts mail from known addresses and takes
|
|
61
|
+
no SMTP AUTH) could not be configured: `buildEmailTransport` always required `user` and `password`.
|
|
62
|
+
|
|
63
|
+
- `EmailPreset.authOptional` (set on `smtp` only). For such a preset, `user` and `password` both blank
|
|
64
|
+
(absent, empty or whitespace) builds the transport without `auth`. One without the other still
|
|
65
|
+
throws the same "SMTP user is required" / "Password is required" error. Every other preset keeps
|
|
66
|
+
requiring its key.
|
|
67
|
+
- `EmailCredentialData.requireTLS?: string | boolean` (boolean or the form strings `'true'` / `'false'`,
|
|
68
|
+
like `secure`; blank leaves it unset): passed to nodemailer as `requireTLS`, so the transport refuses
|
|
69
|
+
to send unless STARTTLS succeeds. Read only where the host may be overridden (`smtp`, `ses`).
|
|
70
|
+
- `getEmailCredentialSchema()` adds an optional `requireTLS` select; the `user` and `password`
|
|
71
|
+
descriptions say a relay may leave both blank.
|
|
72
|
+
|
|
73
|
+
Additive: a credential that worked before builds the same transport (no `requireTLS` key unless set).
|
|
74
|
+
Pinned by `tests/providers.email.auth-optional.test.ts` (including `testEmailCredential` against a fake
|
|
75
|
+
SMTP server: no `AUTH` command; `requireTLS` with no STARTTLS offered fails verification).
|
|
76
|
+
|
|
77
|
+
FLOW OCC adoption: `@spinekit/integrations`' email provider passes `requireTLS` through and lets the
|
|
78
|
+
administrator leave both fields blank for FLOW ICT's allow-listed relay (gap G-W1-INT-4).
|
|
79
|
+
|
|
5
80
|
## [2.7.0] — 2026-10-18
|
|
6
81
|
|
|
7
82
|
### Added — push delivery hints: `collapseKey`, `threadId`, `badge`
|
package/README.md
CHANGED
|
@@ -183,12 +183,30 @@ const channel = new EmailChannel({
|
|
|
183
183
|
| `sendgrid` | `smtp.sendgrid.net:587` | `apiKey` | User is the literal `apikey` |
|
|
184
184
|
| `mailgun` | `smtp.mailgun.org:465` | `user`, `password` | Per-domain SMTP creds |
|
|
185
185
|
| `ses` | `email-smtp.us-east-1.amazonaws.com:465` | `user`, `password` | SES IAM SMTP creds. Override `host` for other regions |
|
|
186
|
-
| `smtp` | user-supplied | `host`, `port`, `secure`, `user`, `password` | Any
|
|
186
|
+
| `smtp` | user-supplied | `host`, `port`, `secure`, `requireTLS`, `user`, `password` | Any SMTP server. Leave `user` and `password` both blank for a relay without auth (IP allow-listed) |
|
|
187
187
|
|
|
188
188
|
Host override is allowed only for `smtp` and `ses` (regional). Other
|
|
189
189
|
presets pin the host to prevent footguns like "I changed the host but
|
|
190
190
|
kept the Resend API key".
|
|
191
191
|
|
|
192
|
+
`requireTLS` (boolean or `'true'` / `'false'`, `smtp` and `ses` only)
|
|
193
|
+
makes the transport refuse to send unless STARTTLS succeeds. Custom SMTP
|
|
194
|
+
with `user` and `password` both blank builds a transport without `auth`
|
|
195
|
+
(a relay that allow-lists the sender by address); one without the other
|
|
196
|
+
still throws.
|
|
197
|
+
|
|
198
|
+
```typescript
|
|
199
|
+
// Enterprise relay, allow-listed by IP, STARTTLS required
|
|
200
|
+
await buildEmailTransport({
|
|
201
|
+
provider: 'smtp',
|
|
202
|
+
fromEmail: 'alerts@corp.example',
|
|
203
|
+
host: 'relay.corp.example',
|
|
204
|
+
port: 25,
|
|
205
|
+
secure: false,
|
|
206
|
+
requireTLS: true,
|
|
207
|
+
});
|
|
208
|
+
```
|
|
209
|
+
|
|
192
210
|
```typescript
|
|
193
211
|
// SES in eu-west-1
|
|
194
212
|
await buildEmailTransport({
|
|
@@ -296,6 +314,65 @@ const expoPush = new PushChannel({
|
|
|
296
314
|
});
|
|
297
315
|
```
|
|
298
316
|
|
|
317
|
+
### Built-in push transports (`/push`): FCM HTTP v1 and APNs, no SDK
|
|
318
|
+
|
|
319
|
+
`@classytic/notifications/push` ships production push providers on node built-ins only
|
|
320
|
+
(`node:crypto`, `node:http2`, `fetch`): no `firebase-admin`, no `apn`. Each is a plain `PushProvider`,
|
|
321
|
+
so it drops into `PushChannel`.
|
|
322
|
+
|
|
323
|
+
```typescript
|
|
324
|
+
import { PushChannel } from '@classytic/notifications/channels';
|
|
325
|
+
import { apnsProvider, fcmProvider, pushRouter } from '@classytic/notifications/push';
|
|
326
|
+
|
|
327
|
+
const dropToken = (token: string) => devices.deleteOne({ token });
|
|
328
|
+
|
|
329
|
+
const push = new PushChannel({
|
|
330
|
+
provider: pushRouter({
|
|
331
|
+
// Credentials are a value or a FUNCTION, re-read per send: rotate without restarting.
|
|
332
|
+
android: fcmProvider({ credentials: () => vault.fcm(), onInvalidToken: dropToken }),
|
|
333
|
+
ios: apnsProvider({
|
|
334
|
+
credentials: () => vault.apns(), // { keyId, teamId, privateKey (.p8), bundleId, environment }
|
|
335
|
+
onInvalidToken: dropToken,
|
|
336
|
+
allowCriticalAlerts: false, // true only if the iOS build has Apple's critical-alerts entitlement
|
|
337
|
+
}),
|
|
338
|
+
}),
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
await service.send({
|
|
342
|
+
event: 'task.offered',
|
|
343
|
+
recipient: { id: userId, deviceToken },
|
|
344
|
+
data: {
|
|
345
|
+
title: 'New task',
|
|
346
|
+
platform: 'ios', // pushRouter dispatches on it
|
|
347
|
+
pushData: { type: 'task_offer', offerId: 'o_1' },
|
|
348
|
+
collapseKey: 'offer-o_1',
|
|
349
|
+
interruptionLevel: 'time-sensitive',
|
|
350
|
+
ttlSeconds: 300,
|
|
351
|
+
},
|
|
352
|
+
});
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
| Provider answer | Result | Retried |
|
|
356
|
+
|---|---|---|
|
|
357
|
+
| FCM `UNREGISTERED`, `INVALID_ARGUMENT` naming the token; APNs 410, `BadDeviceToken` | `InvalidPushTokenError` + `onInvalidToken(token, reason)` | no |
|
|
358
|
+
| Payload / topic / sender problems, a platform without a provider | `PushRejectedError` (device kept) | no |
|
|
359
|
+
| Credentials missing, malformed, or refused after one refresh | `PushCredentialsError` | no |
|
|
360
|
+
| 429, 5xx, timeout, network | `TransientPushError` with `retryAfterMs` | yes, never sooner than `Retry-After` |
|
|
361
|
+
|
|
362
|
+
- **Tokens**: FCM OAuth2 access tokens are cached until 60 s before expiry with one shared refresh
|
|
363
|
+
for concurrent sends; APNs ES256 provider tokens are reused for 50 minutes (Apple allows 20 to 60).
|
|
364
|
+
- **Connections**: one HTTP/2 session per APNs host, reused, reopened after GOAWAY; it never holds
|
|
365
|
+
the process open while idle. `close()` ends it on shutdown.
|
|
366
|
+
- **Data-only pushes**: `data.contentAvailable: true` (or `dataOnly: true`) with no title/body sends a
|
|
367
|
+
background push. `createContentFreeBuilder` / `contentFreeOnly` keep pushes to a type and opaque ids
|
|
368
|
+
for apps whose data may not leave a jurisdiction.
|
|
369
|
+
- **Observability**: `onDelivery(event)` gets one redacted record per send (token suffix and hash,
|
|
370
|
+
status, reason, latency; never the token or the text).
|
|
371
|
+
- `withRetry` (and so the service) now honours `retryAfterMs` on an error or its `cause`.
|
|
372
|
+
|
|
373
|
+
Arc apps: `@classytic/arc-notifications/push` adds device registration, credentials from env or an
|
|
374
|
+
encrypted admin integration, and a device fan-out channel on top of these providers.
|
|
375
|
+
|
|
299
376
|
### WebhookChannel
|
|
300
377
|
|
|
301
378
|
Zero dependencies — uses native `fetch`.
|
|
@@ -743,6 +820,18 @@ import {
|
|
|
743
820
|
NotificationError, ChannelError, ProviderNotInstalledError,
|
|
744
821
|
} from '@classytic/notifications/utils';
|
|
745
822
|
|
|
823
|
+
// Push transports (FCM HTTP v1, APNs HTTP/2), zero dependencies
|
|
824
|
+
import {
|
|
825
|
+
fcmProvider, apnsProvider, pushRouter,
|
|
826
|
+
createContentFreeBuilder, contentFreeOnly,
|
|
827
|
+
parseFcmServiceAccount, validateFcmCredentials, validateApnsCredentials,
|
|
828
|
+
InvalidPushTokenError, PushRejectedError, PushCredentialsError, TransientPushError,
|
|
829
|
+
isInvalidPushTokenError, tokenSuffix, tokenHash,
|
|
830
|
+
} from '@classytic/notifications/push';
|
|
831
|
+
import type {
|
|
832
|
+
FcmCredentials, ApnsCredentials, CredentialsSource, PushDeliveryEvent, InvalidTokenReason,
|
|
833
|
+
} from '@classytic/notifications/push';
|
|
834
|
+
|
|
746
835
|
// Types
|
|
747
836
|
import type {
|
|
748
837
|
SmsProvider, PushProvider, DeliveryLog, DeliveryStatus,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as WebhookChannel, i as ConsoleChannel, n as PushChannel, o as EmailChannel, r as SmsChannel, s as BaseChannel, t as TelegramChannel } from "../telegram.channel-
|
|
1
|
+
import { a as WebhookChannel, i as ConsoleChannel, n as PushChannel, o as EmailChannel, r as SmsChannel, s as BaseChannel, t as TelegramChannel } from "../telegram.channel-8DKyn1og.mjs";
|
|
2
2
|
export { BaseChannel, ConsoleChannel, EmailChannel, PushChannel, SmsChannel, TelegramChannel, WebhookChannel };
|
package/dist/channels/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as WebhookChannel, i as ConsoleChannel, n as PushChannel, o as EmailChannel, r as SmsChannel, s as BaseChannel, t as TelegramChannel } from "../telegram.channel-
|
|
1
|
+
import { a as WebhookChannel, i as ConsoleChannel, n as PushChannel, o as EmailChannel, r as SmsChannel, s as BaseChannel, t as TelegramChannel } from "../telegram.channel-0XRkIXmt.mjs";
|
|
2
2
|
|
|
3
3
|
export { BaseChannel, ConsoleChannel, EmailChannel, PushChannel, SmsChannel, TelegramChannel, WebhookChannel };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//#region src/utils/errors.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Notification Errors
|
|
4
|
+
* @module @classytic/notifications
|
|
5
|
+
*/
|
|
6
|
+
declare class NotificationError extends Error {
|
|
7
|
+
readonly code: string;
|
|
8
|
+
readonly channel?: string;
|
|
9
|
+
readonly cause?: Error;
|
|
10
|
+
constructor(message: string, options?: {
|
|
11
|
+
code?: string;
|
|
12
|
+
channel?: string;
|
|
13
|
+
cause?: Error;
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
declare class ChannelError extends NotificationError {
|
|
17
|
+
constructor(channel: string, message: string, cause?: Error);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Thrown by a provider for a failure no retry can fix (unregistered device token, invalid
|
|
21
|
+
* recipient). Channels that honour it (PushChannel) return `failed` with `retryable: false`, so
|
|
22
|
+
* the service does not retry. Detected structurally (`retryable === false`), so a provider may
|
|
23
|
+
* also throw any error carrying that flag.
|
|
24
|
+
*/
|
|
25
|
+
declare class PermanentDeliveryError extends NotificationError {
|
|
26
|
+
readonly retryable: false;
|
|
27
|
+
constructor(message: string, options?: {
|
|
28
|
+
code?: string;
|
|
29
|
+
channel?: string;
|
|
30
|
+
cause?: Error;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
declare class ProviderNotInstalledError extends NotificationError {
|
|
34
|
+
constructor(provider: string, installCmd: string);
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
export { ProviderNotInstalledError as i, NotificationError as n, PermanentDeliveryError as r, ChannelError as t };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
import { a as WebhookChannel, i as ConsoleChannel, n as PushChannel, o as EmailChannel, r as SmsChannel, s as BaseChannel, t as TelegramChannel } from "./telegram.channel-
|
|
3
|
-
import { C as
|
|
1
|
+
import { $ as RateLimitConfig, A as SmsProvider, B as QueueJobStatus, C as PushProviderMessage, D as SendResult, E as RetryConfig, F as WebhookChannelConfig, G as MemoryDeliveryLog, H as DeliveryLog, I as MemoryQueue, J as IdempotencyStore, K as IDEMPOTENCY_DEFAULT_LEASE, L as QueueAdapter, M as TelegramChannelConfig, N as TemplateResolver, O as ServiceEvent, P as TemplateResult, Q as MemoryRateLimitStore, R as QueueEnqueueOptions, S as PushProvider, T as ResolvedRetryConfig, U as DeliveryLogEntry, V as QueueProcessor, W as DeliveryLogQuery, X as RedisIdempotencyClient, Y as MemoryIdempotencyStore, Z as RedisIdempotencyStore, _ as NotificationServiceConfig, a as ChannelConfig, b as PushInterruptionLevel, c as EmailChannelConfig, d as HookMap, et as RateLimitStore, f as Logger, g as NotificationPreferences, h as NotificationPayload, i as Channel, j as SmtpTransportOptions, k as SmsChannelConfig, l as EventHandler, m as NotificationHookConfig, n as BatchProgress, o as DispatchResult, p as NodemailerTransporter, q as IDEMPOTENCY_DEFAULT_TTL, r as BatchResult, s as EmailAttachment, t as BatchOptions, u as HookHandler, v as PreferenceResolver, w as Recipient, x as PushPlatform, y as PushChannelConfig, z as QueueJob } from "./types-BNjSzlcY.mjs";
|
|
2
|
+
import { a as WebhookChannel, i as ConsoleChannel, n as PushChannel, o as EmailChannel, r as SmsChannel, s as BaseChannel, t as TelegramChannel } from "./telegram.channel-8DKyn1og.mjs";
|
|
3
|
+
import { C as mergeHooks, S as withRetry, _ as isQuietHours, a as createStatusHandler, b as resolveRetryConfig, c as InterpolateOptions, d as TemplateMap, f as createSimpleResolver, g as QuietHoursConfig, h as pMap, i as StatusUpdate, l as SimpleResolverOptions, m as PMapOptions, n as StatusHandler, o as FallbackOptions, p as interpolateHtml, r as StatusHandlerConfig, s as withFallback, t as DeliveryStatus, u as TemplateDefinition, v as Emitter, x as retryAfterHint, y as calculateDelay } from "./status-webhook-Pg_jRXwp.mjs";
|
|
4
|
+
import { i as ProviderNotInstalledError, n as NotificationError, r as PermanentDeliveryError, t as ChannelError } from "./errors-DCOaQvhV.mjs";
|
|
4
5
|
//#region src/NotificationService.d.ts
|
|
5
6
|
export declare class NotificationService {
|
|
6
7
|
private channels;
|
|
@@ -138,4 +139,4 @@ export declare class NotificationService {
|
|
|
138
139
|
off(event: ServiceEvent, handler: EventHandler): this;
|
|
139
140
|
}
|
|
140
141
|
//#endregion
|
|
141
|
-
export { BaseChannel, type BatchOptions, type BatchProgress, type BatchResult, type Channel, type ChannelConfig, ChannelError, ConsoleChannel, type DeliveryLog, type DeliveryLogEntry, type DeliveryLogQuery, type DeliveryStatus, type DispatchResult, type EmailAttachment, EmailChannel, type EmailChannelConfig, Emitter, type EventHandler, type FallbackOptions, type HookHandler, type HookMap, IDEMPOTENCY_DEFAULT_LEASE, IDEMPOTENCY_DEFAULT_TTL, type IdempotencyStore, type InterpolateOptions, type Logger, MemoryDeliveryLog, MemoryIdempotencyStore, MemoryQueue, MemoryRateLimitStore, type NodemailerTransporter, NotificationError, type NotificationHookConfig, type NotificationPayload, type NotificationPreferences, type NotificationServiceConfig, type PMapOptions, PermanentDeliveryError, type PreferenceResolver, ProviderNotInstalledError, PushChannel, type PushChannelConfig, type PushProvider, type QueueAdapter, type QueueEnqueueOptions, type QueueJob, type QueueJobStatus, type QueueProcessor, type QuietHoursConfig, type RateLimitConfig, type RateLimitStore, type Recipient, type RedisIdempotencyClient, RedisIdempotencyStore, type ResolvedRetryConfig, type RetryConfig, type SendResult, type ServiceEvent, type SimpleResolverOptions, SmsChannel, type SmsChannelConfig, type SmsProvider, type SmtpTransportOptions, type StatusHandler, type StatusHandlerConfig, type StatusUpdate, TelegramChannel, type TelegramChannelConfig, type TemplateDefinition, type TemplateMap, type TemplateResolver, type TemplateResult, WebhookChannel, type WebhookChannelConfig, calculateDelay, createSimpleResolver, createStatusHandler, interpolateHtml, isQuietHours, mergeHooks, pMap, resolveRetryConfig, withFallback, withRetry };
|
|
142
|
+
export { BaseChannel, type BatchOptions, type BatchProgress, type BatchResult, type Channel, type ChannelConfig, ChannelError, ConsoleChannel, type DeliveryLog, type DeliveryLogEntry, type DeliveryLogQuery, type DeliveryStatus, type DispatchResult, type EmailAttachment, EmailChannel, type EmailChannelConfig, Emitter, type EventHandler, type FallbackOptions, type HookHandler, type HookMap, IDEMPOTENCY_DEFAULT_LEASE, IDEMPOTENCY_DEFAULT_TTL, type IdempotencyStore, type InterpolateOptions, type Logger, MemoryDeliveryLog, MemoryIdempotencyStore, MemoryQueue, MemoryRateLimitStore, type NodemailerTransporter, NotificationError, type NotificationHookConfig, type NotificationPayload, type NotificationPreferences, type NotificationServiceConfig, type PMapOptions, PermanentDeliveryError, type PreferenceResolver, ProviderNotInstalledError, PushChannel, type PushChannelConfig, type PushInterruptionLevel, type PushPlatform, type PushProvider, type PushProviderMessage, type QueueAdapter, type QueueEnqueueOptions, type QueueJob, type QueueJobStatus, type QueueProcessor, type QuietHoursConfig, type RateLimitConfig, type RateLimitStore, type Recipient, type RedisIdempotencyClient, RedisIdempotencyStore, type ResolvedRetryConfig, type RetryConfig, type SendResult, type ServiceEvent, type SimpleResolverOptions, SmsChannel, type SmsChannelConfig, type SmsProvider, type SmtpTransportOptions, type StatusHandler, type StatusHandlerConfig, type StatusUpdate, TelegramChannel, type TelegramChannelConfig, type TemplateDefinition, type TemplateMap, type TemplateResolver, type TemplateResult, WebhookChannel, type WebhookChannelConfig, calculateDelay, createSimpleResolver, createStatusHandler, interpolateHtml, isQuietHours, mergeHooks, pMap, resolveRetryConfig, retryAfterHint, withFallback, withRetry };
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { _ as
|
|
1
|
+
import { _ as retryAfterHint, a as MemoryQueue, c as pMap, d as IDEMPOTENCY_DEFAULT_TTL, f as MemoryIdempotencyStore, g as resolveRetryConfig, h as calculateDelay, i as interpolateHtml, l as MemoryRateLimitStore, m as isQuietHours, n as withFallback, o as MemoryDeliveryLog, p as RedisIdempotencyStore, r as createSimpleResolver, s as mergeHooks, t as createStatusHandler, u as IDEMPOTENCY_DEFAULT_LEASE, v as withRetry, y as Emitter } from "./status-webhook-D1lNssTZ.mjs";
|
|
2
2
|
import { i as ProviderNotInstalledError, n as NotificationError, r as PermanentDeliveryError, t as ChannelError } from "./errors-CsQZKfec.mjs";
|
|
3
|
-
import { a as WebhookChannel, i as ConsoleChannel, n as PushChannel, o as EmailChannel, r as SmsChannel, s as BaseChannel, t as TelegramChannel } from "./telegram.channel-
|
|
3
|
+
import { a as WebhookChannel, i as ConsoleChannel, n as PushChannel, o as EmailChannel, r as SmsChannel, s as BaseChannel, t as TelegramChannel } from "./telegram.channel-0XRkIXmt.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/NotificationService.ts
|
|
6
6
|
/**
|
|
@@ -575,4 +575,4 @@ var NotificationService = class {
|
|
|
575
575
|
*/
|
|
576
576
|
|
|
577
577
|
//#endregion
|
|
578
|
-
export { BaseChannel, ChannelError, ConsoleChannel, EmailChannel, Emitter, IDEMPOTENCY_DEFAULT_LEASE, IDEMPOTENCY_DEFAULT_TTL, MemoryDeliveryLog, MemoryIdempotencyStore, MemoryQueue, MemoryRateLimitStore, NotificationError, NotificationService, PermanentDeliveryError, ProviderNotInstalledError, PushChannel, RedisIdempotencyStore, SmsChannel, TelegramChannel, WebhookChannel, calculateDelay, createSimpleResolver, createStatusHandler, interpolateHtml, isQuietHours, mergeHooks, pMap, resolveRetryConfig, withFallback, withRetry };
|
|
578
|
+
export { BaseChannel, ChannelError, ConsoleChannel, EmailChannel, Emitter, IDEMPOTENCY_DEFAULT_LEASE, IDEMPOTENCY_DEFAULT_TTL, MemoryDeliveryLog, MemoryIdempotencyStore, MemoryQueue, MemoryRateLimitStore, NotificationError, NotificationService, PermanentDeliveryError, ProviderNotInstalledError, PushChannel, RedisIdempotencyStore, SmsChannel, TelegramChannel, WebhookChannel, calculateDelay, createSimpleResolver, createStatusHandler, interpolateHtml, isQuietHours, mergeHooks, pMap, resolveRetryConfig, retryAfterHint, withFallback, withRetry };
|
|
@@ -45,6 +45,13 @@ interface EmailPreset {
|
|
|
45
45
|
* — prevents "changed host, kept the Resend key" footguns.
|
|
46
46
|
*/
|
|
47
47
|
allowHostOverride?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* `true` when the relay may take no SMTP AUTH: with BOTH `user` and
|
|
50
|
+
* `password` blank the transport is built without `auth` (an
|
|
51
|
+
* IP-allow-listed relay). One without the other is still an error.
|
|
52
|
+
* Only custom SMTP sets it; every preset keeps requiring its key.
|
|
53
|
+
*/
|
|
54
|
+
authOptional?: boolean;
|
|
48
55
|
/** Setup instructions surfaced in the Integrations UI. */
|
|
49
56
|
setupHint: string;
|
|
50
57
|
}
|
|
@@ -74,6 +81,12 @@ interface EmailCredentialData {
|
|
|
74
81
|
host?: string;
|
|
75
82
|
port?: string | number;
|
|
76
83
|
secure?: string | boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Refuse to send unless STARTTLS succeeds (nodemailer `requireTLS`).
|
|
86
|
+
* Boolean or the form strings `'true'` / `'false'`; blank leaves it
|
|
87
|
+
* unset. Read only where the host may be overridden (`smtp`, `ses`).
|
|
88
|
+
*/
|
|
89
|
+
requireTLS?: string | boolean;
|
|
77
90
|
}
|
|
78
91
|
/**
|
|
79
92
|
* Build a `nodemailer` `Transporter` from the credential blob.
|
package/dist/providers/index.mjs
CHANGED
|
@@ -59,7 +59,8 @@ const EMAIL_PRESETS = {
|
|
|
59
59
|
secure: false,
|
|
60
60
|
userSource: "user",
|
|
61
61
|
passSource: "password",
|
|
62
|
-
|
|
62
|
+
authOptional: true,
|
|
63
|
+
setupHint: "Use for SMTP servers without a preset. Standard auth-SMTP only — no OAuth-XOAUTH2. For a relay that accepts mail from allow-listed addresses without authentication, leave user and password both blank."
|
|
63
64
|
}
|
|
64
65
|
};
|
|
65
66
|
/** Convenience dropdown options for the credential UI. */
|
|
@@ -70,6 +71,14 @@ const EMAIL_PROVIDER_OPTIONS = Object.keys(EMAIL_PRESETS).map((name) => ({
|
|
|
70
71
|
|
|
71
72
|
//#endregion
|
|
72
73
|
//#region src/providers/email/transport.ts
|
|
74
|
+
function isBlank(value) {
|
|
75
|
+
return value === void 0 || value === null || String(value).trim() === "";
|
|
76
|
+
}
|
|
77
|
+
/** Boolean, or the form strings `'true'` / `'false'`; blank is `undefined`. */
|
|
78
|
+
function readFlag(value) {
|
|
79
|
+
if (typeof value === "boolean") return value;
|
|
80
|
+
if (typeof value === "string" && value.trim() !== "") return value.trim() === "true";
|
|
81
|
+
}
|
|
73
82
|
function resolveUser(data, userSource) {
|
|
74
83
|
if (userSource.startsWith("literal:")) return userSource.slice(8);
|
|
75
84
|
if (userSource === "user") {
|
|
@@ -102,6 +111,11 @@ async function buildEmailTransport(data) {
|
|
|
102
111
|
if (typeof data.secure === "boolean") secure = data.secure;
|
|
103
112
|
else if (typeof data.secure === "string") secure = data.secure === "true";
|
|
104
113
|
}
|
|
114
|
+
const requireTLS = allowOverride ? readFlag(data.requireTLS) : void 0;
|
|
115
|
+
const auth = preset.authOptional === true && preset.userSource === "user" && isBlank(data.user) && isBlank(preset.passSource === "apiKey" ? data.apiKey : data.password) ? void 0 : {
|
|
116
|
+
user: resolveUser(data, preset.userSource),
|
|
117
|
+
pass: resolvePass(data, preset.passSource)
|
|
118
|
+
};
|
|
105
119
|
let nodemailer;
|
|
106
120
|
try {
|
|
107
121
|
nodemailer = await import("nodemailer");
|
|
@@ -112,10 +126,8 @@ async function buildEmailTransport(data) {
|
|
|
112
126
|
host,
|
|
113
127
|
port,
|
|
114
128
|
secure,
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
pass: resolvePass(data, preset.passSource)
|
|
118
|
-
}
|
|
129
|
+
...requireTLS !== void 0 ? { requireTLS } : {},
|
|
130
|
+
...auth ? { auth } : {}
|
|
119
131
|
});
|
|
120
132
|
}
|
|
121
133
|
/**
|
|
@@ -182,14 +194,14 @@ function getEmailCredentialSchema() {
|
|
|
182
194
|
displayName: "SMTP Username",
|
|
183
195
|
type: "text",
|
|
184
196
|
required: false,
|
|
185
|
-
description: "Gmail address, Mailgun SMTP user, or custom SMTP user."
|
|
197
|
+
description: "Gmail address, Mailgun SMTP user, or custom SMTP user. Custom SMTP: leave user and password both blank for a relay that accepts mail without authentication."
|
|
186
198
|
},
|
|
187
199
|
{
|
|
188
200
|
name: "password",
|
|
189
201
|
displayName: "SMTP Password",
|
|
190
202
|
type: "password",
|
|
191
203
|
required: false,
|
|
192
|
-
description: "Gmail app password, Mailgun SMTP password, or custom SMTP password."
|
|
204
|
+
description: "Gmail app password, Mailgun SMTP password, or custom SMTP password. Custom SMTP: leave both blank for a relay without authentication."
|
|
193
205
|
},
|
|
194
206
|
{
|
|
195
207
|
name: "host",
|
|
@@ -220,6 +232,20 @@ function getEmailCredentialSchema() {
|
|
|
220
232
|
label: "false (port 587 / STARTTLS)"
|
|
221
233
|
}],
|
|
222
234
|
description: "Custom SMTP only."
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
name: "requireTLS",
|
|
238
|
+
displayName: "Require STARTTLS",
|
|
239
|
+
type: "select",
|
|
240
|
+
required: false,
|
|
241
|
+
options: [{
|
|
242
|
+
value: "true",
|
|
243
|
+
label: "true (refuse to send without STARTTLS)"
|
|
244
|
+
}, {
|
|
245
|
+
value: "false",
|
|
246
|
+
label: "false (use STARTTLS when offered)"
|
|
247
|
+
}],
|
|
248
|
+
description: "Custom SMTP only. With Secure false, refuse to send unless the relay upgrades to TLS."
|
|
223
249
|
}
|
|
224
250
|
];
|
|
225
251
|
}
|