@apocaliss92/nodelink-js 0.4.29 → 0.4.31
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 +20 -13
- package/dist/{chunk-NQ7D5TLR.js → chunk-XVFCEFM6.js} +11 -1
- package/dist/chunk-XVFCEFM6.js.map +1 -0
- package/dist/cli/rtsp-server.cjs +10 -0
- package/dist/cli/rtsp-server.cjs.map +1 -1
- package/dist/cli/rtsp-server.js +1 -1
- package/dist/index.cjs +67 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +58 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-NQ7D5TLR.js.map +0 -1
package/dist/cli/rtsp-server.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -21585,6 +21585,7 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
|
|
|
21585
21585
|
*/
|
|
21586
21586
|
subscribeEmailPushEvents(params) {
|
|
21587
21587
|
const channel = params.channel ?? 0;
|
|
21588
|
+
const onEvent = params.onEvent;
|
|
21588
21589
|
const matches = "match" in params ? params.match : (event) => event.cameraId === params.cameraId;
|
|
21589
21590
|
const off = onEmailPushEvent((event) => {
|
|
21590
21591
|
if (!matches(event)) return;
|
|
@@ -21600,6 +21601,15 @@ var ReolinkBaichuanApi = class _ReolinkBaichuanApi {
|
|
|
21600
21601
|
timestamp: event.receivedAtMs
|
|
21601
21602
|
});
|
|
21602
21603
|
}
|
|
21604
|
+
if (onEvent) {
|
|
21605
|
+
try {
|
|
21606
|
+
onEvent(event);
|
|
21607
|
+
} catch (err) {
|
|
21608
|
+
this.logger.warn?.(
|
|
21609
|
+
`[ReolinkBaichuanApi] subscribeEmailPushEvents onEvent threw: ${err instanceof Error ? err.message : err}`
|
|
21610
|
+
);
|
|
21611
|
+
}
|
|
21612
|
+
}
|
|
21603
21613
|
});
|
|
21604
21614
|
return off;
|
|
21605
21615
|
}
|
|
@@ -41065,6 +41075,7 @@ function base64DecodeToBytes(b64) {
|
|
|
41065
41075
|
}
|
|
41066
41076
|
|
|
41067
41077
|
// src/emailPush/server.ts
|
|
41078
|
+
var import_node_util2 = require("util");
|
|
41068
41079
|
var import_smtp_server = require("smtp-server");
|
|
41069
41080
|
var import_mailparser = require("mailparser");
|
|
41070
41081
|
|
|
@@ -41120,8 +41131,10 @@ function createEmailPushServer(params) {
|
|
|
41120
41131
|
let server;
|
|
41121
41132
|
let status = buildInitialStatus(config);
|
|
41122
41133
|
function parseRecipient(rcpt) {
|
|
41123
|
-
const
|
|
41124
|
-
if (
|
|
41134
|
+
const at = rcpt.lastIndexOf("@");
|
|
41135
|
+
if (at <= 0 || at === rcpt.length - 1) return void 0;
|
|
41136
|
+
const local = rcpt.slice(0, at);
|
|
41137
|
+
const domain = rcpt.slice(at + 1).toLowerCase();
|
|
41125
41138
|
return { local, domain };
|
|
41126
41139
|
}
|
|
41127
41140
|
function resolveCameraIdFromRecipient(rcpt) {
|
|
@@ -41174,10 +41187,19 @@ function createEmailPushServer(params) {
|
|
|
41174
41187
|
disabledCommands: config.requireAuth ? [] : ["AUTH"],
|
|
41175
41188
|
allowInsecureAuth: !config.tls,
|
|
41176
41189
|
size: config.maxMessageBytes,
|
|
41190
|
+
// smtp-server invokes its internal logger as
|
|
41191
|
+
// logger.info(metadata, formatString, ...args)
|
|
41192
|
+
// where `metadata` is an opaque session/connection object and
|
|
41193
|
+
// `formatString` may contain printf-style placeholders.
|
|
41194
|
+
// Naive `.map(String).join(" ")` would surface `[object Object]`
|
|
41195
|
+
// and leave `%s` unresolved (which is what the user was seeing).
|
|
41196
|
+
// Here we strip the metadata (keeping a compact `tnx`/`cid` tag
|
|
41197
|
+
// when present), then apply `util.format` so placeholders are
|
|
41198
|
+
// expanded by Node exactly like the smtp-server defaults do.
|
|
41177
41199
|
logger: {
|
|
41178
|
-
info: (...args) => log.
|
|
41179
|
-
debug: (...args) => log.debug(
|
|
41180
|
-
error: (...args) => log.warn(
|
|
41200
|
+
info: (...args) => log.info(formatSmtpLogArgs(args)),
|
|
41201
|
+
debug: (...args) => log.debug(formatSmtpLogArgs(args)),
|
|
41202
|
+
error: (...args) => log.warn(formatSmtpLogArgs(args))
|
|
41181
41203
|
},
|
|
41182
41204
|
...tlsOptions ? { secure: false, ...tlsOptions } : {},
|
|
41183
41205
|
onConnect(session, callback) {
|
|
@@ -41226,24 +41248,37 @@ function createEmailPushServer(params) {
|
|
|
41226
41248
|
);
|
|
41227
41249
|
return callback(new Error("Invalid username or password"));
|
|
41228
41250
|
},
|
|
41229
|
-
onRcptTo(address,
|
|
41251
|
+
onRcptTo(address, session, callback) {
|
|
41230
41252
|
const cameraId = resolveCameraIdFromRecipient(address.address);
|
|
41231
41253
|
if (!cameraId) {
|
|
41232
41254
|
status.messagesRejected++;
|
|
41255
|
+
log.warn(
|
|
41256
|
+
`SMTP RCPT TO rejected ${address.address} \u2014 unknown recipient (sessionId=${session.id})`
|
|
41257
|
+
);
|
|
41233
41258
|
return callback(
|
|
41234
41259
|
new Error(
|
|
41235
41260
|
`Unknown recipient ${address.address} (not registered)`
|
|
41236
41261
|
)
|
|
41237
41262
|
);
|
|
41238
41263
|
}
|
|
41264
|
+
log.info(
|
|
41265
|
+
`SMTP RCPT TO ${address.address} \u2192 camera=${cameraId} (sessionId=${session.id})`
|
|
41266
|
+
);
|
|
41239
41267
|
callback();
|
|
41240
41268
|
},
|
|
41241
41269
|
onData(stream, session, callback) {
|
|
41270
|
+
const startedAt = Date.now();
|
|
41271
|
+
log.debug(
|
|
41272
|
+
`SMTP DATA start (sessionId=${session.id} from=${session.envelope.mailFrom ? session.envelope.mailFrom.address : "?"})`
|
|
41273
|
+
);
|
|
41242
41274
|
const chunks = [];
|
|
41243
41275
|
stream.on("data", (chunk) => chunks.push(chunk));
|
|
41244
41276
|
stream.on("end", () => {
|
|
41245
41277
|
const recipients = session.envelope.rcptTo?.map((r) => r.address) ?? [];
|
|
41246
41278
|
const buffer = Buffer.concat(chunks);
|
|
41279
|
+
log.info(
|
|
41280
|
+
`SMTP DATA received ${buffer.length}B in ${Date.now() - startedAt}ms for ${recipients.length} recipient(s) (sessionId=${session.id})`
|
|
41281
|
+
);
|
|
41247
41282
|
const matched = recipients.map((r) => ({
|
|
41248
41283
|
recipient: r,
|
|
41249
41284
|
cameraId: resolveCameraIdFromRecipient(r)
|
|
@@ -41252,6 +41287,9 @@ function createEmailPushServer(params) {
|
|
|
41252
41287
|
);
|
|
41253
41288
|
if (matched.length === 0) {
|
|
41254
41289
|
status.messagesRejected++;
|
|
41290
|
+
log.warn(
|
|
41291
|
+
`SMTP DATA dropped \u2014 no recognised recipients in [${recipients.join(", ")}] (sessionId=${session.id})`
|
|
41292
|
+
);
|
|
41255
41293
|
return callback(new Error("No recognised recipients"));
|
|
41256
41294
|
}
|
|
41257
41295
|
Promise.all(
|
|
@@ -41260,13 +41298,15 @@ function createEmailPushServer(params) {
|
|
|
41260
41298
|
)
|
|
41261
41299
|
).then(() => callback()).catch((err) => {
|
|
41262
41300
|
const msg = err instanceof Error ? err.message : String(err);
|
|
41263
|
-
log.error(
|
|
41301
|
+
log.error(
|
|
41302
|
+
`Email push pipeline error (sessionId=${session.id}): ${msg}`
|
|
41303
|
+
);
|
|
41264
41304
|
status.lastErrorMessage = msg;
|
|
41265
41305
|
callback(new Error(msg));
|
|
41266
41306
|
});
|
|
41267
41307
|
});
|
|
41268
41308
|
stream.on("error", (err) => {
|
|
41269
|
-
log.warn(`SMTP stream error: ${err.message}`);
|
|
41309
|
+
log.warn(`SMTP stream error (sessionId=${session.id}): ${err.message}`);
|
|
41270
41310
|
callback(err);
|
|
41271
41311
|
});
|
|
41272
41312
|
}
|
|
@@ -41314,6 +41354,25 @@ function createEmailPushServer(params) {
|
|
|
41314
41354
|
}
|
|
41315
41355
|
};
|
|
41316
41356
|
}
|
|
41357
|
+
function formatSmtpLogArgs(args) {
|
|
41358
|
+
if (args.length === 0) return "[smtp]";
|
|
41359
|
+
const [first, ...rest] = args;
|
|
41360
|
+
let tag = "";
|
|
41361
|
+
let formatArgs = args;
|
|
41362
|
+
if (first && typeof first === "object" && !Array.isArray(first)) {
|
|
41363
|
+
const meta = first;
|
|
41364
|
+
const tnx = typeof meta.tnx === "string" ? meta.tnx : void 0;
|
|
41365
|
+
const cid = typeof meta.cid === "string" ? meta.cid : void 0;
|
|
41366
|
+
const sid = typeof meta.sid === "string" ? meta.sid : void 0;
|
|
41367
|
+
const bits = [];
|
|
41368
|
+
if (tnx) bits.push(tnx);
|
|
41369
|
+
if (cid) bits.push(`cid=${cid}`);
|
|
41370
|
+
if (sid) bits.push(`sid=${sid}`);
|
|
41371
|
+
if (bits.length > 0) tag = ` [${bits.join(" ")}]`;
|
|
41372
|
+
formatArgs = rest;
|
|
41373
|
+
}
|
|
41374
|
+
return `[smtp]${tag} ${(0, import_node_util2.format)(...formatArgs)}`;
|
|
41375
|
+
}
|
|
41317
41376
|
function buildInitialStatus(config) {
|
|
41318
41377
|
return {
|
|
41319
41378
|
enabled: true,
|