@essentialai/cogent-bridge-bundled 3.23.2 → 3.23.3
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/cogent-bridge.mjs +402 -308
- package/package.json +1 -1
package/cogent-bridge.mjs
CHANGED
|
@@ -1259,8 +1259,8 @@ var init_parseUtil = __esm({
|
|
|
1259
1259
|
init_errors();
|
|
1260
1260
|
init_en();
|
|
1261
1261
|
makeIssue = (params) => {
|
|
1262
|
-
const { data, path:
|
|
1263
|
-
const fullPath = [...
|
|
1262
|
+
const { data, path: path22, errorMaps, issueData } = params;
|
|
1263
|
+
const fullPath = [...path22, ...issueData.path || []];
|
|
1264
1264
|
const fullIssue = {
|
|
1265
1265
|
...issueData,
|
|
1266
1266
|
path: fullPath
|
|
@@ -1540,11 +1540,11 @@ var init_types = __esm({
|
|
|
1540
1540
|
init_parseUtil();
|
|
1541
1541
|
init_util();
|
|
1542
1542
|
ParseInputLazyPath = class {
|
|
1543
|
-
constructor(parent, value,
|
|
1543
|
+
constructor(parent, value, path22, key) {
|
|
1544
1544
|
this._cachedPath = [];
|
|
1545
1545
|
this.parent = parent;
|
|
1546
1546
|
this.data = value;
|
|
1547
|
-
this._path =
|
|
1547
|
+
this._path = path22;
|
|
1548
1548
|
this._key = key;
|
|
1549
1549
|
}
|
|
1550
1550
|
get path() {
|
|
@@ -4996,10 +4996,10 @@ function assignProp(target, prop, value) {
|
|
|
4996
4996
|
configurable: true
|
|
4997
4997
|
});
|
|
4998
4998
|
}
|
|
4999
|
-
function getElementAtPath(obj,
|
|
5000
|
-
if (!
|
|
4999
|
+
function getElementAtPath(obj, path22) {
|
|
5000
|
+
if (!path22)
|
|
5001
5001
|
return obj;
|
|
5002
|
-
return
|
|
5002
|
+
return path22.reduce((acc, key) => acc?.[key], obj);
|
|
5003
5003
|
}
|
|
5004
5004
|
function promiseAllObject(promisesObj) {
|
|
5005
5005
|
const keys = Object.keys(promisesObj);
|
|
@@ -5248,11 +5248,11 @@ function aborted(x, startIndex = 0) {
|
|
|
5248
5248
|
}
|
|
5249
5249
|
return false;
|
|
5250
5250
|
}
|
|
5251
|
-
function prefixIssues(
|
|
5251
|
+
function prefixIssues(path22, issues) {
|
|
5252
5252
|
return issues.map((iss) => {
|
|
5253
5253
|
var _a;
|
|
5254
5254
|
(_a = iss).path ?? (_a.path = []);
|
|
5255
|
-
iss.path.unshift(
|
|
5255
|
+
iss.path.unshift(path22);
|
|
5256
5256
|
return iss;
|
|
5257
5257
|
});
|
|
5258
5258
|
}
|
|
@@ -17058,8 +17058,8 @@ var require_utils = __commonJS({
|
|
|
17058
17058
|
}
|
|
17059
17059
|
return ind;
|
|
17060
17060
|
}
|
|
17061
|
-
function removeDotSegments(
|
|
17062
|
-
let input =
|
|
17061
|
+
function removeDotSegments(path22) {
|
|
17062
|
+
let input = path22;
|
|
17063
17063
|
const output = [];
|
|
17064
17064
|
let nextSlash = -1;
|
|
17065
17065
|
let len = 0;
|
|
@@ -17258,8 +17258,8 @@ var require_schemes = __commonJS({
|
|
|
17258
17258
|
wsComponent.secure = void 0;
|
|
17259
17259
|
}
|
|
17260
17260
|
if (wsComponent.resourceName) {
|
|
17261
|
-
const [
|
|
17262
|
-
wsComponent.path =
|
|
17261
|
+
const [path22, query] = wsComponent.resourceName.split("?");
|
|
17262
|
+
wsComponent.path = path22 && path22 !== "/" ? path22 : void 0;
|
|
17263
17263
|
wsComponent.query = query;
|
|
17264
17264
|
wsComponent.resourceName = void 0;
|
|
17265
17265
|
}
|
|
@@ -20612,12 +20612,12 @@ var require_dist = __commonJS({
|
|
|
20612
20612
|
throw new Error(`Unknown format "${name}"`);
|
|
20613
20613
|
return f;
|
|
20614
20614
|
};
|
|
20615
|
-
function addFormats(ajv, list,
|
|
20615
|
+
function addFormats(ajv, list, fs20, exportName) {
|
|
20616
20616
|
var _a;
|
|
20617
20617
|
var _b;
|
|
20618
20618
|
(_a = (_b = ajv.opts.code).formats) !== null && _a !== void 0 ? _a : _b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`;
|
|
20619
20619
|
for (const f of list)
|
|
20620
|
-
ajv.addFormat(f,
|
|
20620
|
+
ajv.addFormat(f, fs20[f]);
|
|
20621
20621
|
}
|
|
20622
20622
|
module.exports = exports = formatsPlugin;
|
|
20623
20623
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -21729,8 +21729,8 @@ var require_parseUtil = __commonJS({
|
|
|
21729
21729
|
var errors_js_1 = require_errors2();
|
|
21730
21730
|
var en_js_1 = __importDefault(require_en());
|
|
21731
21731
|
var makeIssue2 = (params) => {
|
|
21732
|
-
const { data, path:
|
|
21733
|
-
const fullPath = [...
|
|
21732
|
+
const { data, path: path22, errorMaps, issueData } = params;
|
|
21733
|
+
const fullPath = [...path22, ...issueData.path || []];
|
|
21734
21734
|
const fullIssue = {
|
|
21735
21735
|
...issueData,
|
|
21736
21736
|
path: fullPath
|
|
@@ -21884,11 +21884,11 @@ var require_types2 = __commonJS({
|
|
|
21884
21884
|
var parseUtil_js_1 = require_parseUtil();
|
|
21885
21885
|
var util_js_1 = require_util2();
|
|
21886
21886
|
var ParseInputLazyPath2 = class {
|
|
21887
|
-
constructor(parent, value,
|
|
21887
|
+
constructor(parent, value, path22, key) {
|
|
21888
21888
|
this._cachedPath = [];
|
|
21889
21889
|
this.parent = parent;
|
|
21890
21890
|
this.data = value;
|
|
21891
|
-
this._path =
|
|
21891
|
+
this._path = path22;
|
|
21892
21892
|
this._key = key;
|
|
21893
21893
|
}
|
|
21894
21894
|
get path() {
|
|
@@ -26389,8 +26389,8 @@ var init_stdio2 = __esm({
|
|
|
26389
26389
|
// src/constants.ts
|
|
26390
26390
|
import { createRequire } from "node:module";
|
|
26391
26391
|
function resolveVersion() {
|
|
26392
|
-
if ("3.23.
|
|
26393
|
-
return "3.23.
|
|
26392
|
+
if ("3.23.3") {
|
|
26393
|
+
return "3.23.3";
|
|
26394
26394
|
}
|
|
26395
26395
|
try {
|
|
26396
26396
|
const require2 = createRequire(import.meta.url);
|
|
@@ -27826,7 +27826,7 @@ var init_http_backend = __esm({
|
|
|
27826
27826
|
* in cloud mode we ignore it and use this.sessionId (the cloud session).
|
|
27827
27827
|
*/
|
|
27828
27828
|
async registerPeer(peerId, _sessionId, cwd, label, clientVersion, mode, _channelSessionId, capabilities, workspaceId, threadId, peerSecret) {
|
|
27829
|
-
const
|
|
27829
|
+
const path22 = PATHS.peers.replace(":sessionId", this.sessionId);
|
|
27830
27830
|
const body = {
|
|
27831
27831
|
peerId,
|
|
27832
27832
|
cwd,
|
|
@@ -27857,7 +27857,7 @@ var init_http_backend = __esm({
|
|
|
27857
27857
|
if (peerSecret !== void 0 && await relaySupports(this.http, "peer-ownership")) {
|
|
27858
27858
|
body.peerSecret = peerSecret;
|
|
27859
27859
|
}
|
|
27860
|
-
return this.http.post(
|
|
27860
|
+
return this.http.post(path22, body);
|
|
27861
27861
|
}
|
|
27862
27862
|
/**
|
|
27863
27863
|
* Deregister a peer from the cloud session.
|
|
@@ -27869,9 +27869,9 @@ var init_http_backend = __esm({
|
|
|
27869
27869
|
* local mail creds. A 404 (peer not found) resolves to `{ removed: false, ... }`, not a throw.
|
|
27870
27870
|
*/
|
|
27871
27871
|
async deregisterPeer(peerId) {
|
|
27872
|
-
const
|
|
27872
|
+
const path22 = PATHS.peer.replace(":sessionId", this.sessionId).replace(":peerId", peerId);
|
|
27873
27873
|
try {
|
|
27874
|
-
const headers = await this.http.delete(
|
|
27874
|
+
const headers = await this.http.delete(path22, {});
|
|
27875
27875
|
const mailboxDeprovisioned = headers.get(MAILBOX_DEPROVISIONED_HEADER) === "true";
|
|
27876
27876
|
return { removed: true, mailboxDeprovisioned };
|
|
27877
27877
|
} catch (err) {
|
|
@@ -27895,8 +27895,8 @@ var init_http_backend = __esm({
|
|
|
27895
27895
|
* GET /api/sessions/:sessionId/peers
|
|
27896
27896
|
*/
|
|
27897
27897
|
async listPeers() {
|
|
27898
|
-
const
|
|
27899
|
-
const result = await this.http.get(
|
|
27898
|
+
const path22 = PATHS.peers.replace(":sessionId", this.sessionId);
|
|
27899
|
+
const result = await this.http.get(path22);
|
|
27900
27900
|
return result.peers;
|
|
27901
27901
|
}
|
|
27902
27902
|
/**
|
|
@@ -27904,8 +27904,8 @@ var init_http_backend = __esm({
|
|
|
27904
27904
|
* Calls the lightweight heartbeat endpoint on the cloud relay server.
|
|
27905
27905
|
*/
|
|
27906
27906
|
async updateLastSeen(peerId) {
|
|
27907
|
-
const
|
|
27908
|
-
await this.http.post(
|
|
27907
|
+
const path22 = PATHS.heartbeat.replace(":sessionId", this.sessionId);
|
|
27908
|
+
await this.http.post(path22, { peerId });
|
|
27909
27909
|
}
|
|
27910
27910
|
/**
|
|
27911
27911
|
* Record a message in the cloud session.
|
|
@@ -27916,7 +27916,7 @@ var init_http_backend = __esm({
|
|
|
27916
27916
|
* the input record to construct a full MessageRecord.
|
|
27917
27917
|
*/
|
|
27918
27918
|
async recordMessage(record2) {
|
|
27919
|
-
const
|
|
27919
|
+
const path22 = PATHS.messages.replace(":sessionId", this.sessionId);
|
|
27920
27920
|
const body = {
|
|
27921
27921
|
fromPeerId: record2.fromPeerId,
|
|
27922
27922
|
toPeerId: record2.toPeerId,
|
|
@@ -27939,7 +27939,7 @@ var init_http_backend = __esm({
|
|
|
27939
27939
|
if (record2.attachments && record2.attachments.length > 0) {
|
|
27940
27940
|
body.attachments = record2.attachments;
|
|
27941
27941
|
}
|
|
27942
|
-
const resp = await this.http.post(
|
|
27942
|
+
const resp = await this.http.post(path22, body);
|
|
27943
27943
|
return {
|
|
27944
27944
|
...record2,
|
|
27945
27945
|
id: resp.id,
|
|
@@ -27953,7 +27953,7 @@ var init_http_backend = __esm({
|
|
|
27953
27953
|
* Supports optional peerId filter and limit (default 300).
|
|
27954
27954
|
*/
|
|
27955
27955
|
async getHistory(peerId, limit, includeRelayEchoes, metadataOnly, dedupInferredEchoes) {
|
|
27956
|
-
const
|
|
27956
|
+
const path22 = PATHS.messages.replace(":sessionId", this.sessionId);
|
|
27957
27957
|
const query = {};
|
|
27958
27958
|
if (peerId) {
|
|
27959
27959
|
query.peerId = peerId;
|
|
@@ -27968,7 +27968,7 @@ var init_http_backend = __esm({
|
|
|
27968
27968
|
if (dedupInferredEchoes) {
|
|
27969
27969
|
query.dedupInferredEchoes = "true";
|
|
27970
27970
|
}
|
|
27971
|
-
const result = await this.http.get(
|
|
27971
|
+
const result = await this.http.get(path22, query);
|
|
27972
27972
|
return result.messages;
|
|
27973
27973
|
}
|
|
27974
27974
|
/**
|
|
@@ -27979,12 +27979,12 @@ var init_http_backend = __esm({
|
|
|
27979
27979
|
* so that get-history shows the actual response (not null).
|
|
27980
27980
|
*/
|
|
27981
27981
|
async updateMessageResponse(messageId, response, durationMs, pending) {
|
|
27982
|
-
const
|
|
27982
|
+
const path22 = PATHS.message.replace(":sessionId", this.sessionId).replace(":messageId", messageId);
|
|
27983
27983
|
const body = { response, durationMs };
|
|
27984
27984
|
if (pending === true) {
|
|
27985
27985
|
body.pending = true;
|
|
27986
27986
|
}
|
|
27987
|
-
await this.http.patch(
|
|
27987
|
+
await this.http.patch(path22, body);
|
|
27988
27988
|
}
|
|
27989
27989
|
/**
|
|
27990
27990
|
* Validate a session.
|
|
@@ -28126,8 +28126,8 @@ var init_http_client = __esm({
|
|
|
28126
28126
|
* Perform an authenticated GET request.
|
|
28127
28127
|
* Appends query parameters to the URL if provided.
|
|
28128
28128
|
*/
|
|
28129
|
-
async get(
|
|
28130
|
-
const url = new URL(
|
|
28129
|
+
async get(path22, query) {
|
|
28130
|
+
const url = new URL(path22, this.baseUrl);
|
|
28131
28131
|
if (query) {
|
|
28132
28132
|
for (const [k, v] of Object.entries(query)) {
|
|
28133
28133
|
url.searchParams.set(k, v);
|
|
@@ -28142,8 +28142,8 @@ var init_http_client = __esm({
|
|
|
28142
28142
|
/**
|
|
28143
28143
|
* Perform an authenticated POST request with a JSON body.
|
|
28144
28144
|
*/
|
|
28145
|
-
async post(
|
|
28146
|
-
const url = new URL(
|
|
28145
|
+
async post(path22, body) {
|
|
28146
|
+
const url = new URL(path22, this.baseUrl);
|
|
28147
28147
|
const resp = await this.fetchWithTimeout(url, {
|
|
28148
28148
|
method: "POST",
|
|
28149
28149
|
headers: this.headers(),
|
|
@@ -28161,8 +28161,8 @@ var init_http_client = __esm({
|
|
|
28161
28161
|
* Perform an authenticated PATCH request with a JSON body.
|
|
28162
28162
|
* Used to update existing resources (e.g., message response fields).
|
|
28163
28163
|
*/
|
|
28164
|
-
async patch(
|
|
28165
|
-
const url = new URL(
|
|
28164
|
+
async patch(path22, body) {
|
|
28165
|
+
const url = new URL(path22, this.baseUrl);
|
|
28166
28166
|
const resp = await this.fetchWithTimeout(url, {
|
|
28167
28167
|
method: "PATCH",
|
|
28168
28168
|
headers: this.headers(),
|
|
@@ -28187,8 +28187,8 @@ var init_http_client = __esm({
|
|
|
28187
28187
|
* "Malformed JSON in request body" 400 from cogent-server <=3.1.2 when
|
|
28188
28188
|
* any client (including third-party tools) DELETEd a peer without a body.
|
|
28189
28189
|
*/
|
|
28190
|
-
async delete(
|
|
28191
|
-
const url = new URL(
|
|
28190
|
+
async delete(path22, body) {
|
|
28191
|
+
const url = new URL(path22, this.baseUrl);
|
|
28192
28192
|
const headers = {
|
|
28193
28193
|
"Authorization": `Bearer ${this.token}`
|
|
28194
28194
|
};
|
|
@@ -32393,14 +32393,14 @@ var init_ws_client = __esm({
|
|
|
32393
32393
|
if (this.pollTimer) return;
|
|
32394
32394
|
const poll = async () => {
|
|
32395
32395
|
try {
|
|
32396
|
-
const
|
|
32396
|
+
const path22 = `/api/sessions/${this.opts.sessionId}/poll`;
|
|
32397
32397
|
const query = {
|
|
32398
32398
|
peerId: this.opts.peerId
|
|
32399
32399
|
};
|
|
32400
32400
|
if (this.lastMessageId) {
|
|
32401
32401
|
query.lastMessageId = this.lastMessageId;
|
|
32402
32402
|
}
|
|
32403
|
-
const result = await this.opts.http.get(
|
|
32403
|
+
const result = await this.opts.http.get(path22, query);
|
|
32404
32404
|
if (result.messages && result.messages.length > 0) {
|
|
32405
32405
|
this.opts.onMessages(result.messages);
|
|
32406
32406
|
this.lastMessageId = result.messages[result.messages.length - 1].id;
|
|
@@ -33395,6 +33395,92 @@ var init_wake_inflight = __esm({
|
|
|
33395
33395
|
}
|
|
33396
33396
|
});
|
|
33397
33397
|
|
|
33398
|
+
// src/services/wake-claim.ts
|
|
33399
|
+
import crypto6 from "node:crypto";
|
|
33400
|
+
import fs15 from "node:fs";
|
|
33401
|
+
import os11 from "node:os";
|
|
33402
|
+
import path16 from "node:path";
|
|
33403
|
+
function hashCwd4(cwd) {
|
|
33404
|
+
return crypto6.createHash("sha256").update(path16.resolve(cwd)).digest("hex").slice(0, 16);
|
|
33405
|
+
}
|
|
33406
|
+
function wakeClaimPath(peerId, messageId, cwd = process.cwd()) {
|
|
33407
|
+
return path16.join(
|
|
33408
|
+
os11.homedir(),
|
|
33409
|
+
".cogent",
|
|
33410
|
+
"wake-claims",
|
|
33411
|
+
`${hashCwd4(cwd)}.${safe2(peerId)}.${safe2(messageId)}.json`
|
|
33412
|
+
);
|
|
33413
|
+
}
|
|
33414
|
+
function ttlMs2() {
|
|
33415
|
+
let timeout = 3e5;
|
|
33416
|
+
try {
|
|
33417
|
+
const c2 = getConfig()?.COGENT_TIMEOUT_MS;
|
|
33418
|
+
if (typeof c2 === "number" && Number.isFinite(c2) && c2 > 0) timeout = c2;
|
|
33419
|
+
} catch {
|
|
33420
|
+
}
|
|
33421
|
+
return Math.min(timeout * CLAIM_TIMEOUT_FACTOR, CLAIM_MAX_MS);
|
|
33422
|
+
}
|
|
33423
|
+
function holderAlive(pid) {
|
|
33424
|
+
if (typeof pid !== "number" || !Number.isInteger(pid) || pid <= 0) return false;
|
|
33425
|
+
if (pid === process.pid) return true;
|
|
33426
|
+
try {
|
|
33427
|
+
process.kill(pid, 0);
|
|
33428
|
+
return true;
|
|
33429
|
+
} catch (err) {
|
|
33430
|
+
return err?.code === "EPERM";
|
|
33431
|
+
}
|
|
33432
|
+
}
|
|
33433
|
+
function claimWake(peerId, messageId, cwd = process.cwd()) {
|
|
33434
|
+
const p = wakeClaimPath(peerId, messageId, cwd);
|
|
33435
|
+
const now = Date.now();
|
|
33436
|
+
const body = () => JSON.stringify({ pid: process.pid, startedAt: now, expiresAt: now + ttlMs2() });
|
|
33437
|
+
try {
|
|
33438
|
+
fs15.mkdirSync(path16.dirname(p), { recursive: true });
|
|
33439
|
+
try {
|
|
33440
|
+
fs15.writeFileSync(p, body(), { flag: "wx" });
|
|
33441
|
+
return true;
|
|
33442
|
+
} catch (err) {
|
|
33443
|
+
if (err?.code !== "EEXIST") throw err;
|
|
33444
|
+
}
|
|
33445
|
+
let held = null;
|
|
33446
|
+
try {
|
|
33447
|
+
held = JSON.parse(fs15.readFileSync(p, "utf-8"));
|
|
33448
|
+
} catch {
|
|
33449
|
+
held = null;
|
|
33450
|
+
}
|
|
33451
|
+
const expired = !held || typeof held.expiresAt !== "number" || held.expiresAt <= now;
|
|
33452
|
+
if (!held || expired || !holderAlive(held.pid)) {
|
|
33453
|
+
fs15.writeFileSync(p, body());
|
|
33454
|
+
logger.debug(`wake-claim: took over an abandoned claim for ${messageId}`);
|
|
33455
|
+
return true;
|
|
33456
|
+
}
|
|
33457
|
+
logger.info(
|
|
33458
|
+
`Auto-relay: SKIPPING wake for message ${messageId} \u2014 pid ${held.pid} in this cwd already has it. Another bridge process is registered as "${peerId}"; without this both would resume the same session and duplicate the work.`
|
|
33459
|
+
);
|
|
33460
|
+
return false;
|
|
33461
|
+
} catch (err) {
|
|
33462
|
+
logger.warn(`wake-claim: could not claim ${messageId} (${err.message}) \u2014 waking anyway`);
|
|
33463
|
+
return true;
|
|
33464
|
+
}
|
|
33465
|
+
}
|
|
33466
|
+
function releaseWake(peerId, messageId, cwd = process.cwd()) {
|
|
33467
|
+
try {
|
|
33468
|
+
fs15.unlinkSync(wakeClaimPath(peerId, messageId, cwd));
|
|
33469
|
+
} catch {
|
|
33470
|
+
}
|
|
33471
|
+
}
|
|
33472
|
+
var CLAIM_MAX_MS, CLAIM_TIMEOUT_FACTOR, safe2;
|
|
33473
|
+
var init_wake_claim = __esm({
|
|
33474
|
+
"src/services/wake-claim.ts"() {
|
|
33475
|
+
"use strict";
|
|
33476
|
+
init_config();
|
|
33477
|
+
init_logger();
|
|
33478
|
+
CLAIM_MAX_MS = 18e5;
|
|
33479
|
+
CLAIM_TIMEOUT_FACTOR = 3;
|
|
33480
|
+
safe2 = (s) => String(s).replace(/[^A-Za-z0-9._-]/g, "_");
|
|
33481
|
+
}
|
|
33482
|
+
});
|
|
33483
|
+
|
|
33398
33484
|
// src/services/auto-relay.ts
|
|
33399
33485
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
33400
33486
|
function buildStatusNotice(status, peerId, traceId) {
|
|
@@ -33534,6 +33620,7 @@ var init_auto_relay = __esm({
|
|
|
33534
33620
|
init_backend();
|
|
33535
33621
|
init_codex_cli();
|
|
33536
33622
|
init_wake_inflight();
|
|
33623
|
+
init_wake_claim();
|
|
33537
33624
|
init_logger();
|
|
33538
33625
|
init_npm_update_check();
|
|
33539
33626
|
RELAY_STATUS = {
|
|
@@ -33991,6 +34078,9 @@ var init_auto_relay = __esm({
|
|
|
33991
34078
|
}
|
|
33992
34079
|
}
|
|
33993
34080
|
if (this.localPeerId && !this.awarenessOnly.has(msg.id)) {
|
|
34081
|
+
if (!claimWake(this.localPeerId, msg.id, this.localCwd ?? process.cwd())) {
|
|
34082
|
+
return;
|
|
34083
|
+
}
|
|
33994
34084
|
markWakeInFlight(this.localPeerId, msg.id, msg.traceId);
|
|
33995
34085
|
}
|
|
33996
34086
|
if (this.processing) {
|
|
@@ -34028,10 +34118,14 @@ var init_auto_relay = __esm({
|
|
|
34028
34118
|
return;
|
|
34029
34119
|
}
|
|
34030
34120
|
const inflightPeer = this.localPeerId;
|
|
34121
|
+
const claimCwd = this.localCwd ?? process.cwd();
|
|
34031
34122
|
try {
|
|
34032
34123
|
await this._processMessage(msg);
|
|
34033
34124
|
} finally {
|
|
34034
|
-
if (inflightPeer)
|
|
34125
|
+
if (inflightPeer) {
|
|
34126
|
+
clearWakeInFlight(inflightPeer, msg.id);
|
|
34127
|
+
releaseWake(inflightPeer, msg.id, claimCwd);
|
|
34128
|
+
}
|
|
34035
34129
|
}
|
|
34036
34130
|
}
|
|
34037
34131
|
/**
|
|
@@ -34687,9 +34781,9 @@ __export(startup_exports, {
|
|
|
34687
34781
|
setInboxNotifier: () => setInboxNotifier,
|
|
34688
34782
|
triggerReRegistration: () => triggerReRegistration
|
|
34689
34783
|
});
|
|
34690
|
-
import
|
|
34691
|
-
import
|
|
34692
|
-
import
|
|
34784
|
+
import os12 from "node:os";
|
|
34785
|
+
import path17 from "node:path";
|
|
34786
|
+
import fs16 from "node:fs/promises";
|
|
34693
34787
|
import readline2 from "node:readline";
|
|
34694
34788
|
import { execFile as execFile5 } from "node:child_process";
|
|
34695
34789
|
import { promisify as promisify4 } from "node:util";
|
|
@@ -34707,7 +34801,7 @@ function bindInboxNotifier() {
|
|
|
34707
34801
|
}
|
|
34708
34802
|
async function loadPersistedConfig() {
|
|
34709
34803
|
try {
|
|
34710
|
-
const raw = await
|
|
34804
|
+
const raw = await fs16.readFile(PERSIST_PATH, "utf-8");
|
|
34711
34805
|
return JSON.parse(raw);
|
|
34712
34806
|
} catch {
|
|
34713
34807
|
return {};
|
|
@@ -34715,7 +34809,7 @@ async function loadPersistedConfig() {
|
|
|
34715
34809
|
}
|
|
34716
34810
|
async function savePersistedConfig(config2) {
|
|
34717
34811
|
try {
|
|
34718
|
-
await
|
|
34812
|
+
await fs16.writeFile(PERSIST_PATH, JSON.stringify(config2, null, 2) + "\n", "utf-8");
|
|
34719
34813
|
} catch (err) {
|
|
34720
34814
|
const msg = err instanceof Error ? err.message : String(err);
|
|
34721
34815
|
logger.warn(`Could not save config to ${PERSIST_PATH}: ${msg}`);
|
|
@@ -34750,11 +34844,11 @@ First run detected. Where should cogent-bridge store its data?
|
|
|
34750
34844
|
});
|
|
34751
34845
|
}
|
|
34752
34846
|
async function validateStateDir(statePath) {
|
|
34753
|
-
await
|
|
34754
|
-
const testFile =
|
|
34847
|
+
await fs16.mkdir(statePath, { recursive: true });
|
|
34848
|
+
const testFile = path17.join(statePath, ".write-test");
|
|
34755
34849
|
try {
|
|
34756
|
-
await
|
|
34757
|
-
await
|
|
34850
|
+
await fs16.writeFile(testFile, "test", "utf-8");
|
|
34851
|
+
await fs16.unlink(testFile);
|
|
34758
34852
|
} catch {
|
|
34759
34853
|
throw new BridgeError(
|
|
34760
34854
|
"STARTUP_FAILED" /* STARTUP_FAILED */,
|
|
@@ -34942,10 +35036,10 @@ async function runStartup() {
|
|
|
34942
35036
|
if (envStatePath) {
|
|
34943
35037
|
statePath = envStatePath;
|
|
34944
35038
|
} else {
|
|
34945
|
-
const defaultPath =
|
|
35039
|
+
const defaultPath = path17.join(os12.homedir(), ".cogent");
|
|
34946
35040
|
statePath = await firstRunPrompt(defaultPath);
|
|
34947
35041
|
}
|
|
34948
|
-
if (!envStatePath && statePath !==
|
|
35042
|
+
if (!envStatePath && statePath !== path17.join(os12.homedir(), ".cogent")) {
|
|
34949
35043
|
process.env.COGENT_STATE_PATH = statePath;
|
|
34950
35044
|
} else if (!envStatePath) {
|
|
34951
35045
|
process.env.COGENT_STATE_PATH = statePath;
|
|
@@ -35009,7 +35103,7 @@ async function runStartup() {
|
|
|
35009
35103
|
}
|
|
35010
35104
|
initLogger(
|
|
35011
35105
|
config2.COGENT_LOG_LEVEL,
|
|
35012
|
-
|
|
35106
|
+
path17.join(config2.COGENT_STATE_PATH, "logs")
|
|
35013
35107
|
);
|
|
35014
35108
|
if (isCloud && effectiveSessionId && effectiveToken) {
|
|
35015
35109
|
cloudInbox = new MessageInbox();
|
|
@@ -35071,7 +35165,7 @@ var init_startup = __esm({
|
|
|
35071
35165
|
init_auto_relay();
|
|
35072
35166
|
UUID_V4_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
35073
35167
|
execFileAsync3 = promisify4(execFile5);
|
|
35074
|
-
PERSIST_PATH =
|
|
35168
|
+
PERSIST_PATH = path17.join(os12.homedir(), ".cogent-config.json");
|
|
35075
35169
|
legacyWarnEmitted = false;
|
|
35076
35170
|
cloudWsClient = null;
|
|
35077
35171
|
cloudInbox = null;
|
|
@@ -35085,13 +35179,13 @@ var init_startup = __esm({
|
|
|
35085
35179
|
});
|
|
35086
35180
|
|
|
35087
35181
|
// src/cloud/mail-credential-store.ts
|
|
35088
|
-
import
|
|
35089
|
-
import
|
|
35090
|
-
import
|
|
35091
|
-
import
|
|
35182
|
+
import crypto7 from "node:crypto";
|
|
35183
|
+
import fs17 from "node:fs/promises";
|
|
35184
|
+
import path18 from "node:path";
|
|
35185
|
+
import os13 from "node:os";
|
|
35092
35186
|
function defaultMailCredentialPath(cwd = process.cwd()) {
|
|
35093
|
-
const hash =
|
|
35094
|
-
return
|
|
35187
|
+
const hash = crypto7.createHash("sha256").update(path18.resolve(cwd)).digest("hex").slice(0, 16);
|
|
35188
|
+
return path18.join(os13.homedir(), ".cogent", "mail-credentials", `${hash}.json`);
|
|
35095
35189
|
}
|
|
35096
35190
|
function resolveMailCredentialPath(credentialPath) {
|
|
35097
35191
|
if (credentialPath) return credentialPath;
|
|
@@ -35102,16 +35196,16 @@ function resolveMailCredentialPath(credentialPath) {
|
|
|
35102
35196
|
async function loadMailCredentials(credentialPath) {
|
|
35103
35197
|
const filePath = resolveMailCredentialPath(credentialPath);
|
|
35104
35198
|
try {
|
|
35105
|
-
return JSON.parse(await
|
|
35199
|
+
return JSON.parse(await fs17.readFile(filePath, "utf-8"));
|
|
35106
35200
|
} catch {
|
|
35107
35201
|
return null;
|
|
35108
35202
|
}
|
|
35109
35203
|
}
|
|
35110
35204
|
async function saveMailCredentials(creds, credentialPath) {
|
|
35111
35205
|
const filePath = resolveMailCredentialPath(credentialPath);
|
|
35112
|
-
await
|
|
35113
|
-
await
|
|
35114
|
-
await
|
|
35206
|
+
await fs17.mkdir(path18.dirname(filePath), { recursive: true, mode: 448 });
|
|
35207
|
+
await fs17.writeFile(filePath, JSON.stringify(creds, null, 2) + "\n", { encoding: "utf-8", mode: 384 });
|
|
35208
|
+
await fs17.chmod(filePath, 384);
|
|
35115
35209
|
}
|
|
35116
35210
|
async function persistProvisionedMailbox(mailbox, credentialPath) {
|
|
35117
35211
|
if (!mailbox?.address || !mailbox.password) return false;
|
|
@@ -35132,7 +35226,7 @@ async function persistProvisionedMailbox(mailbox, credentialPath) {
|
|
|
35132
35226
|
async function clearMailCredentials(credentialPath) {
|
|
35133
35227
|
const filePath = resolveMailCredentialPath(credentialPath);
|
|
35134
35228
|
try {
|
|
35135
|
-
await
|
|
35229
|
+
await fs17.unlink(filePath);
|
|
35136
35230
|
} catch (err) {
|
|
35137
35231
|
if (err.code !== "ENOENT") throw err;
|
|
35138
35232
|
}
|
|
@@ -35147,7 +35241,7 @@ var init_mail_credential_store = __esm({
|
|
|
35147
35241
|
});
|
|
35148
35242
|
|
|
35149
35243
|
// src/tools/register-peer.ts
|
|
35150
|
-
import
|
|
35244
|
+
import crypto8 from "node:crypto";
|
|
35151
35245
|
function unresolvedSessionReason(r) {
|
|
35152
35246
|
if (r.sessionId) return null;
|
|
35153
35247
|
return r.candidateCount === 0 ? "no-candidates" : "ambiguous";
|
|
@@ -35213,7 +35307,7 @@ function registerRegisterPeerTool(server) {
|
|
|
35213
35307
|
}
|
|
35214
35308
|
}
|
|
35215
35309
|
if (!cloudSessionId) {
|
|
35216
|
-
autoSecret =
|
|
35310
|
+
autoSecret = crypto8.randomBytes(16).toString("hex");
|
|
35217
35311
|
const resp = await fetch(
|
|
35218
35312
|
`${endpoint}/api/sessions`,
|
|
35219
35313
|
{
|
|
@@ -36595,7 +36689,7 @@ var init_wake_log2 = __esm({
|
|
|
36595
36689
|
});
|
|
36596
36690
|
|
|
36597
36691
|
// src/tools/create-session.ts
|
|
36598
|
-
import
|
|
36692
|
+
import crypto9 from "node:crypto";
|
|
36599
36693
|
function registerCreateSessionTool(server) {
|
|
36600
36694
|
server.registerTool(
|
|
36601
36695
|
"cogent_create_session",
|
|
@@ -36626,7 +36720,7 @@ function registerCreateSessionTool(server) {
|
|
|
36626
36720
|
)
|
|
36627
36721
|
);
|
|
36628
36722
|
}
|
|
36629
|
-
const sessionSecret = secret ??
|
|
36723
|
+
const sessionSecret = secret ?? crypto9.randomBytes(16).toString("hex");
|
|
36630
36724
|
const resp = await fetch(
|
|
36631
36725
|
`${config2.COGENT_ENDPOINT}/api/sessions`,
|
|
36632
36726
|
{
|
|
@@ -37084,8 +37178,8 @@ var require_cookies = __commonJS({
|
|
|
37084
37178
|
if (urlparts.hostname !== cookie.domain && (cookie.domain.charAt(0) !== "." || ("." + urlparts.hostname).substr(-cookie.domain.length) !== cookie.domain)) {
|
|
37085
37179
|
return false;
|
|
37086
37180
|
}
|
|
37087
|
-
let
|
|
37088
|
-
if (
|
|
37181
|
+
let path22 = this.getPath(urlparts.pathname);
|
|
37182
|
+
if (path22.substr(0, cookie.path.length) !== cookie.path) {
|
|
37089
37183
|
return false;
|
|
37090
37184
|
}
|
|
37091
37185
|
if (cookie.secure && urlparts.protocol !== "https:") {
|
|
@@ -37145,16 +37239,16 @@ var require_cookies = __commonJS({
|
|
|
37145
37239
|
* @returns {String} Normalized path
|
|
37146
37240
|
*/
|
|
37147
37241
|
getPath(pathname) {
|
|
37148
|
-
let
|
|
37149
|
-
|
|
37150
|
-
|
|
37151
|
-
if (
|
|
37152
|
-
|
|
37242
|
+
let path22 = (pathname || "/").split("/");
|
|
37243
|
+
path22.pop();
|
|
37244
|
+
path22 = path22.join("/").trim();
|
|
37245
|
+
if (path22.charAt(0) !== "/") {
|
|
37246
|
+
path22 = "/" + path22;
|
|
37153
37247
|
}
|
|
37154
|
-
if (
|
|
37155
|
-
|
|
37248
|
+
if (path22.substr(-1) !== "/") {
|
|
37249
|
+
path22 += "/";
|
|
37156
37250
|
}
|
|
37157
|
-
return
|
|
37251
|
+
return path22;
|
|
37158
37252
|
}
|
|
37159
37253
|
};
|
|
37160
37254
|
module.exports = Cookies;
|
|
@@ -37455,15 +37549,15 @@ var require_shared = __commonJS({
|
|
|
37455
37549
|
"use strict";
|
|
37456
37550
|
var urllib = __require("url");
|
|
37457
37551
|
var util2 = __require("util");
|
|
37458
|
-
var
|
|
37552
|
+
var fs20 = __require("fs");
|
|
37459
37553
|
var nmfetch = require_fetch();
|
|
37460
37554
|
var dns = __require("dns");
|
|
37461
37555
|
var net = __require("net");
|
|
37462
|
-
var
|
|
37556
|
+
var os15 = __require("os");
|
|
37463
37557
|
var DNS_TTL = 5 * 60 * 1e3;
|
|
37464
37558
|
var networkInterfaces;
|
|
37465
37559
|
try {
|
|
37466
|
-
networkInterfaces =
|
|
37560
|
+
networkInterfaces = os15.networkInterfaces();
|
|
37467
37561
|
} catch (err) {
|
|
37468
37562
|
}
|
|
37469
37563
|
module.exports.networkInterfaces = networkInterfaces;
|
|
@@ -37841,7 +37935,7 @@ var require_shared = __commonJS({
|
|
|
37841
37935
|
}
|
|
37842
37936
|
return callback(null, parsedDataUri.data);
|
|
37843
37937
|
} else if (content.path) {
|
|
37844
|
-
return resolveStream(
|
|
37938
|
+
return resolveStream(fs20.createReadStream(content.path), callback);
|
|
37845
37939
|
}
|
|
37846
37940
|
}
|
|
37847
37941
|
if (typeof data[key].content === "string" && !["utf8", "usascii", "ascii"].includes(encoding)) {
|
|
@@ -37965,7 +38059,7 @@ var require_shared = __commonJS({
|
|
|
37965
38059
|
var require_mime_types = __commonJS({
|
|
37966
38060
|
"node_modules/nodemailer/lib/mime-funcs/mime-types.js"(exports, module) {
|
|
37967
38061
|
"use strict";
|
|
37968
|
-
var
|
|
38062
|
+
var path22 = __require("path");
|
|
37969
38063
|
var defaultMimeType = "application/octet-stream";
|
|
37970
38064
|
var defaultExtension = "bin";
|
|
37971
38065
|
var mimeTypes = /* @__PURE__ */ new Map([
|
|
@@ -40023,7 +40117,7 @@ var require_mime_types = __commonJS({
|
|
|
40023
40117
|
if (!filename) {
|
|
40024
40118
|
return defaultMimeType;
|
|
40025
40119
|
}
|
|
40026
|
-
let parsed =
|
|
40120
|
+
let parsed = path22.parse(filename);
|
|
40027
40121
|
let extension = (parsed.ext.substr(1) || parsed.name || "").split("?").shift().trim().toLowerCase();
|
|
40028
40122
|
let value = defaultMimeType;
|
|
40029
40123
|
if (extensions.has(extension)) {
|
|
@@ -41424,8 +41518,8 @@ var require_le_unix = __commonJS({
|
|
|
41424
41518
|
var require_mime_node = __commonJS({
|
|
41425
41519
|
"node_modules/nodemailer/lib/mime-node/index.js"(exports, module) {
|
|
41426
41520
|
"use strict";
|
|
41427
|
-
var
|
|
41428
|
-
var
|
|
41521
|
+
var crypto10 = __require("crypto");
|
|
41522
|
+
var fs20 = __require("fs");
|
|
41429
41523
|
var punycode = require_punycode();
|
|
41430
41524
|
var PassThrough = __require("stream").PassThrough;
|
|
41431
41525
|
var shared = require_shared();
|
|
@@ -41441,7 +41535,7 @@ var require_mime_node = __commonJS({
|
|
|
41441
41535
|
constructor(contentType, options) {
|
|
41442
41536
|
this.nodeCounter = 0;
|
|
41443
41537
|
options = options || {};
|
|
41444
|
-
this.baseBoundary = options.baseBoundary ||
|
|
41538
|
+
this.baseBoundary = options.baseBoundary || crypto10.randomBytes(8).toString("hex");
|
|
41445
41539
|
this.boundaryPrefix = options.boundaryPrefix || "--_NmP";
|
|
41446
41540
|
this.disableFileAccess = !!options.disableFileAccess;
|
|
41447
41541
|
this.disableUrlAccess = !!options.disableUrlAccess;
|
|
@@ -42140,7 +42234,7 @@ var require_mime_node = __commonJS({
|
|
|
42140
42234
|
setImmediate(() => contentStream.emit("error", new Error("File access rejected for " + content.path)));
|
|
42141
42235
|
return contentStream;
|
|
42142
42236
|
}
|
|
42143
|
-
return
|
|
42237
|
+
return fs20.createReadStream(content.path);
|
|
42144
42238
|
} else if (content && typeof content.href === "string") {
|
|
42145
42239
|
if (this.disableUrlAccess) {
|
|
42146
42240
|
contentStream = new PassThrough();
|
|
@@ -42384,8 +42478,8 @@ var require_mime_node = __commonJS({
|
|
|
42384
42478
|
_generateMessageId() {
|
|
42385
42479
|
return "<" + [2, 2, 2, 6].reduce(
|
|
42386
42480
|
// crux to generate UUID-like random strings
|
|
42387
|
-
(prev, len) => prev + "-" +
|
|
42388
|
-
|
|
42481
|
+
(prev, len) => prev + "-" + crypto10.randomBytes(len).toString("hex"),
|
|
42482
|
+
crypto10.randomBytes(4).toString("hex")
|
|
42389
42483
|
) + "@" + // try to use the domain of the FROM address or fallback to server hostname
|
|
42390
42484
|
(this.getEnvelope().from || this.hostname || "localhost").split("@").pop() + ">";
|
|
42391
42485
|
}
|
|
@@ -42976,14 +43070,14 @@ var require_relaxed_body = __commonJS({
|
|
|
42976
43070
|
"node_modules/nodemailer/lib/dkim/relaxed-body.js"(exports, module) {
|
|
42977
43071
|
"use strict";
|
|
42978
43072
|
var Transform = __require("stream").Transform;
|
|
42979
|
-
var
|
|
43073
|
+
var crypto10 = __require("crypto");
|
|
42980
43074
|
var RelaxedBody = class extends Transform {
|
|
42981
43075
|
constructor(options) {
|
|
42982
43076
|
super();
|
|
42983
43077
|
options = options || {};
|
|
42984
43078
|
this.chunkBuffer = [];
|
|
42985
43079
|
this.chunkBufferLen = 0;
|
|
42986
|
-
this.bodyHash =
|
|
43080
|
+
this.bodyHash = crypto10.createHash(options.hashAlgo || "sha1");
|
|
42987
43081
|
this.remainder = "";
|
|
42988
43082
|
this.byteLength = 0;
|
|
42989
43083
|
this.debug = options.debug;
|
|
@@ -43086,7 +43180,7 @@ var require_sign = __commonJS({
|
|
|
43086
43180
|
"use strict";
|
|
43087
43181
|
var punycode = require_punycode();
|
|
43088
43182
|
var mimeFuncs = require_mime_funcs();
|
|
43089
|
-
var
|
|
43183
|
+
var crypto10 = __require("crypto");
|
|
43090
43184
|
module.exports = (headers, hashAlgo, bodyHash, options) => {
|
|
43091
43185
|
options = options || {};
|
|
43092
43186
|
let defaultFieldNames = "From:Sender:Reply-To:Subject:Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive";
|
|
@@ -43095,7 +43189,7 @@ var require_sign = __commonJS({
|
|
|
43095
43189
|
let dkimHeader = generateDKIMHeader(options.domainName, options.keySelector, canonicalizedHeaderData.fieldNames, hashAlgo, bodyHash);
|
|
43096
43190
|
let signer, signature;
|
|
43097
43191
|
canonicalizedHeaderData.headers += "dkim-signature:" + relaxedHeaderLine(dkimHeader);
|
|
43098
|
-
signer =
|
|
43192
|
+
signer = crypto10.createSign(("rsa-" + hashAlgo).toUpperCase());
|
|
43099
43193
|
signer.update(canonicalizedHeaderData.headers);
|
|
43100
43194
|
try {
|
|
43101
43195
|
signature = signer.sign(options.privateKey, "base64");
|
|
@@ -43161,9 +43255,9 @@ var require_dkim = __commonJS({
|
|
|
43161
43255
|
var RelaxedBody = require_relaxed_body();
|
|
43162
43256
|
var sign = require_sign();
|
|
43163
43257
|
var PassThrough = __require("stream").PassThrough;
|
|
43164
|
-
var
|
|
43165
|
-
var
|
|
43166
|
-
var
|
|
43258
|
+
var fs20 = __require("fs");
|
|
43259
|
+
var path22 = __require("path");
|
|
43260
|
+
var crypto10 = __require("crypto");
|
|
43167
43261
|
var DKIM_ALGO = "sha256";
|
|
43168
43262
|
var MAX_MESSAGE_SIZE = 128 * 1024;
|
|
43169
43263
|
var DKIMSigner = class {
|
|
@@ -43176,7 +43270,7 @@ var require_dkim = __commonJS({
|
|
|
43176
43270
|
this.chunks = [];
|
|
43177
43271
|
this.chunklen = 0;
|
|
43178
43272
|
this.readPos = 0;
|
|
43179
|
-
this.cachePath = this.cacheDir ?
|
|
43273
|
+
this.cachePath = this.cacheDir ? path22.join(this.cacheDir, "message." + Date.now() + "-" + crypto10.randomBytes(14).toString("hex")) : false;
|
|
43180
43274
|
this.cache = false;
|
|
43181
43275
|
this.headers = false;
|
|
43182
43276
|
this.bodyHash = false;
|
|
@@ -43196,10 +43290,10 @@ var require_dkim = __commonJS({
|
|
|
43196
43290
|
if (!this.cache || !this.cachePath) {
|
|
43197
43291
|
return;
|
|
43198
43292
|
}
|
|
43199
|
-
|
|
43293
|
+
fs20.unlink(this.cachePath, () => false);
|
|
43200
43294
|
}
|
|
43201
43295
|
createReadCache() {
|
|
43202
|
-
this.cache =
|
|
43296
|
+
this.cache = fs20.createReadStream(this.cachePath);
|
|
43203
43297
|
this.cache.once("error", (err) => {
|
|
43204
43298
|
this.cleanup();
|
|
43205
43299
|
this.output.emit("error", err);
|
|
@@ -43255,7 +43349,7 @@ var require_dkim = __commonJS({
|
|
|
43255
43349
|
}
|
|
43256
43350
|
createWriteCache() {
|
|
43257
43351
|
this.output.usingCache = true;
|
|
43258
|
-
this.cache =
|
|
43352
|
+
this.cache = fs20.createWriteStream(this.cachePath);
|
|
43259
43353
|
this.cache.once("error", (err) => {
|
|
43260
43354
|
this.cleanup();
|
|
43261
43355
|
this.relaxedBody.unpipe(this.cache);
|
|
@@ -43732,7 +43826,7 @@ var require_mailer = __commonJS({
|
|
|
43732
43826
|
var MailMessage = require_mail_message();
|
|
43733
43827
|
var net = __require("net");
|
|
43734
43828
|
var dns = __require("dns");
|
|
43735
|
-
var
|
|
43829
|
+
var crypto10 = __require("crypto");
|
|
43736
43830
|
var Mail = class extends EventEmitter {
|
|
43737
43831
|
constructor(transporter, options, defaults) {
|
|
43738
43832
|
super();
|
|
@@ -44056,7 +44150,7 @@ var require_mailer = __commonJS({
|
|
|
44056
44150
|
}
|
|
44057
44151
|
let cidCounter = 0;
|
|
44058
44152
|
html = (html || "").toString().replace(/(<img\b[^<>]{0,1024} src\s{0,20}=[\s"']{0,20})(data:([^;]+);[^"'>\s]+)/gi, (match, prefix, dataUri, mimeType) => {
|
|
44059
|
-
let cid =
|
|
44153
|
+
let cid = crypto10.randomBytes(10).toString("hex") + "@localhost";
|
|
44060
44154
|
if (!mail.data.attachments) {
|
|
44061
44155
|
mail.data.attachments = [];
|
|
44062
44156
|
}
|
|
@@ -44182,8 +44276,8 @@ var require_smtp_connection = __commonJS({
|
|
|
44182
44276
|
var EventEmitter = __require("events").EventEmitter;
|
|
44183
44277
|
var net = __require("net");
|
|
44184
44278
|
var tls = __require("tls");
|
|
44185
|
-
var
|
|
44186
|
-
var
|
|
44279
|
+
var os15 = __require("os");
|
|
44280
|
+
var crypto10 = __require("crypto");
|
|
44187
44281
|
var DataStream = require_data_stream();
|
|
44188
44282
|
var PassThrough = __require("stream").PassThrough;
|
|
44189
44283
|
var shared = require_shared();
|
|
@@ -44194,7 +44288,7 @@ var require_smtp_connection = __commonJS({
|
|
|
44194
44288
|
var SMTPConnection = class extends EventEmitter {
|
|
44195
44289
|
constructor(options) {
|
|
44196
44290
|
super(options);
|
|
44197
|
-
this.id =
|
|
44291
|
+
this.id = crypto10.randomBytes(8).toString("base64").replace(/\W/g, "");
|
|
44198
44292
|
this.stage = "init";
|
|
44199
44293
|
this.options = options || {};
|
|
44200
44294
|
this.secureConnection = !!this.options.secure;
|
|
@@ -45287,7 +45381,7 @@ var require_smtp_connection = __commonJS({
|
|
|
45287
45381
|
} else {
|
|
45288
45382
|
challengeString = challengeMatch[1];
|
|
45289
45383
|
}
|
|
45290
|
-
let base64decoded = Buffer.from(challengeString, "base64").toString("ascii"), hmacMD5 =
|
|
45384
|
+
let base64decoded = Buffer.from(challengeString, "base64").toString("ascii"), hmacMD5 = crypto10.createHmac("md5", this._auth.credentials.pass);
|
|
45291
45385
|
hmacMD5.update(base64decoded);
|
|
45292
45386
|
let prepended = this._auth.credentials.user + " " + hmacMD5.digest("hex");
|
|
45293
45387
|
this._responseActions.push((str2) => {
|
|
@@ -45575,7 +45669,7 @@ var require_smtp_connection = __commonJS({
|
|
|
45575
45669
|
_getHostname() {
|
|
45576
45670
|
let defaultHostname;
|
|
45577
45671
|
try {
|
|
45578
|
-
defaultHostname =
|
|
45672
|
+
defaultHostname = os15.hostname() || "";
|
|
45579
45673
|
} catch (err) {
|
|
45580
45674
|
defaultHostname = "localhost";
|
|
45581
45675
|
}
|
|
@@ -45598,7 +45692,7 @@ var require_xoauth2 = __commonJS({
|
|
|
45598
45692
|
"use strict";
|
|
45599
45693
|
var Stream = __require("stream").Stream;
|
|
45600
45694
|
var nmfetch = require_fetch();
|
|
45601
|
-
var
|
|
45695
|
+
var crypto10 = __require("crypto");
|
|
45602
45696
|
var shared = require_shared();
|
|
45603
45697
|
var XOAuth2 = class extends Stream {
|
|
45604
45698
|
constructor(options, logger2) {
|
|
@@ -45889,7 +45983,7 @@ var require_xoauth2 = __commonJS({
|
|
|
45889
45983
|
*/
|
|
45890
45984
|
jwtSignRS256(payload) {
|
|
45891
45985
|
payload = ['{"alg":"RS256","typ":"JWT"}', JSON.stringify(payload)].map((val) => this.toBase64URL(val)).join(".");
|
|
45892
|
-
let signature =
|
|
45986
|
+
let signature = crypto10.createSign("RSA-SHA256").update(payload).sign(this.options.privateKey);
|
|
45893
45987
|
return payload + "." + this.toBase64URL(signature);
|
|
45894
45988
|
}
|
|
45895
45989
|
};
|
|
@@ -48144,13 +48238,13 @@ var require_nodemailer = __commonJS({
|
|
|
48144
48238
|
});
|
|
48145
48239
|
|
|
48146
48240
|
// src/mail/mail-sender.ts
|
|
48147
|
-
import
|
|
48148
|
-
import
|
|
48241
|
+
import fs18 from "node:fs/promises";
|
|
48242
|
+
import path19 from "node:path";
|
|
48149
48243
|
async function buildAndSendMail(sender, creds, params) {
|
|
48150
48244
|
const attachments = [];
|
|
48151
48245
|
for (const p of params.attachmentPaths ?? []) {
|
|
48152
|
-
const content = await
|
|
48153
|
-
attachments.push({ filename:
|
|
48246
|
+
const content = await fs18.readFile(p);
|
|
48247
|
+
attachments.push({ filename: path19.basename(p), content });
|
|
48154
48248
|
}
|
|
48155
48249
|
const { messageId } = await sender.send({
|
|
48156
48250
|
from: creds.address,
|
|
@@ -48539,8 +48633,8 @@ var require_req = __commonJS({
|
|
|
48539
48633
|
if (req.originalUrl) {
|
|
48540
48634
|
_req.url = req.originalUrl;
|
|
48541
48635
|
} else {
|
|
48542
|
-
const
|
|
48543
|
-
_req.url = typeof
|
|
48636
|
+
const path22 = req.path;
|
|
48637
|
+
_req.url = typeof path22 === "string" ? path22 : req.url ? req.url.path || req.url : void 0;
|
|
48544
48638
|
}
|
|
48545
48639
|
if (req.query) {
|
|
48546
48640
|
_req.query = req.query;
|
|
@@ -48705,14 +48799,14 @@ var require_redact = __commonJS({
|
|
|
48705
48799
|
}
|
|
48706
48800
|
return obj;
|
|
48707
48801
|
}
|
|
48708
|
-
function parsePath(
|
|
48802
|
+
function parsePath(path22) {
|
|
48709
48803
|
const parts = [];
|
|
48710
48804
|
let current = "";
|
|
48711
48805
|
let inBrackets = false;
|
|
48712
48806
|
let inQuotes = false;
|
|
48713
48807
|
let quoteChar = "";
|
|
48714
|
-
for (let i = 0; i <
|
|
48715
|
-
const char =
|
|
48808
|
+
for (let i = 0; i < path22.length; i++) {
|
|
48809
|
+
const char = path22[i];
|
|
48716
48810
|
if (!inBrackets && char === ".") {
|
|
48717
48811
|
if (current) {
|
|
48718
48812
|
parts.push(current);
|
|
@@ -48843,10 +48937,10 @@ var require_redact = __commonJS({
|
|
|
48843
48937
|
return current;
|
|
48844
48938
|
}
|
|
48845
48939
|
function redactPaths(obj, paths, censor, remove = false) {
|
|
48846
|
-
for (const
|
|
48847
|
-
const parts = parsePath(
|
|
48940
|
+
for (const path22 of paths) {
|
|
48941
|
+
const parts = parsePath(path22);
|
|
48848
48942
|
if (parts.includes("*")) {
|
|
48849
|
-
redactWildcardPath(obj, parts, censor,
|
|
48943
|
+
redactWildcardPath(obj, parts, censor, path22, remove);
|
|
48850
48944
|
} else {
|
|
48851
48945
|
if (remove) {
|
|
48852
48946
|
removeKey(obj, parts);
|
|
@@ -48931,8 +49025,8 @@ var require_redact = __commonJS({
|
|
|
48931
49025
|
}
|
|
48932
49026
|
} else {
|
|
48933
49027
|
if (afterWildcard.includes("*")) {
|
|
48934
|
-
const wrappedCensor = typeof censor === "function" ? (value,
|
|
48935
|
-
const fullPath = [...pathArray.slice(0, pathLength), ...
|
|
49028
|
+
const wrappedCensor = typeof censor === "function" ? (value, path22) => {
|
|
49029
|
+
const fullPath = [...pathArray.slice(0, pathLength), ...path22];
|
|
48936
49030
|
return censor(value, fullPath);
|
|
48937
49031
|
} : censor;
|
|
48938
49032
|
redactWildcardPath(current, afterWildcard, wrappedCensor, originalPath, remove);
|
|
@@ -48967,8 +49061,8 @@ var require_redact = __commonJS({
|
|
|
48967
49061
|
return null;
|
|
48968
49062
|
}
|
|
48969
49063
|
const pathStructure = /* @__PURE__ */ new Map();
|
|
48970
|
-
for (const
|
|
48971
|
-
const parts = parsePath(
|
|
49064
|
+
for (const path22 of pathsToClone) {
|
|
49065
|
+
const parts = parsePath(path22);
|
|
48972
49066
|
let current = pathStructure;
|
|
48973
49067
|
for (let i = 0; i < parts.length; i++) {
|
|
48974
49068
|
const part = parts[i];
|
|
@@ -49020,24 +49114,24 @@ var require_redact = __commonJS({
|
|
|
49020
49114
|
}
|
|
49021
49115
|
return cloneSelectively(obj, pathStructure);
|
|
49022
49116
|
}
|
|
49023
|
-
function validatePath(
|
|
49024
|
-
if (typeof
|
|
49117
|
+
function validatePath(path22) {
|
|
49118
|
+
if (typeof path22 !== "string") {
|
|
49025
49119
|
throw new Error("Paths must be (non-empty) strings");
|
|
49026
49120
|
}
|
|
49027
|
-
if (
|
|
49121
|
+
if (path22 === "") {
|
|
49028
49122
|
throw new Error("Invalid redaction path ()");
|
|
49029
49123
|
}
|
|
49030
|
-
if (
|
|
49031
|
-
throw new Error(`Invalid redaction path (${
|
|
49124
|
+
if (path22.includes("..")) {
|
|
49125
|
+
throw new Error(`Invalid redaction path (${path22})`);
|
|
49032
49126
|
}
|
|
49033
|
-
if (
|
|
49034
|
-
throw new Error(`Invalid redaction path (${
|
|
49127
|
+
if (path22.includes(",")) {
|
|
49128
|
+
throw new Error(`Invalid redaction path (${path22})`);
|
|
49035
49129
|
}
|
|
49036
49130
|
let bracketCount = 0;
|
|
49037
49131
|
let inQuotes = false;
|
|
49038
49132
|
let quoteChar = "";
|
|
49039
|
-
for (let i = 0; i <
|
|
49040
|
-
const char =
|
|
49133
|
+
for (let i = 0; i < path22.length; i++) {
|
|
49134
|
+
const char = path22[i];
|
|
49041
49135
|
if ((char === '"' || char === "'") && bracketCount > 0) {
|
|
49042
49136
|
if (!inQuotes) {
|
|
49043
49137
|
inQuotes = true;
|
|
@@ -49051,20 +49145,20 @@ var require_redact = __commonJS({
|
|
|
49051
49145
|
} else if (char === "]" && !inQuotes) {
|
|
49052
49146
|
bracketCount--;
|
|
49053
49147
|
if (bracketCount < 0) {
|
|
49054
|
-
throw new Error(`Invalid redaction path (${
|
|
49148
|
+
throw new Error(`Invalid redaction path (${path22})`);
|
|
49055
49149
|
}
|
|
49056
49150
|
}
|
|
49057
49151
|
}
|
|
49058
49152
|
if (bracketCount !== 0) {
|
|
49059
|
-
throw new Error(`Invalid redaction path (${
|
|
49153
|
+
throw new Error(`Invalid redaction path (${path22})`);
|
|
49060
49154
|
}
|
|
49061
49155
|
}
|
|
49062
49156
|
function validatePaths(paths) {
|
|
49063
49157
|
if (!Array.isArray(paths)) {
|
|
49064
49158
|
throw new TypeError("paths must be an array");
|
|
49065
49159
|
}
|
|
49066
|
-
for (const
|
|
49067
|
-
validatePath(
|
|
49160
|
+
for (const path22 of paths) {
|
|
49161
|
+
validatePath(path22);
|
|
49068
49162
|
}
|
|
49069
49163
|
}
|
|
49070
49164
|
function slowRedact(options = {}) {
|
|
@@ -49232,8 +49326,8 @@ var require_redaction = __commonJS({
|
|
|
49232
49326
|
if (shape[k] === null) {
|
|
49233
49327
|
o[k] = (value) => topCensor(value, [k]);
|
|
49234
49328
|
} else {
|
|
49235
|
-
const wrappedCensor = typeof censor === "function" ? (value,
|
|
49236
|
-
return censor(value, [k, ...
|
|
49329
|
+
const wrappedCensor = typeof censor === "function" ? (value, path22) => {
|
|
49330
|
+
return censor(value, [k, ...path22]);
|
|
49237
49331
|
} : censor;
|
|
49238
49332
|
o[k] = Redact({
|
|
49239
49333
|
paths: shape[k],
|
|
@@ -49451,10 +49545,10 @@ var require_atomic_sleep = __commonJS({
|
|
|
49451
49545
|
var require_sonic_boom = __commonJS({
|
|
49452
49546
|
"node_modules/sonic-boom/index.js"(exports, module) {
|
|
49453
49547
|
"use strict";
|
|
49454
|
-
var
|
|
49548
|
+
var fs20 = __require("fs");
|
|
49455
49549
|
var EventEmitter = __require("events");
|
|
49456
49550
|
var inherits = __require("util").inherits;
|
|
49457
|
-
var
|
|
49551
|
+
var path22 = __require("path");
|
|
49458
49552
|
var sleep3 = require_atomic_sleep();
|
|
49459
49553
|
var assert2 = __require("assert");
|
|
49460
49554
|
var BUSY_WRITE_TIMEOUT = 100;
|
|
@@ -49508,20 +49602,20 @@ var require_sonic_boom = __commonJS({
|
|
|
49508
49602
|
const mode = sonic.mode;
|
|
49509
49603
|
if (sonic.sync) {
|
|
49510
49604
|
try {
|
|
49511
|
-
if (sonic.mkdir)
|
|
49512
|
-
const fd =
|
|
49605
|
+
if (sonic.mkdir) fs20.mkdirSync(path22.dirname(file), { recursive: true });
|
|
49606
|
+
const fd = fs20.openSync(file, flags, mode);
|
|
49513
49607
|
fileOpened(null, fd);
|
|
49514
49608
|
} catch (err) {
|
|
49515
49609
|
fileOpened(err);
|
|
49516
49610
|
throw err;
|
|
49517
49611
|
}
|
|
49518
49612
|
} else if (sonic.mkdir) {
|
|
49519
|
-
|
|
49613
|
+
fs20.mkdir(path22.dirname(file), { recursive: true }, (err) => {
|
|
49520
49614
|
if (err) return fileOpened(err);
|
|
49521
|
-
|
|
49615
|
+
fs20.open(file, flags, mode, fileOpened);
|
|
49522
49616
|
});
|
|
49523
49617
|
} else {
|
|
49524
|
-
|
|
49618
|
+
fs20.open(file, flags, mode, fileOpened);
|
|
49525
49619
|
}
|
|
49526
49620
|
}
|
|
49527
49621
|
function SonicBoom(opts) {
|
|
@@ -49562,8 +49656,8 @@ var require_sonic_boom = __commonJS({
|
|
|
49562
49656
|
this.flush = flushBuffer;
|
|
49563
49657
|
this.flushSync = flushBufferSync;
|
|
49564
49658
|
this._actualWrite = actualWriteBuffer;
|
|
49565
|
-
fsWriteSync = () =>
|
|
49566
|
-
fsWrite = () =>
|
|
49659
|
+
fsWriteSync = () => fs20.writeSync(this.fd, this._writingBuf);
|
|
49660
|
+
fsWrite = () => fs20.write(this.fd, this._writingBuf, this.release);
|
|
49567
49661
|
} else if (contentMode === void 0 || contentMode === kContentModeUtf8) {
|
|
49568
49662
|
this._writingBuf = "";
|
|
49569
49663
|
this.write = write;
|
|
@@ -49572,15 +49666,15 @@ var require_sonic_boom = __commonJS({
|
|
|
49572
49666
|
this._actualWrite = actualWrite;
|
|
49573
49667
|
fsWriteSync = () => {
|
|
49574
49668
|
if (Buffer.isBuffer(this._writingBuf)) {
|
|
49575
|
-
return
|
|
49669
|
+
return fs20.writeSync(this.fd, this._writingBuf);
|
|
49576
49670
|
}
|
|
49577
|
-
return
|
|
49671
|
+
return fs20.writeSync(this.fd, this._writingBuf, "utf8");
|
|
49578
49672
|
};
|
|
49579
49673
|
fsWrite = () => {
|
|
49580
49674
|
if (Buffer.isBuffer(this._writingBuf)) {
|
|
49581
|
-
return
|
|
49675
|
+
return fs20.write(this.fd, this._writingBuf, this.release);
|
|
49582
49676
|
}
|
|
49583
|
-
return
|
|
49677
|
+
return fs20.write(this.fd, this._writingBuf, "utf8", this.release);
|
|
49584
49678
|
};
|
|
49585
49679
|
} else {
|
|
49586
49680
|
throw new Error(`SonicBoom supports "${kContentModeUtf8}" and "${kContentModeBuffer}", but passed ${contentMode}`);
|
|
@@ -49637,7 +49731,7 @@ var require_sonic_boom = __commonJS({
|
|
|
49637
49731
|
}
|
|
49638
49732
|
}
|
|
49639
49733
|
if (this._fsync) {
|
|
49640
|
-
|
|
49734
|
+
fs20.fsyncSync(this.fd);
|
|
49641
49735
|
}
|
|
49642
49736
|
const len = this._len;
|
|
49643
49737
|
if (this._reopening) {
|
|
@@ -49751,7 +49845,7 @@ var require_sonic_boom = __commonJS({
|
|
|
49751
49845
|
const onDrain = () => {
|
|
49752
49846
|
if (!this._fsync) {
|
|
49753
49847
|
try {
|
|
49754
|
-
|
|
49848
|
+
fs20.fsync(this.fd, (err) => {
|
|
49755
49849
|
this._flushPending = false;
|
|
49756
49850
|
cb(err);
|
|
49757
49851
|
});
|
|
@@ -49853,7 +49947,7 @@ var require_sonic_boom = __commonJS({
|
|
|
49853
49947
|
const fd = this.fd;
|
|
49854
49948
|
this.once("ready", () => {
|
|
49855
49949
|
if (fd !== this.fd) {
|
|
49856
|
-
|
|
49950
|
+
fs20.close(fd, (err) => {
|
|
49857
49951
|
if (err) {
|
|
49858
49952
|
return this.emit("error", err);
|
|
49859
49953
|
}
|
|
@@ -49902,7 +49996,7 @@ var require_sonic_boom = __commonJS({
|
|
|
49902
49996
|
buf = this._bufs[0];
|
|
49903
49997
|
}
|
|
49904
49998
|
try {
|
|
49905
|
-
const n = Buffer.isBuffer(buf) ?
|
|
49999
|
+
const n = Buffer.isBuffer(buf) ? fs20.writeSync(this.fd, buf) : fs20.writeSync(this.fd, buf, "utf8");
|
|
49906
50000
|
const releasedBufObj = releaseWritingBuf(buf, this._len, n);
|
|
49907
50001
|
buf = releasedBufObj.writingBuf;
|
|
49908
50002
|
this._len = releasedBufObj.len;
|
|
@@ -49918,7 +50012,7 @@ var require_sonic_boom = __commonJS({
|
|
|
49918
50012
|
}
|
|
49919
50013
|
}
|
|
49920
50014
|
try {
|
|
49921
|
-
|
|
50015
|
+
fs20.fsyncSync(this.fd);
|
|
49922
50016
|
} catch {
|
|
49923
50017
|
}
|
|
49924
50018
|
}
|
|
@@ -49939,7 +50033,7 @@ var require_sonic_boom = __commonJS({
|
|
|
49939
50033
|
buf = mergeBuf(this._bufs[0], this._lens[0]);
|
|
49940
50034
|
}
|
|
49941
50035
|
try {
|
|
49942
|
-
const n =
|
|
50036
|
+
const n = fs20.writeSync(this.fd, buf);
|
|
49943
50037
|
buf = buf.subarray(n);
|
|
49944
50038
|
this._len = Math.max(this._len - n, 0);
|
|
49945
50039
|
if (buf.length <= 0) {
|
|
@@ -49967,13 +50061,13 @@ var require_sonic_boom = __commonJS({
|
|
|
49967
50061
|
this._writingBuf = this._writingBuf.length ? this._writingBuf : this._bufs.shift() || "";
|
|
49968
50062
|
if (this.sync) {
|
|
49969
50063
|
try {
|
|
49970
|
-
const written = Buffer.isBuffer(this._writingBuf) ?
|
|
50064
|
+
const written = Buffer.isBuffer(this._writingBuf) ? fs20.writeSync(this.fd, this._writingBuf) : fs20.writeSync(this.fd, this._writingBuf, "utf8");
|
|
49971
50065
|
release(null, written);
|
|
49972
50066
|
} catch (err) {
|
|
49973
50067
|
release(err);
|
|
49974
50068
|
}
|
|
49975
50069
|
} else {
|
|
49976
|
-
|
|
50070
|
+
fs20.write(this.fd, this._writingBuf, release);
|
|
49977
50071
|
}
|
|
49978
50072
|
}
|
|
49979
50073
|
function actualWriteBuffer() {
|
|
@@ -49982,7 +50076,7 @@ var require_sonic_boom = __commonJS({
|
|
|
49982
50076
|
this._writingBuf = this._writingBuf.length ? this._writingBuf : mergeBuf(this._bufs.shift(), this._lens.shift());
|
|
49983
50077
|
if (this.sync) {
|
|
49984
50078
|
try {
|
|
49985
|
-
const written =
|
|
50079
|
+
const written = fs20.writeSync(this.fd, this._writingBuf);
|
|
49986
50080
|
release(null, written);
|
|
49987
50081
|
} catch (err) {
|
|
49988
50082
|
release(err);
|
|
@@ -49991,7 +50085,7 @@ var require_sonic_boom = __commonJS({
|
|
|
49991
50085
|
if (kCopyBuffer) {
|
|
49992
50086
|
this._writingBuf = Buffer.from(this._writingBuf);
|
|
49993
50087
|
}
|
|
49994
|
-
|
|
50088
|
+
fs20.write(this.fd, this._writingBuf, release);
|
|
49995
50089
|
}
|
|
49996
50090
|
}
|
|
49997
50091
|
function actualClose(sonic) {
|
|
@@ -50007,12 +50101,12 @@ var require_sonic_boom = __commonJS({
|
|
|
50007
50101
|
sonic._lens = [];
|
|
50008
50102
|
assert2(typeof sonic.fd === "number", `sonic.fd must be a number, got ${typeof sonic.fd}`);
|
|
50009
50103
|
try {
|
|
50010
|
-
|
|
50104
|
+
fs20.fsync(sonic.fd, closeWrapped);
|
|
50011
50105
|
} catch {
|
|
50012
50106
|
}
|
|
50013
50107
|
function closeWrapped() {
|
|
50014
50108
|
if (sonic.fd !== 1 && sonic.fd !== 2) {
|
|
50015
|
-
|
|
50109
|
+
fs20.close(sonic.fd, done);
|
|
50016
50110
|
} else {
|
|
50017
50111
|
done();
|
|
50018
50112
|
}
|
|
@@ -50848,15 +50942,15 @@ var require_transport = __commonJS({
|
|
|
50848
50942
|
if (!unquoted) {
|
|
50849
50943
|
return false;
|
|
50850
50944
|
}
|
|
50851
|
-
let
|
|
50852
|
-
if (
|
|
50945
|
+
let path22 = unquoted;
|
|
50946
|
+
if (path22.startsWith("file://")) {
|
|
50853
50947
|
try {
|
|
50854
|
-
|
|
50948
|
+
path22 = fileURLToPath(path22);
|
|
50855
50949
|
} catch {
|
|
50856
50950
|
return false;
|
|
50857
50951
|
}
|
|
50858
50952
|
}
|
|
50859
|
-
return isAbsolute(
|
|
50953
|
+
return isAbsolute(path22) && !existsSync(path22);
|
|
50860
50954
|
}
|
|
50861
50955
|
function stripQuotes(value) {
|
|
50862
50956
|
const first = value[0];
|
|
@@ -52550,7 +52644,7 @@ var require_multistream = __commonJS({
|
|
|
52550
52644
|
var require_pino = __commonJS({
|
|
52551
52645
|
"node_modules/pino/pino.js"(exports, module) {
|
|
52552
52646
|
"use strict";
|
|
52553
|
-
var
|
|
52647
|
+
var os15 = __require("node:os");
|
|
52554
52648
|
var stdSerializers = require_pino_std_serializers();
|
|
52555
52649
|
var caller = require_caller();
|
|
52556
52650
|
var redaction = require_redaction();
|
|
@@ -52597,7 +52691,7 @@ var require_pino = __commonJS({
|
|
|
52597
52691
|
} = symbols;
|
|
52598
52692
|
var { epochTime, nullTime } = time3;
|
|
52599
52693
|
var { pid } = process;
|
|
52600
|
-
var hostname2 =
|
|
52694
|
+
var hostname2 = os15.hostname();
|
|
52601
52695
|
var defaultErrorSerializer = stdSerializers.err;
|
|
52602
52696
|
var defaultOptions2 = {
|
|
52603
52697
|
level: "info",
|
|
@@ -84923,15 +85017,15 @@ var require_tools2 = __commonJS({
|
|
|
84923
85017
|
* @param {String} path - Mailbox path to encode
|
|
84924
85018
|
* @returns {String} Encoded mailbox path
|
|
84925
85019
|
*/
|
|
84926
|
-
encodePath(connection,
|
|
84927
|
-
|
|
84928
|
-
if (!connection.enabled.has("UTF8=ACCEPT") && !tools.isRev2Active(connection) && /[&\x00-\x08\x0b-\x0c\x0e-\x1f\u0080-\uffff]/.test(
|
|
85020
|
+
encodePath(connection, path22) {
|
|
85021
|
+
path22 = (path22 || "").toString();
|
|
85022
|
+
if (!connection.enabled.has("UTF8=ACCEPT") && !tools.isRev2Active(connection) && /[&\x00-\x08\x0b-\x0c\x0e-\x1f\u0080-\uffff]/.test(path22)) {
|
|
84929
85023
|
try {
|
|
84930
|
-
|
|
85024
|
+
path22 = iconv.encode(path22, "utf-7-imap").toString();
|
|
84931
85025
|
} catch {
|
|
84932
85026
|
}
|
|
84933
85027
|
}
|
|
84934
|
-
return
|
|
85028
|
+
return path22;
|
|
84935
85029
|
},
|
|
84936
85030
|
/**
|
|
84937
85031
|
* Decodes a mailbox path from modified UTF-7 if the server does not support UTF8=ACCEPT.
|
|
@@ -84940,15 +85034,15 @@ var require_tools2 = __commonJS({
|
|
|
84940
85034
|
* @param {String} path - Mailbox path to decode
|
|
84941
85035
|
* @returns {String} Decoded mailbox path
|
|
84942
85036
|
*/
|
|
84943
|
-
decodePath(connection,
|
|
84944
|
-
|
|
84945
|
-
if (!connection.enabled.has("UTF8=ACCEPT") && !tools.isRev2Active(connection) && /[&]/.test(
|
|
85037
|
+
decodePath(connection, path22) {
|
|
85038
|
+
path22 = (path22 || "").toString();
|
|
85039
|
+
if (!connection.enabled.has("UTF8=ACCEPT") && !tools.isRev2Active(connection) && /[&]/.test(path22)) {
|
|
84946
85040
|
try {
|
|
84947
|
-
|
|
85041
|
+
path22 = iconv.decode(Buffer.from(path22), "utf-7-imap").toString();
|
|
84948
85042
|
} catch {
|
|
84949
85043
|
}
|
|
84950
85044
|
}
|
|
84951
|
-
return
|
|
85045
|
+
return path22;
|
|
84952
85046
|
},
|
|
84953
85047
|
/**
|
|
84954
85048
|
* Normalizes a mailbox path by joining array segments with the namespace delimiter,
|
|
@@ -84959,17 +85053,17 @@ var require_tools2 = __commonJS({
|
|
|
84959
85053
|
* @param {Boolean} [skipNamespace] - If true, skips prepending the namespace prefix
|
|
84960
85054
|
* @returns {String} Normalized mailbox path
|
|
84961
85055
|
*/
|
|
84962
|
-
normalizePath(connection,
|
|
84963
|
-
if (Array.isArray(
|
|
84964
|
-
|
|
85056
|
+
normalizePath(connection, path22, skipNamespace) {
|
|
85057
|
+
if (Array.isArray(path22)) {
|
|
85058
|
+
path22 = path22.join(connection.namespace && connection.namespace.delimiter || "");
|
|
84965
85059
|
}
|
|
84966
|
-
if (
|
|
85060
|
+
if (path22.toUpperCase() === "INBOX") {
|
|
84967
85061
|
return "INBOX";
|
|
84968
85062
|
}
|
|
84969
|
-
if (!skipNamespace && connection.namespace && connection.namespace.prefix && !
|
|
84970
|
-
|
|
85063
|
+
if (!skipNamespace && connection.namespace && connection.namespace.prefix && !path22.startsWith(connection.namespace.prefix)) {
|
|
85064
|
+
path22 = connection.namespace.prefix + path22;
|
|
84971
85065
|
}
|
|
84972
|
-
return
|
|
85066
|
+
return path22;
|
|
84973
85067
|
},
|
|
84974
85068
|
/**
|
|
84975
85069
|
* Compares two mailbox paths for equality after normalization.
|
|
@@ -85300,14 +85394,14 @@ var require_tools2 = __commonJS({
|
|
|
85300
85394
|
}
|
|
85301
85395
|
}
|
|
85302
85396
|
if (map.emailId || map.uid) {
|
|
85303
|
-
let
|
|
85304
|
-
if (/[\u0080-\uffff]/.test(
|
|
85397
|
+
let path22 = mailbox.path;
|
|
85398
|
+
if (/[\u0080-\uffff]/.test(path22)) {
|
|
85305
85399
|
try {
|
|
85306
|
-
|
|
85400
|
+
path22 = iconv.encode(path22, "utf-7-imap").toString();
|
|
85307
85401
|
} catch {
|
|
85308
85402
|
}
|
|
85309
85403
|
}
|
|
85310
|
-
map.id = map.emailId || createHash2("md5").update([
|
|
85404
|
+
map.id = map.emailId || createHash2("md5").update([path22, mailbox.uidValidity?.toString() || "", map.uid.toString()].join(":")).digest("hex");
|
|
85311
85405
|
}
|
|
85312
85406
|
if (map.flags) {
|
|
85313
85407
|
let flagColor = tools.getFlagColor(map.flags);
|
|
@@ -85482,16 +85576,16 @@ var require_tools2 = __commonJS({
|
|
|
85482
85576
|
* @returns {Object} Parsed body structure tree with part numbers, types, parameters, and child nodes
|
|
85483
85577
|
*/
|
|
85484
85578
|
parseBodystructure(entry) {
|
|
85485
|
-
let walk = (node,
|
|
85486
|
-
|
|
85579
|
+
let walk = (node, path22) => {
|
|
85580
|
+
path22 = path22 || [];
|
|
85487
85581
|
let curNode = {}, i = 0, part = 0;
|
|
85488
|
-
if (
|
|
85489
|
-
curNode.part =
|
|
85582
|
+
if (path22.length) {
|
|
85583
|
+
curNode.part = path22.join(".");
|
|
85490
85584
|
}
|
|
85491
85585
|
if (Array.isArray(node[0])) {
|
|
85492
85586
|
curNode.childNodes = [];
|
|
85493
85587
|
while (Array.isArray(node[i])) {
|
|
85494
|
-
curNode.childNodes.push(walk(node[i],
|
|
85588
|
+
curNode.childNodes.push(walk(node[i], path22.concat(++part)));
|
|
85495
85589
|
i++;
|
|
85496
85590
|
}
|
|
85497
85591
|
curNode.type = "multipart/" + ((node[i++] || {}).value || "").toString().toLowerCase();
|
|
@@ -85534,7 +85628,7 @@ var require_tools2 = __commonJS({
|
|
|
85534
85628
|
// the encapsulated message shares the part number with its wrapper.
|
|
85535
85629
|
// Distinction is via suffixes: path.MIME = wrapper headers,
|
|
85536
85630
|
// path.HEADER = encapsulated message headers.
|
|
85537
|
-
walk(node[i],
|
|
85631
|
+
walk(node[i], path22)
|
|
85538
85632
|
];
|
|
85539
85633
|
}
|
|
85540
85634
|
i++;
|
|
@@ -87496,14 +87590,14 @@ var require_select = __commonJS({
|
|
|
87496
87590
|
// update into a silent no-op for the rest of the session.
|
|
87497
87591
|
permanentflags: { key: "permanentFlags", parse: (value) => Array.isArray(value) && new Set(value) }
|
|
87498
87592
|
});
|
|
87499
|
-
module.exports = async (connection,
|
|
87593
|
+
module.exports = async (connection, path22, options) => {
|
|
87500
87594
|
if (![connection.states.AUTHENTICATED, connection.states.SELECTED].includes(connection.state)) {
|
|
87501
87595
|
return;
|
|
87502
87596
|
}
|
|
87503
87597
|
options = options || {};
|
|
87504
|
-
|
|
87505
|
-
if (!connection.folders.has(
|
|
87506
|
-
let folders = await connection.run("LIST", "",
|
|
87598
|
+
path22 = normalizePath(connection, path22);
|
|
87599
|
+
if (!connection.folders.has(path22)) {
|
|
87600
|
+
let folders = await connection.run("LIST", "", path22);
|
|
87507
87601
|
if (!folders) {
|
|
87508
87602
|
throw new Error("Failed to fetch folders");
|
|
87509
87603
|
}
|
|
@@ -87511,10 +87605,10 @@ var require_select = __commonJS({
|
|
|
87511
87605
|
connection.folders.set(folder.path, folder);
|
|
87512
87606
|
});
|
|
87513
87607
|
}
|
|
87514
|
-
let folderListData = connection.folders.has(
|
|
87608
|
+
let folderListData = connection.folders.has(path22) ? connection.folders.get(path22) : false;
|
|
87515
87609
|
let response;
|
|
87516
87610
|
try {
|
|
87517
|
-
let map = { path:
|
|
87611
|
+
let map = { path: path22 };
|
|
87518
87612
|
if (folderListData) {
|
|
87519
87613
|
["delimiter", "specialUse", "subscribed", "listed"].forEach((key) => {
|
|
87520
87614
|
if (folderListData[key]) {
|
|
@@ -87533,7 +87627,7 @@ var require_select = __commonJS({
|
|
|
87533
87627
|
]);
|
|
87534
87628
|
map.qresync = true;
|
|
87535
87629
|
}
|
|
87536
|
-
let encodedPath = encodePath(connection,
|
|
87630
|
+
let encodedPath = encodePath(connection, path22);
|
|
87537
87631
|
let selectCommand = {
|
|
87538
87632
|
command: !options.readOnly ? "SELECT" : "EXAMINE",
|
|
87539
87633
|
/* c8 ignore next */
|
|
@@ -87593,12 +87687,12 @@ var require_select = __commonJS({
|
|
|
87593
87687
|
// since the client's last known state. Only received when QRESYNC was requested.
|
|
87594
87688
|
// A dummy mailbox object is passed because the mailbox isn't officially open yet.
|
|
87595
87689
|
VANISHED: async (untagged) => {
|
|
87596
|
-
await connection.untaggedVanished(untagged, { path:
|
|
87690
|
+
await connection.untaggedVanished(untagged, { path: path22, uidNext: false, uidValidity: false });
|
|
87597
87691
|
},
|
|
87598
87692
|
// Untagged FETCH during SELECT/EXAMINE: only occurs with QRESYNC, delivering
|
|
87599
87693
|
// updated flags for messages that changed since the client's last modseq.
|
|
87600
87694
|
FETCH: async (untagged) => {
|
|
87601
|
-
await connection.untaggedFetch(untagged, { path:
|
|
87695
|
+
await connection.untaggedFetch(untagged, { path: path22, uidNext: false, uidValidity: false });
|
|
87602
87696
|
}
|
|
87603
87697
|
}
|
|
87604
87698
|
});
|
|
@@ -87612,13 +87706,13 @@ var require_select = __commonJS({
|
|
|
87612
87706
|
}
|
|
87613
87707
|
let currentMailbox = connection.mailbox;
|
|
87614
87708
|
connection.mailbox = false;
|
|
87615
|
-
if (currentMailbox && currentMailbox.path !==
|
|
87709
|
+
if (currentMailbox && currentMailbox.path !== path22) {
|
|
87616
87710
|
connection.emit("mailboxClose", currentMailbox);
|
|
87617
87711
|
}
|
|
87618
87712
|
connection.mailbox = map;
|
|
87619
87713
|
connection.currentSelectCommand = selectCommand;
|
|
87620
87714
|
connection.state = connection.states.SELECTED;
|
|
87621
|
-
if (!currentMailbox || currentMailbox.path !==
|
|
87715
|
+
if (!currentMailbox || currentMailbox.path !== path22) {
|
|
87622
87716
|
connection.emit("mailboxOpen", connection.mailbox);
|
|
87623
87717
|
}
|
|
87624
87718
|
response.next();
|
|
@@ -87833,17 +87927,17 @@ var require_create = __commonJS({
|
|
|
87833
87927
|
"node_modules/imapflow/lib/commands/create.js"(exports, module) {
|
|
87834
87928
|
"use strict";
|
|
87835
87929
|
var { encodePath, normalizePath, getStatusCode, enhanceCommandError } = require_tools2();
|
|
87836
|
-
module.exports = async (connection,
|
|
87930
|
+
module.exports = async (connection, path22) => {
|
|
87837
87931
|
if (![connection.states.AUTHENTICATED, connection.states.SELECTED].includes(connection.state)) {
|
|
87838
87932
|
return;
|
|
87839
87933
|
}
|
|
87840
|
-
|
|
87934
|
+
path22 = normalizePath(connection, path22);
|
|
87841
87935
|
let response;
|
|
87842
87936
|
try {
|
|
87843
87937
|
let map = {
|
|
87844
|
-
path:
|
|
87938
|
+
path: path22
|
|
87845
87939
|
};
|
|
87846
|
-
response = await connection.exec("CREATE", [{ type: "ATOM", value: encodePath(connection,
|
|
87940
|
+
response = await connection.exec("CREATE", [{ type: "ATOM", value: encodePath(connection, path22) }]);
|
|
87847
87941
|
let section = response.response.attributes && response.response.attributes[0] && response.response.attributes[0].section && response.response.attributes[0].section.length ? response.response.attributes[0].section : false;
|
|
87848
87942
|
if (section) {
|
|
87849
87943
|
let key;
|
|
@@ -87869,13 +87963,13 @@ var require_create = __commonJS({
|
|
|
87869
87963
|
}
|
|
87870
87964
|
map.created = true;
|
|
87871
87965
|
response.next();
|
|
87872
|
-
await connection.run("SUBSCRIBE",
|
|
87966
|
+
await connection.run("SUBSCRIBE", path22);
|
|
87873
87967
|
return map;
|
|
87874
87968
|
} catch (err) {
|
|
87875
87969
|
let errorCode = getStatusCode(err.response);
|
|
87876
87970
|
if (errorCode === "ALREADYEXISTS") {
|
|
87877
87971
|
return {
|
|
87878
|
-
path:
|
|
87972
|
+
path: path22,
|
|
87879
87973
|
created: false
|
|
87880
87974
|
};
|
|
87881
87975
|
}
|
|
@@ -87892,20 +87986,20 @@ var require_delete = __commonJS({
|
|
|
87892
87986
|
"node_modules/imapflow/lib/commands/delete.js"(exports, module) {
|
|
87893
87987
|
"use strict";
|
|
87894
87988
|
var { encodePath, normalizePath, enhanceCommandError } = require_tools2();
|
|
87895
|
-
module.exports = async (connection,
|
|
87989
|
+
module.exports = async (connection, path22) => {
|
|
87896
87990
|
if (![connection.states.AUTHENTICATED, connection.states.SELECTED].includes(connection.state)) {
|
|
87897
87991
|
return;
|
|
87898
87992
|
}
|
|
87899
|
-
|
|
87900
|
-
if (connection.state === connection.states.SELECTED && connection.mailbox.path ===
|
|
87993
|
+
path22 = normalizePath(connection, path22);
|
|
87994
|
+
if (connection.state === connection.states.SELECTED && connection.mailbox.path === path22) {
|
|
87901
87995
|
await connection.run("CLOSE");
|
|
87902
87996
|
}
|
|
87903
87997
|
let response;
|
|
87904
87998
|
try {
|
|
87905
87999
|
let map = {
|
|
87906
|
-
path:
|
|
88000
|
+
path: path22
|
|
87907
88001
|
};
|
|
87908
|
-
response = await connection.exec("DELETE", [{ type: "ATOM", value: encodePath(connection,
|
|
88002
|
+
response = await connection.exec("DELETE", [{ type: "ATOM", value: encodePath(connection, path22) }]);
|
|
87909
88003
|
response.next();
|
|
87910
88004
|
return map;
|
|
87911
88005
|
} catch (err) {
|
|
@@ -87922,23 +88016,23 @@ var require_rename = __commonJS({
|
|
|
87922
88016
|
"node_modules/imapflow/lib/commands/rename.js"(exports, module) {
|
|
87923
88017
|
"use strict";
|
|
87924
88018
|
var { encodePath, normalizePath, enhanceCommandError } = require_tools2();
|
|
87925
|
-
module.exports = async (connection,
|
|
88019
|
+
module.exports = async (connection, path22, newPath) => {
|
|
87926
88020
|
if (![connection.states.AUTHENTICATED, connection.states.SELECTED].includes(connection.state)) {
|
|
87927
88021
|
return;
|
|
87928
88022
|
}
|
|
87929
|
-
|
|
88023
|
+
path22 = normalizePath(connection, path22);
|
|
87930
88024
|
newPath = normalizePath(connection, newPath);
|
|
87931
|
-
if (connection.state === connection.states.SELECTED && connection.mailbox.path ===
|
|
88025
|
+
if (connection.state === connection.states.SELECTED && connection.mailbox.path === path22) {
|
|
87932
88026
|
await connection.run("CLOSE");
|
|
87933
88027
|
}
|
|
87934
88028
|
let response;
|
|
87935
88029
|
try {
|
|
87936
88030
|
let map = {
|
|
87937
|
-
path:
|
|
88031
|
+
path: path22,
|
|
87938
88032
|
newPath
|
|
87939
88033
|
};
|
|
87940
88034
|
response = await connection.exec("RENAME", [
|
|
87941
|
-
{ type: "ATOM", value: encodePath(connection,
|
|
88035
|
+
{ type: "ATOM", value: encodePath(connection, path22) },
|
|
87942
88036
|
{ type: "ATOM", value: encodePath(connection, newPath) }
|
|
87943
88037
|
]);
|
|
87944
88038
|
response.next();
|
|
@@ -87985,14 +88079,14 @@ var require_subscribe = __commonJS({
|
|
|
87985
88079
|
"node_modules/imapflow/lib/commands/subscribe.js"(exports, module) {
|
|
87986
88080
|
"use strict";
|
|
87987
88081
|
var { encodePath, normalizePath, enhanceCommandError } = require_tools2();
|
|
87988
|
-
module.exports = async (connection,
|
|
88082
|
+
module.exports = async (connection, path22) => {
|
|
87989
88083
|
if (![connection.states.AUTHENTICATED, connection.states.SELECTED].includes(connection.state)) {
|
|
87990
88084
|
return;
|
|
87991
88085
|
}
|
|
87992
|
-
|
|
88086
|
+
path22 = normalizePath(connection, path22);
|
|
87993
88087
|
let response;
|
|
87994
88088
|
try {
|
|
87995
|
-
response = await connection.exec("SUBSCRIBE", [{ type: "ATOM", value: encodePath(connection,
|
|
88089
|
+
response = await connection.exec("SUBSCRIBE", [{ type: "ATOM", value: encodePath(connection, path22) }]);
|
|
87996
88090
|
response.next();
|
|
87997
88091
|
return true;
|
|
87998
88092
|
} catch (err) {
|
|
@@ -88009,14 +88103,14 @@ var require_unsubscribe = __commonJS({
|
|
|
88009
88103
|
"node_modules/imapflow/lib/commands/unsubscribe.js"(exports, module) {
|
|
88010
88104
|
"use strict";
|
|
88011
88105
|
var { encodePath, normalizePath, enhanceCommandError } = require_tools2();
|
|
88012
|
-
module.exports = async (connection,
|
|
88106
|
+
module.exports = async (connection, path22) => {
|
|
88013
88107
|
if (![connection.states.AUTHENTICATED, connection.states.SELECTED].includes(connection.state)) {
|
|
88014
88108
|
return;
|
|
88015
88109
|
}
|
|
88016
|
-
|
|
88110
|
+
path22 = normalizePath(connection, path22);
|
|
88017
88111
|
let response;
|
|
88018
88112
|
try {
|
|
88019
|
-
response = await connection.exec("UNSUBSCRIBE", [{ type: "ATOM", value: encodePath(connection,
|
|
88113
|
+
response = await connection.exec("UNSUBSCRIBE", [{ type: "ATOM", value: encodePath(connection, path22) }]);
|
|
88020
88114
|
response.next();
|
|
88021
88115
|
return true;
|
|
88022
88116
|
} catch (err) {
|
|
@@ -88822,11 +88916,11 @@ var require_status = __commonJS({
|
|
|
88822
88916
|
var { encodePath, normalizePath, buildStatusQueryAttributes, isRev2Active } = require_tools2();
|
|
88823
88917
|
var { parseStatusList } = require_status_fields();
|
|
88824
88918
|
var MAILBOX_UPDATERS = {
|
|
88825
|
-
messages: (value, connection,
|
|
88919
|
+
messages: (value, connection, path22) => {
|
|
88826
88920
|
let prevCount = connection.mailbox.exists;
|
|
88827
88921
|
if (prevCount !== value) {
|
|
88828
88922
|
connection.mailbox.exists = value;
|
|
88829
|
-
connection.emit("exists", { path:
|
|
88923
|
+
connection.emit("exists", { path: path22, count: value, prevCount });
|
|
88830
88924
|
}
|
|
88831
88925
|
},
|
|
88832
88926
|
uidNext: (value, connection) => {
|
|
@@ -88836,28 +88930,28 @@ var require_status = __commonJS({
|
|
|
88836
88930
|
connection.mailbox.highestModseq = value;
|
|
88837
88931
|
}
|
|
88838
88932
|
};
|
|
88839
|
-
module.exports = async (connection,
|
|
88840
|
-
if (![connection.states.AUTHENTICATED, connection.states.SELECTED].includes(connection.state) || !
|
|
88933
|
+
module.exports = async (connection, path22, query) => {
|
|
88934
|
+
if (![connection.states.AUTHENTICATED, connection.states.SELECTED].includes(connection.state) || !path22) {
|
|
88841
88935
|
return false;
|
|
88842
88936
|
}
|
|
88843
|
-
|
|
88844
|
-
let encodedPath = encodePath(connection,
|
|
88937
|
+
path22 = normalizePath(connection, path22);
|
|
88938
|
+
let encodedPath = encodePath(connection, path22);
|
|
88845
88939
|
let attributes = [{ type: encodedPath.indexOf("&") >= 0 ? "STRING" : "ATOM", value: encodedPath }];
|
|
88846
88940
|
let queryAttributes = buildStatusQueryAttributes(connection, query);
|
|
88847
88941
|
let syntheticRecent = query && query.recent && isRev2Active(connection);
|
|
88848
88942
|
if (!queryAttributes.length) {
|
|
88849
|
-
return syntheticRecent ? { path:
|
|
88943
|
+
return syntheticRecent ? { path: path22, recent: 0 } : false;
|
|
88850
88944
|
}
|
|
88851
88945
|
attributes.push(queryAttributes);
|
|
88852
88946
|
let response;
|
|
88853
88947
|
try {
|
|
88854
|
-
let map = { path:
|
|
88948
|
+
let map = { path: path22 };
|
|
88855
88949
|
response = await connection.exec("STATUS", attributes, {
|
|
88856
88950
|
untagged: {
|
|
88857
88951
|
// STATUS response: * STATUS <mailbox> (<key> <value> <key> <value> ...)
|
|
88858
88952
|
// Parsed as alternating key-value pairs (i % 2 pattern).
|
|
88859
88953
|
STATUS: async (untagged) => {
|
|
88860
|
-
let updateCurrent = connection.state === connection.states.SELECTED &&
|
|
88954
|
+
let updateCurrent = connection.state === connection.states.SELECTED && path22 === connection.mailbox.path;
|
|
88861
88955
|
let list = untagged.attributes && Array.isArray(untagged.attributes[1]) ? untagged.attributes[1] : false;
|
|
88862
88956
|
if (!list) {
|
|
88863
88957
|
return;
|
|
@@ -88865,7 +88959,7 @@ var require_status = __commonJS({
|
|
|
88865
88959
|
parseStatusList(list, (key, value) => {
|
|
88866
88960
|
map[key] = value;
|
|
88867
88961
|
if (updateCurrent && MAILBOX_UPDATERS[key]) {
|
|
88868
|
-
MAILBOX_UPDATERS[key](value, connection,
|
|
88962
|
+
MAILBOX_UPDATERS[key](value, connection, path22);
|
|
88869
88963
|
}
|
|
88870
88964
|
});
|
|
88871
88965
|
}
|
|
@@ -88878,9 +88972,9 @@ var require_status = __commonJS({
|
|
|
88878
88972
|
return map;
|
|
88879
88973
|
} catch (err) {
|
|
88880
88974
|
if (err.responseStatus === "NO") {
|
|
88881
|
-
let folders = await connection.run("LIST", "",
|
|
88975
|
+
let folders = await connection.run("LIST", "", path22, { listOnly: true });
|
|
88882
88976
|
if (folders && !folders.length) {
|
|
88883
|
-
let error2 = new Error(`Mailbox doesn't exist: ${
|
|
88977
|
+
let error2 = new Error(`Mailbox doesn't exist: ${path22}`);
|
|
88884
88978
|
error2.code = "NotFound";
|
|
88885
88979
|
error2.response = err;
|
|
88886
88980
|
throw error2;
|
|
@@ -89027,15 +89121,15 @@ var require_quota = __commonJS({
|
|
|
89027
89121
|
"node_modules/imapflow/lib/commands/quota.js"(exports, module) {
|
|
89028
89122
|
"use strict";
|
|
89029
89123
|
var { encodePath, normalizePath, enhanceCommandError, parseUintValue, isUnsafeKey } = require_tools2();
|
|
89030
|
-
module.exports = async (connection,
|
|
89031
|
-
if (![connection.states.AUTHENTICATED, connection.states.SELECTED].includes(connection.state) || !
|
|
89124
|
+
module.exports = async (connection, path22) => {
|
|
89125
|
+
if (![connection.states.AUTHENTICATED, connection.states.SELECTED].includes(connection.state) || !path22) {
|
|
89032
89126
|
return;
|
|
89033
89127
|
}
|
|
89034
89128
|
if (!connection.capabilities.has("QUOTA")) {
|
|
89035
89129
|
return false;
|
|
89036
89130
|
}
|
|
89037
|
-
|
|
89038
|
-
let map = { path:
|
|
89131
|
+
path22 = normalizePath(connection, path22);
|
|
89132
|
+
let map = { path: path22 };
|
|
89039
89133
|
let processQuotaResponse = (untagged) => {
|
|
89040
89134
|
let attributes = untagged.attributes && untagged.attributes[1];
|
|
89041
89135
|
if (!attributes || !attributes.length) {
|
|
@@ -89075,7 +89169,7 @@ var require_quota = __commonJS({
|
|
|
89075
89169
|
let quotaFound = false;
|
|
89076
89170
|
let response;
|
|
89077
89171
|
try {
|
|
89078
|
-
response = await connection.exec("GETQUOTAROOT", [{ type: "ATOM", value: encodePath(connection,
|
|
89172
|
+
response = await connection.exec("GETQUOTAROOT", [{ type: "ATOM", value: encodePath(connection, path22) }], {
|
|
89079
89173
|
untagged: {
|
|
89080
89174
|
// QUOTAROOT response tells us which quota root applies to this mailbox.
|
|
89081
89175
|
// A mailbox may have zero or one quota root.
|
|
@@ -89218,15 +89312,15 @@ var require_idle = __commonJS({
|
|
|
89218
89312
|
}
|
|
89219
89313
|
}
|
|
89220
89314
|
async function pollOnce2(connection, session) {
|
|
89221
|
-
let
|
|
89315
|
+
let path22 = connection.mailbox && connection.mailbox.path;
|
|
89222
89316
|
switch (connection.missingIdleCommand) {
|
|
89223
89317
|
case "SELECT":
|
|
89224
89318
|
connection.log.debug({ src: "c", msg: `Running SELECT to detect changes in folder`, cid: connection.id });
|
|
89225
|
-
await connection.runInternal("SELECT",
|
|
89319
|
+
await connection.runInternal("SELECT", path22, { readOnly: session.selectCommand.command === "EXAMINE" });
|
|
89226
89320
|
break;
|
|
89227
89321
|
case "STATUS": {
|
|
89228
89322
|
connection.log.debug({ src: "c", msg: `Running STATUS to detect changes in folder`, cid: connection.id });
|
|
89229
|
-
let status = await connection.runInternal("STATUS",
|
|
89323
|
+
let status = await connection.runInternal("STATUS", path22, {
|
|
89230
89324
|
messages: true,
|
|
89231
89325
|
uidNext: true,
|
|
89232
89326
|
uidValidity: true,
|
|
@@ -89519,7 +89613,7 @@ var require_imap_flow = __commonJS({
|
|
|
89519
89613
|
"use strict";
|
|
89520
89614
|
var tls = __require("tls");
|
|
89521
89615
|
var net = __require("net");
|
|
89522
|
-
var
|
|
89616
|
+
var crypto10 = __require("crypto");
|
|
89523
89617
|
var { EventEmitter } = __require("events");
|
|
89524
89618
|
var logger2 = require_logger();
|
|
89525
89619
|
var libmime = require_libmime();
|
|
@@ -89826,7 +89920,7 @@ var require_imap_flow = __commonJS({
|
|
|
89826
89920
|
this.emit("error", err);
|
|
89827
89921
|
}
|
|
89828
89922
|
getRandomId() {
|
|
89829
|
-
let rid = BigInt("0x" +
|
|
89923
|
+
let rid = BigInt("0x" + crypto10.randomBytes(13).toString("hex")).toString(36);
|
|
89830
89924
|
if (rid.length < 20) {
|
|
89831
89925
|
rid = "0".repeat(20 - rid.length) + rid;
|
|
89832
89926
|
}
|
|
@@ -90913,12 +91007,12 @@ var require_imap_flow = __commonJS({
|
|
|
90913
91007
|
this.emit("flags", updateEvent);
|
|
90914
91008
|
}
|
|
90915
91009
|
}
|
|
90916
|
-
async ensureSelectedMailbox(
|
|
90917
|
-
if (!
|
|
91010
|
+
async ensureSelectedMailbox(path22) {
|
|
91011
|
+
if (!path22) {
|
|
90918
91012
|
return false;
|
|
90919
91013
|
}
|
|
90920
|
-
if (!this.mailbox || !comparePaths(this, this.mailbox.path,
|
|
90921
|
-
return await this.mailboxOpen(
|
|
91014
|
+
if (!this.mailbox || !comparePaths(this, this.mailbox.path, path22)) {
|
|
91015
|
+
return await this.mailboxOpen(path22);
|
|
90922
91016
|
}
|
|
90923
91017
|
return true;
|
|
90924
91018
|
}
|
|
@@ -91333,9 +91427,9 @@ var require_imap_flow = __commonJS({
|
|
|
91333
91427
|
* let quota = await client.getQuota();
|
|
91334
91428
|
* console.log(quota.storage.used, quota.storage.limit)
|
|
91335
91429
|
*/
|
|
91336
|
-
async getQuota(
|
|
91337
|
-
|
|
91338
|
-
return await this.run("QUOTA",
|
|
91430
|
+
async getQuota(path22) {
|
|
91431
|
+
path22 = path22 || "INBOX";
|
|
91432
|
+
return await this.run("QUOTA", path22);
|
|
91339
91433
|
}
|
|
91340
91434
|
/**
|
|
91341
91435
|
* @typedef {Object} ListResponse
|
|
@@ -91445,8 +91539,8 @@ var require_imap_flow = __commonJS({
|
|
|
91445
91539
|
* console.log(info.path);
|
|
91446
91540
|
* // "INBOX.parent.child" // assumes "INBOX." as namespace prefix and "." as delimiter
|
|
91447
91541
|
*/
|
|
91448
|
-
async mailboxCreate(
|
|
91449
|
-
return await this.run("CREATE",
|
|
91542
|
+
async mailboxCreate(path22) {
|
|
91543
|
+
return await this.run("CREATE", path22);
|
|
91450
91544
|
}
|
|
91451
91545
|
/**
|
|
91452
91546
|
* @typedef {Object} MailboxRenameResponse
|
|
@@ -91467,8 +91561,8 @@ var require_imap_flow = __commonJS({
|
|
|
91467
91561
|
* console.log(info.newPath);
|
|
91468
91562
|
* // "INBOX.Important stuff ❗️" // assumes "INBOX." as namespace prefix
|
|
91469
91563
|
*/
|
|
91470
|
-
async mailboxRename(
|
|
91471
|
-
return await this.run("RENAME",
|
|
91564
|
+
async mailboxRename(path22, newPath) {
|
|
91565
|
+
return await this.run("RENAME", path22, newPath);
|
|
91472
91566
|
}
|
|
91473
91567
|
/**
|
|
91474
91568
|
* @typedef {Object} MailboxDeleteResponse
|
|
@@ -91487,8 +91581,8 @@ var require_imap_flow = __commonJS({
|
|
|
91487
91581
|
* console.log(info.path);
|
|
91488
91582
|
* // "INBOX.Important stuff ❗️" // assumes "INBOX." as namespace prefix
|
|
91489
91583
|
*/
|
|
91490
|
-
async mailboxDelete(
|
|
91491
|
-
return await this.run("DELETE",
|
|
91584
|
+
async mailboxDelete(path22) {
|
|
91585
|
+
return await this.run("DELETE", path22);
|
|
91492
91586
|
}
|
|
91493
91587
|
/**
|
|
91494
91588
|
* Subscribes to a mailbox
|
|
@@ -91499,8 +91593,8 @@ var require_imap_flow = __commonJS({
|
|
|
91499
91593
|
* @example
|
|
91500
91594
|
* await client.mailboxSubscribe('Important stuff ❗️');
|
|
91501
91595
|
*/
|
|
91502
|
-
async mailboxSubscribe(
|
|
91503
|
-
return await this.run("SUBSCRIBE",
|
|
91596
|
+
async mailboxSubscribe(path22) {
|
|
91597
|
+
return await this.run("SUBSCRIBE", path22);
|
|
91504
91598
|
}
|
|
91505
91599
|
/**
|
|
91506
91600
|
* Unsubscribes from a mailbox
|
|
@@ -91511,8 +91605,8 @@ var require_imap_flow = __commonJS({
|
|
|
91511
91605
|
* @example
|
|
91512
91606
|
* await client.mailboxUnsubscribe('Important stuff ❗️');
|
|
91513
91607
|
*/
|
|
91514
|
-
async mailboxUnsubscribe(
|
|
91515
|
-
return await this.run("UNSUBSCRIBE",
|
|
91608
|
+
async mailboxUnsubscribe(path22) {
|
|
91609
|
+
return await this.run("UNSUBSCRIBE", path22);
|
|
91516
91610
|
}
|
|
91517
91611
|
/**
|
|
91518
91612
|
* Opens a mailbox to access messages. You can perform message operations only against an opened mailbox.
|
|
@@ -91530,8 +91624,8 @@ var require_imap_flow = __commonJS({
|
|
|
91530
91624
|
* console.log(mailbox.exists);
|
|
91531
91625
|
* // 125
|
|
91532
91626
|
*/
|
|
91533
|
-
async mailboxOpen(
|
|
91534
|
-
return await this.run("SELECT",
|
|
91627
|
+
async mailboxOpen(path22, options) {
|
|
91628
|
+
return await this.run("SELECT", path22, options);
|
|
91535
91629
|
}
|
|
91536
91630
|
/**
|
|
91537
91631
|
* Closes a previously opened mailbox
|
|
@@ -91578,8 +91672,8 @@ var require_imap_flow = __commonJS({
|
|
|
91578
91672
|
* console.log(status.unseen);
|
|
91579
91673
|
* // 123
|
|
91580
91674
|
*/
|
|
91581
|
-
async status(
|
|
91582
|
-
return await this.run("STATUS",
|
|
91675
|
+
async status(path22, query) {
|
|
91676
|
+
return await this.run("STATUS", path22, query);
|
|
91583
91677
|
}
|
|
91584
91678
|
/**
|
|
91585
91679
|
* Starts listening for new or deleted messages from the currently opened mailbox. Only required if {@link ImapFlow#disableAutoIdle} is set to `true`
|
|
@@ -91833,8 +91927,8 @@ var require_imap_flow = __commonJS({
|
|
|
91833
91927
|
* @example
|
|
91834
91928
|
* await client.append('INBOX', rawMessageBuffer, ['\\Seen'], new Date(2000, 1, 1));
|
|
91835
91929
|
*/
|
|
91836
|
-
async append(
|
|
91837
|
-
return await this.run("APPEND",
|
|
91930
|
+
async append(path22, content, flags, idate) {
|
|
91931
|
+
return await this.run("APPEND", path22, content, flags, idate) || false;
|
|
91838
91932
|
}
|
|
91839
91933
|
/**
|
|
91840
91934
|
* @typedef {Object} CopyResponseObject
|
|
@@ -92678,7 +92772,7 @@ var require_imap_flow = __commonJS({
|
|
|
92678
92772
|
await new Promise((resolve2) => setImmediate(resolve2));
|
|
92679
92773
|
}
|
|
92680
92774
|
const lock = this.locks.shift();
|
|
92681
|
-
const { resolve, reject, path:
|
|
92775
|
+
const { resolve, reject, path: path22, options, lockId } = lock;
|
|
92682
92776
|
if (lock.acquireTimer) {
|
|
92683
92777
|
clearTimeout(lock.acquireTimer);
|
|
92684
92778
|
lock.acquireTimer = null;
|
|
@@ -92694,7 +92788,7 @@ var require_imap_flow = __commonJS({
|
|
|
92694
92788
|
this.log.warn({
|
|
92695
92789
|
msg: "Mailbox lock held for a long time",
|
|
92696
92790
|
lockId: lock.lockId,
|
|
92697
|
-
path:
|
|
92791
|
+
path: path22,
|
|
92698
92792
|
heldFor: Date.now() - lock.heldAt,
|
|
92699
92793
|
/* c8 ignore next */
|
|
92700
92794
|
// the held-lock-warning diagnostic with a description set is a timing-dependent log detail
|
|
@@ -92730,52 +92824,52 @@ var require_imap_flow = __commonJS({
|
|
|
92730
92824
|
}
|
|
92731
92825
|
};
|
|
92732
92826
|
if (!this.usable || !this.socket || this.socket.destroyed) {
|
|
92733
|
-
this.log.trace({ msg: "Failed to acquire mailbox lock", path:
|
|
92827
|
+
this.log.trace({ msg: "Failed to acquire mailbox lock", path: path22, lockId, idling: this.idling });
|
|
92734
92828
|
let error2 = new Error("Connection not available");
|
|
92735
92829
|
error2.code = "NoConnection";
|
|
92736
92830
|
reject(error2);
|
|
92737
92831
|
continue;
|
|
92738
92832
|
}
|
|
92739
|
-
if (this.mailbox && this.mailbox.path ===
|
|
92833
|
+
if (this.mailbox && this.mailbox.path === path22 && !!this.mailbox.readOnly === !!options.readOnly) {
|
|
92740
92834
|
this.log.trace({
|
|
92741
92835
|
msg: "Mailbox lock acquired [existing]",
|
|
92742
|
-
path:
|
|
92836
|
+
path: path22,
|
|
92743
92837
|
lockId,
|
|
92744
92838
|
idling: this.idling,
|
|
92745
92839
|
...options.description && { description: options.description }
|
|
92746
92840
|
});
|
|
92747
92841
|
this.currentLock = lock;
|
|
92748
92842
|
armHeldTimer();
|
|
92749
|
-
resolve({ path:
|
|
92843
|
+
resolve({ path: path22, release });
|
|
92750
92844
|
break;
|
|
92751
92845
|
}
|
|
92752
92846
|
try {
|
|
92753
|
-
await this.mailboxOpen(
|
|
92847
|
+
await this.mailboxOpen(path22, options);
|
|
92754
92848
|
this.log.trace({
|
|
92755
92849
|
msg: "Mailbox lock acquired [selected]",
|
|
92756
|
-
path:
|
|
92850
|
+
path: path22,
|
|
92757
92851
|
lockId,
|
|
92758
92852
|
idling: this.idling,
|
|
92759
92853
|
...options.description && { description: options.description }
|
|
92760
92854
|
});
|
|
92761
92855
|
this.currentLock = lock;
|
|
92762
92856
|
armHeldTimer();
|
|
92763
|
-
resolve({ path:
|
|
92857
|
+
resolve({ path: path22, release });
|
|
92764
92858
|
break;
|
|
92765
92859
|
} catch (err) {
|
|
92766
92860
|
if (err.responseStatus === "NO") {
|
|
92767
92861
|
try {
|
|
92768
|
-
let folders = await this.run("LIST", "",
|
|
92862
|
+
let folders = await this.run("LIST", "", path22, { listOnly: true });
|
|
92769
92863
|
if (!folders || !folders.length) {
|
|
92770
92864
|
err.mailboxMissing = true;
|
|
92771
92865
|
}
|
|
92772
92866
|
} catch (E) {
|
|
92773
|
-
this.log.trace({ msg: "Failed to verify failed mailbox", path:
|
|
92867
|
+
this.log.trace({ msg: "Failed to verify failed mailbox", path: path22, err: E });
|
|
92774
92868
|
}
|
|
92775
92869
|
}
|
|
92776
92870
|
this.log.trace({
|
|
92777
92871
|
msg: "Failed to acquire mailbox lock",
|
|
92778
|
-
path:
|
|
92872
|
+
path: path22,
|
|
92779
92873
|
lockId,
|
|
92780
92874
|
idling: this.idling,
|
|
92781
92875
|
...options.description && { description: options.description },
|
|
@@ -92814,13 +92908,13 @@ var require_imap_flow = __commonJS({
|
|
|
92814
92908
|
* lock.release();
|
|
92815
92909
|
* }
|
|
92816
92910
|
*/
|
|
92817
|
-
getMailboxLock(
|
|
92911
|
+
getMailboxLock(path22, options) {
|
|
92818
92912
|
options = options || {};
|
|
92819
|
-
|
|
92913
|
+
path22 = normalizePath(this, path22);
|
|
92820
92914
|
let lockId = ++this.lockCounter;
|
|
92821
92915
|
this.log.trace({
|
|
92822
92916
|
msg: "Requesting lock",
|
|
92823
|
-
path:
|
|
92917
|
+
path: path22,
|
|
92824
92918
|
lockId,
|
|
92825
92919
|
...options.description && { description: options.description },
|
|
92826
92920
|
activeLock: this.currentLock ? {
|
|
@@ -92829,7 +92923,7 @@ var require_imap_flow = __commonJS({
|
|
|
92829
92923
|
} : null
|
|
92830
92924
|
});
|
|
92831
92925
|
let lockPromise = new Promise((resolve, reject) => {
|
|
92832
|
-
let lockEntry = { resolve, reject, path:
|
|
92926
|
+
let lockEntry = { resolve, reject, path: path22, options, lockId };
|
|
92833
92927
|
this.locks.push(lockEntry);
|
|
92834
92928
|
if (Number(options.acquireTimeout) > 0) {
|
|
92835
92929
|
lockEntry.acquireTimer = setTimeout(() => {
|
|
@@ -92918,16 +93012,16 @@ var require_imap_flow = __commonJS({
|
|
|
92918
93012
|
});
|
|
92919
93013
|
|
|
92920
93014
|
// src/mail/mail-fetcher.ts
|
|
92921
|
-
import
|
|
92922
|
-
import
|
|
93015
|
+
import fs19 from "node:fs/promises";
|
|
93016
|
+
import path20 from "node:path";
|
|
92923
93017
|
async function saveAttachments(attachments, downloadDir) {
|
|
92924
93018
|
if (attachments.length === 0) return [];
|
|
92925
|
-
await
|
|
93019
|
+
await fs19.mkdir(downloadDir, { recursive: true });
|
|
92926
93020
|
const saved = [];
|
|
92927
93021
|
for (const a of attachments) {
|
|
92928
|
-
const name =
|
|
92929
|
-
const savedPath =
|
|
92930
|
-
await
|
|
93022
|
+
const name = path20.basename(a.filename) || "attachment";
|
|
93023
|
+
const savedPath = path20.join(downloadDir, name);
|
|
93024
|
+
await fs19.writeFile(savedPath, a.content);
|
|
92931
93025
|
saved.push({ filename: name, savedPath, size: a.content.length });
|
|
92932
93026
|
}
|
|
92933
93027
|
return saved;
|
|
@@ -93057,8 +93151,8 @@ var init_mail_fetcher = __esm({
|
|
|
93057
93151
|
});
|
|
93058
93152
|
|
|
93059
93153
|
// src/tools/fetch-mail.ts
|
|
93060
|
-
import
|
|
93061
|
-
import
|
|
93154
|
+
import os14 from "node:os";
|
|
93155
|
+
import path21 from "node:path";
|
|
93062
93156
|
function registerFetchMailTool(server, deps = {}) {
|
|
93063
93157
|
const makeFetcher = deps.fetcherFactory ?? ((creds) => new ImapflowMailFetcher(creds));
|
|
93064
93158
|
server.registerTool(
|
|
@@ -93120,7 +93214,7 @@ var init_fetch_mail = __esm({
|
|
|
93120
93214
|
init_mail_fetcher();
|
|
93121
93215
|
init_auth_error();
|
|
93122
93216
|
init_validate();
|
|
93123
|
-
DEFAULT_DOWNLOAD_DIR =
|
|
93217
|
+
DEFAULT_DOWNLOAD_DIR = path21.join(os14.homedir(), ".cogent", "mail-downloads");
|
|
93124
93218
|
}
|
|
93125
93219
|
});
|
|
93126
93220
|
|