llonebot-dist 7.12.2 → 7.12.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/llbot.js +942 -173
- package/llbot.js.map +1 -1
- package/package.json +1 -1
- package/webui/assets/{index-CW4srXaj.css → index-BvJQpqZQ.css} +1 -1
- package/webui/assets/{index-B0ADks6f.js → index-XoTA3kAm.js} +4 -4
- package/webui/index.html +2 -2
- package//346/233/264/346/226/260/346/227/245/345/277/227.txt +11 -0
package/llbot.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
import * as path$4 from "node:path";
|
|
3
|
-
import path, { dirname } from "node:path";
|
|
3
|
+
import path, { dirname, join } from "node:path";
|
|
4
4
|
import fs, { access, copyFile, mkdir, readFile, stat, unlink, writeFile } from "node:fs/promises";
|
|
5
|
-
import fs$1, {
|
|
6
|
-
import { Readable } from "stream";
|
|
5
|
+
import fs$1, { existsSync } from "fs";
|
|
7
6
|
import * as fs$6 from "node:fs";
|
|
8
|
-
import fs$2, { appendFile, appendFileSync, createReadStream
|
|
7
|
+
import fs$2, { appendFile, appendFileSync, createReadStream, existsSync as existsSync$1, mkdirSync, promises, stat as stat$1, statSync, watch } from "node:fs";
|
|
9
8
|
import os from "node:os";
|
|
10
9
|
import { Binary, Time, camelize, clone, deduplicate, deepEqual, defineProperty, difference, filterKeys, hyphenate, is, isNonNullable, isNullable, isPlainObject, makeArray, mapValues, noop, omit, pick, remove, valueMap } from "cosmokit";
|
|
11
10
|
import { Exporter, Factory } from "reggol";
|
|
12
|
-
import path$1
|
|
11
|
+
import path$1 from "path";
|
|
13
12
|
import { networkInterfaces } from "os";
|
|
14
13
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
15
14
|
import { WebSocket as WebSocket$1, WebSocketServer } from "ws";
|
|
@@ -17,17 +16,15 @@ import { constants } from "node:buffer";
|
|
|
17
16
|
import crypto$1, { createHash, randomBytes, randomInt, randomUUID } from "node:crypto";
|
|
18
17
|
import * as fileType from "file-type";
|
|
19
18
|
import { decode, encode, getDuration, getWavFileInfo, isSilk, isWav } from "silk-wasm";
|
|
20
|
-
import { createServer } from "http";
|
|
21
|
-
import { Http2ServerRequest, constants as constants$1 } from "http2";
|
|
22
|
-
import
|
|
19
|
+
import http, { STATUS_CODES, createServer, request } from "node:http";
|
|
20
|
+
import { Http2ServerRequest, constants as constants$1 } from "node:http2";
|
|
21
|
+
import { Readable, Transform } from "node:stream";
|
|
23
22
|
import { deflateSync, gunzipSync, gzipSync, inflateSync } from "node:zlib";
|
|
24
23
|
import fsPromise, { stat as stat$2, unlink as unlink$1 } from "fs/promises";
|
|
25
|
-
import http, { STATUS_CODES, request } from "node:http";
|
|
26
24
|
import { inspect, isDeepStrictEqual } from "node:util";
|
|
27
|
-
import { Transform } from "node:stream";
|
|
28
25
|
import net, { connect } from "node:net";
|
|
29
26
|
import https from "node:https";
|
|
30
|
-
import { versions } from "process";
|
|
27
|
+
import { versions } from "node:process";
|
|
31
28
|
//#region \0rolldown/runtime.js
|
|
32
29
|
var __create$2 = Object.create;
|
|
33
30
|
var __defProp$9 = Object.defineProperty;
|
|
@@ -36,7 +33,7 @@ var __getOwnPropNames$2 = Object.getOwnPropertyNames;
|
|
|
36
33
|
var __getProtoOf = Object.getPrototypeOf;
|
|
37
34
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
38
35
|
var __esmMin = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
39
|
-
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
36
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
40
37
|
var __exportAll = (all, no_symbols) => {
|
|
41
38
|
let target = {};
|
|
42
39
|
for (var name in all) __defProp$9(target, name, {
|
|
@@ -1623,6 +1620,9 @@ var require_dijkstra = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1623
1620
|
var predecessors = dijkstra.single_source_shortest_paths(graph, s, d);
|
|
1624
1621
|
return dijkstra.extract_shortest_path_from_predecessor_list(predecessors, d);
|
|
1625
1622
|
},
|
|
1623
|
+
/**
|
|
1624
|
+
* A very naive priority queue implementation.
|
|
1625
|
+
*/
|
|
1626
1626
|
PriorityQueue: {
|
|
1627
1627
|
make: function(opts) {
|
|
1628
1628
|
var T = dijkstra.PriorityQueue, t = {}, key;
|
|
@@ -1635,6 +1635,10 @@ var require_dijkstra = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1635
1635
|
default_sorter: function(a, b) {
|
|
1636
1636
|
return a.cost - b.cost;
|
|
1637
1637
|
},
|
|
1638
|
+
/**
|
|
1639
|
+
* Add a new item to the queue and ensure the highest priority element
|
|
1640
|
+
* is at the front of the queue.
|
|
1641
|
+
*/
|
|
1638
1642
|
push: function(value, cost) {
|
|
1639
1643
|
var item = {
|
|
1640
1644
|
value,
|
|
@@ -1643,6 +1647,9 @@ var require_dijkstra = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1643
1647
|
this.queue.push(item);
|
|
1644
1648
|
this.queue.sort(this.sorter);
|
|
1645
1649
|
},
|
|
1650
|
+
/**
|
|
1651
|
+
* Return the highest priority element in the queue.
|
|
1652
|
+
*/
|
|
1646
1653
|
pop: function() {
|
|
1647
1654
|
return this.queue.shift();
|
|
1648
1655
|
},
|
|
@@ -3509,7 +3516,8 @@ var require_packer_async = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
3509
3516
|
var Packer = require_packer();
|
|
3510
3517
|
var PackerAsync = module.exports = function(opt) {
|
|
3511
3518
|
Stream$2.call(this);
|
|
3512
|
-
|
|
3519
|
+
let options = opt || {};
|
|
3520
|
+
this._packer = new Packer(options);
|
|
3513
3521
|
this._deflate = this._packer.createDeflate();
|
|
3514
3522
|
this.readable = true;
|
|
3515
3523
|
};
|
|
@@ -6506,20 +6514,20 @@ var MsgType = /* @__PURE__ */ function(MsgType) {
|
|
|
6506
6514
|
//#region src/ntqqapi/types/notify.ts
|
|
6507
6515
|
var GroupNotifyType = /* @__PURE__ */ function(GroupNotifyType) {
|
|
6508
6516
|
GroupNotifyType[GroupNotifyType["InvitedByMember"] = 1] = "InvitedByMember";
|
|
6509
|
-
GroupNotifyType[GroupNotifyType["RefuseInvited"] =
|
|
6510
|
-
GroupNotifyType[GroupNotifyType["RefusedByAdminiStrator"] =
|
|
6511
|
-
GroupNotifyType[GroupNotifyType["AgreedTojoinDirect"] =
|
|
6512
|
-
GroupNotifyType[GroupNotifyType["InvitedNeedAdminiStratorPass"] =
|
|
6513
|
-
GroupNotifyType[GroupNotifyType["AgreedToJoinByAdminiStrator"] =
|
|
6514
|
-
GroupNotifyType[GroupNotifyType["RequestJoinNeedAdminiStratorPass"] =
|
|
6515
|
-
GroupNotifyType[GroupNotifyType["SetAdmin"] =
|
|
6516
|
-
GroupNotifyType[GroupNotifyType["KickMemberNotifyAdmin"] =
|
|
6517
|
-
GroupNotifyType[GroupNotifyType["KickMemberNotifyKicked"] =
|
|
6518
|
-
GroupNotifyType[GroupNotifyType["MemberLeaveNotifyAdmin"] =
|
|
6519
|
-
GroupNotifyType[GroupNotifyType["CancelAdminNotifyCanceled"] =
|
|
6520
|
-
GroupNotifyType[GroupNotifyType["CancelAdminNotifyAdmin"] =
|
|
6521
|
-
GroupNotifyType[GroupNotifyType["TransferGroupNotifyOldowner"] =
|
|
6522
|
-
GroupNotifyType[GroupNotifyType["TransferGroupNotifyAdmin"] =
|
|
6517
|
+
GroupNotifyType[GroupNotifyType["RefuseInvited"] = 1 + GroupNotifyType["InvitedByMember"]] = "RefuseInvited";
|
|
6518
|
+
GroupNotifyType[GroupNotifyType["RefusedByAdminiStrator"] = 1 + GroupNotifyType["RefuseInvited"]] = "RefusedByAdminiStrator";
|
|
6519
|
+
GroupNotifyType[GroupNotifyType["AgreedTojoinDirect"] = 1 + GroupNotifyType["RefusedByAdminiStrator"]] = "AgreedTojoinDirect";
|
|
6520
|
+
GroupNotifyType[GroupNotifyType["InvitedNeedAdminiStratorPass"] = 1 + GroupNotifyType["AgreedTojoinDirect"]] = "InvitedNeedAdminiStratorPass";
|
|
6521
|
+
GroupNotifyType[GroupNotifyType["AgreedToJoinByAdminiStrator"] = 1 + GroupNotifyType["InvitedNeedAdminiStratorPass"]] = "AgreedToJoinByAdminiStrator";
|
|
6522
|
+
GroupNotifyType[GroupNotifyType["RequestJoinNeedAdminiStratorPass"] = 1 + GroupNotifyType["AgreedToJoinByAdminiStrator"]] = "RequestJoinNeedAdminiStratorPass";
|
|
6523
|
+
GroupNotifyType[GroupNotifyType["SetAdmin"] = 1 + GroupNotifyType["RequestJoinNeedAdminiStratorPass"]] = "SetAdmin";
|
|
6524
|
+
GroupNotifyType[GroupNotifyType["KickMemberNotifyAdmin"] = 1 + GroupNotifyType["SetAdmin"]] = "KickMemberNotifyAdmin";
|
|
6525
|
+
GroupNotifyType[GroupNotifyType["KickMemberNotifyKicked"] = 1 + GroupNotifyType["KickMemberNotifyAdmin"]] = "KickMemberNotifyKicked";
|
|
6526
|
+
GroupNotifyType[GroupNotifyType["MemberLeaveNotifyAdmin"] = 1 + GroupNotifyType["KickMemberNotifyKicked"]] = "MemberLeaveNotifyAdmin";
|
|
6527
|
+
GroupNotifyType[GroupNotifyType["CancelAdminNotifyCanceled"] = 1 + GroupNotifyType["MemberLeaveNotifyAdmin"]] = "CancelAdminNotifyCanceled";
|
|
6528
|
+
GroupNotifyType[GroupNotifyType["CancelAdminNotifyAdmin"] = 1 + GroupNotifyType["CancelAdminNotifyCanceled"]] = "CancelAdminNotifyAdmin";
|
|
6529
|
+
GroupNotifyType[GroupNotifyType["TransferGroupNotifyOldowner"] = 1 + GroupNotifyType["CancelAdminNotifyAdmin"]] = "TransferGroupNotifyOldowner";
|
|
6530
|
+
GroupNotifyType[GroupNotifyType["TransferGroupNotifyAdmin"] = 1 + GroupNotifyType["TransferGroupNotifyOldowner"]] = "TransferGroupNotifyAdmin";
|
|
6523
6531
|
return GroupNotifyType;
|
|
6524
6532
|
}({});
|
|
6525
6533
|
var GroupNotifyStatus = /* @__PURE__ */ function(GroupNotifyStatus) {
|
|
@@ -6832,11 +6840,30 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
6832
6840
|
var utils = module.exports = {
|
|
6833
6841
|
isWindows,
|
|
6834
6842
|
streamRegexp,
|
|
6843
|
+
/**
|
|
6844
|
+
* Copy an object keys into another one
|
|
6845
|
+
*
|
|
6846
|
+
* @param {Object} source source object
|
|
6847
|
+
* @param {Object} dest destination object
|
|
6848
|
+
* @private
|
|
6849
|
+
*/
|
|
6835
6850
|
copy: function(source, dest) {
|
|
6836
6851
|
Object.keys(source).forEach(function(key) {
|
|
6837
6852
|
dest[key] = source[key];
|
|
6838
6853
|
});
|
|
6839
6854
|
},
|
|
6855
|
+
/**
|
|
6856
|
+
* Create an argument list
|
|
6857
|
+
*
|
|
6858
|
+
* Returns a function that adds new arguments to the list.
|
|
6859
|
+
* It also has the following methods:
|
|
6860
|
+
* - clear() empties the argument list
|
|
6861
|
+
* - get() returns the argument list
|
|
6862
|
+
* - find(arg, count) finds 'arg' in the list and return the following 'count' items, or undefined if not found
|
|
6863
|
+
* - remove(arg, count) remove 'arg' in the list as well as the following 'count' items
|
|
6864
|
+
*
|
|
6865
|
+
* @private
|
|
6866
|
+
*/
|
|
6840
6867
|
args: function() {
|
|
6841
6868
|
var list = [];
|
|
6842
6869
|
var argfunc = function() {
|
|
@@ -6864,6 +6891,20 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
6864
6891
|
};
|
|
6865
6892
|
return argfunc;
|
|
6866
6893
|
},
|
|
6894
|
+
/**
|
|
6895
|
+
* Generate filter strings
|
|
6896
|
+
*
|
|
6897
|
+
* @param {String[]|Object[]} filters filter specifications. When using objects,
|
|
6898
|
+
* each must have the following properties:
|
|
6899
|
+
* @param {String} filters.filter filter name
|
|
6900
|
+
* @param {String|Array} [filters.inputs] (array of) input stream specifier(s) for the filter,
|
|
6901
|
+
* defaults to ffmpeg automatically choosing the first unused matching streams
|
|
6902
|
+
* @param {String|Array} [filters.outputs] (array of) output stream specifier(s) for the filter,
|
|
6903
|
+
* defaults to ffmpeg automatically assigning the output to the output file
|
|
6904
|
+
* @param {Object|String|Array} [filters.options] filter options, can be omitted to not set any options
|
|
6905
|
+
* @return String[]
|
|
6906
|
+
* @private
|
|
6907
|
+
*/
|
|
6867
6908
|
makeFilterStrings: function(filters) {
|
|
6868
6909
|
return filters.map(function(filterSpec) {
|
|
6869
6910
|
if (typeof filterSpec === "string") return filterSpec;
|
|
@@ -6892,6 +6933,15 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
6892
6933
|
return filterString;
|
|
6893
6934
|
});
|
|
6894
6935
|
},
|
|
6936
|
+
/**
|
|
6937
|
+
* Search for an executable
|
|
6938
|
+
*
|
|
6939
|
+
* Uses 'which' or 'where' depending on platform
|
|
6940
|
+
*
|
|
6941
|
+
* @param {String} name executable name
|
|
6942
|
+
* @param {Function} callback callback with signature (err, path)
|
|
6943
|
+
* @private
|
|
6944
|
+
*/
|
|
6895
6945
|
which: function(name, callback) {
|
|
6896
6946
|
if (name in whichCache) return callback(null, whichCache[name]);
|
|
6897
6947
|
which(name, function(err, result) {
|
|
@@ -6899,6 +6949,13 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
6899
6949
|
callback(null, whichCache[name] = result);
|
|
6900
6950
|
});
|
|
6901
6951
|
},
|
|
6952
|
+
/**
|
|
6953
|
+
* Convert a [[hh:]mm:]ss[.xxx] timemark into seconds
|
|
6954
|
+
*
|
|
6955
|
+
* @param {String} timemark timemark string
|
|
6956
|
+
* @return Number
|
|
6957
|
+
* @private
|
|
6958
|
+
*/
|
|
6902
6959
|
timemarkToSeconds: function(timemark) {
|
|
6903
6960
|
if (typeof timemark === "number") return timemark;
|
|
6904
6961
|
if (timemark.indexOf(":") === -1 && timemark.indexOf(".") >= 0) return Number(timemark);
|
|
@@ -6908,6 +6965,16 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
6908
6965
|
if (parts.length) secs += Number(parts.pop()) * 3600;
|
|
6909
6966
|
return secs;
|
|
6910
6967
|
},
|
|
6968
|
+
/**
|
|
6969
|
+
* Extract codec data from ffmpeg stderr and emit 'codecData' event if appropriate
|
|
6970
|
+
* Call it with an initially empty codec object once with each line of stderr output until it returns true
|
|
6971
|
+
*
|
|
6972
|
+
* @param {FfmpegCommand} command event emitter
|
|
6973
|
+
* @param {String} stderrLine ffmpeg stderr output line
|
|
6974
|
+
* @param {Object} codecObject object used to accumulate codec data between calls
|
|
6975
|
+
* @return {Boolean} true if codec data is complete (and event was emitted), false otherwise
|
|
6976
|
+
* @private
|
|
6977
|
+
*/
|
|
6911
6978
|
extractCodecData: function(command, stderrLine, codecsObject) {
|
|
6912
6979
|
var inputPattern = /Input #[0-9]+, ([^ ]+),/;
|
|
6913
6980
|
var durPattern = /Duration\: ([^,]+)/;
|
|
@@ -6947,6 +7014,13 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
6947
7014
|
}
|
|
6948
7015
|
return false;
|
|
6949
7016
|
},
|
|
7017
|
+
/**
|
|
7018
|
+
* Extract progress data from ffmpeg stderr and emit 'progress' event if appropriate
|
|
7019
|
+
*
|
|
7020
|
+
* @param {FfmpegCommand} command event emitter
|
|
7021
|
+
* @param {String} stderrLine ffmpeg stderr data
|
|
7022
|
+
* @private
|
|
7023
|
+
*/
|
|
6950
7024
|
extractProgress: function(command, stderrLine) {
|
|
6951
7025
|
var progress = parseProgressLine(stderrLine);
|
|
6952
7026
|
if (progress) {
|
|
@@ -6964,6 +7038,13 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
6964
7038
|
command.emit("progress", ret);
|
|
6965
7039
|
}
|
|
6966
7040
|
},
|
|
7041
|
+
/**
|
|
7042
|
+
* Extract error message(s) from ffmpeg stderr
|
|
7043
|
+
*
|
|
7044
|
+
* @param {String} stderr ffmpeg stderr data
|
|
7045
|
+
* @return {String}
|
|
7046
|
+
* @private
|
|
7047
|
+
*/
|
|
6967
7048
|
extractError: function(stderr) {
|
|
6968
7049
|
return stderr.split(nlRegexp).reduce(function(messages, message) {
|
|
6969
7050
|
if (message.charAt(0) === " " || message.charAt(0) === "[") return [];
|
|
@@ -6973,6 +7054,15 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
6973
7054
|
}
|
|
6974
7055
|
}, []).join("\n");
|
|
6975
7056
|
},
|
|
7057
|
+
/**
|
|
7058
|
+
* Creates a line ring buffer object with the following methods:
|
|
7059
|
+
* - append(str) : appends a string or buffer
|
|
7060
|
+
* - get() : returns the whole string
|
|
7061
|
+
* - close() : prevents further append() calls and does a last call to callbacks
|
|
7062
|
+
* - callback(cb) : calls cb for each line (incl. those already in the ring)
|
|
7063
|
+
*
|
|
7064
|
+
* @param {Number} maxLines maximum number of lines to store (<= 0 for unlimited)
|
|
7065
|
+
*/
|
|
6976
7066
|
linesRing: function(maxLines) {
|
|
6977
7067
|
var cbs = [];
|
|
6978
7068
|
var lines = [];
|
|
@@ -11292,7 +11382,7 @@ var OB11HeartbeatEvent = class extends OB11BaseMetaEvent {
|
|
|
11292
11382
|
};
|
|
11293
11383
|
//#endregion
|
|
11294
11384
|
//#region src/version.ts
|
|
11295
|
-
var version$2 = "7.12.
|
|
11385
|
+
var version$2 = "7.12.3";
|
|
11296
11386
|
//#endregion
|
|
11297
11387
|
//#region node_modules/sift/es5m/index.js
|
|
11298
11388
|
/******************************************************************************
|
|
@@ -11726,7 +11816,8 @@ var $In = function(_super) {
|
|
|
11726
11816
|
}
|
|
11727
11817
|
$In.prototype.init = function() {
|
|
11728
11818
|
var _this = this;
|
|
11729
|
-
|
|
11819
|
+
var params = Array.isArray(this.params) ? this.params : [this.params];
|
|
11820
|
+
this._testers = params.map(function(value) {
|
|
11730
11821
|
if (containsOperation(value, _this.options)) throw new Error("cannot nest $ under ".concat(_this.name.toLowerCase()));
|
|
11731
11822
|
return createTester(value, _this.options.compare);
|
|
11732
11823
|
});
|
|
@@ -20295,6 +20386,27 @@ var streamSSE = (c, cb, onError) => {
|
|
|
20295
20386
|
return c.newResponse(stream.responseReadable);
|
|
20296
20387
|
};
|
|
20297
20388
|
//#endregion
|
|
20389
|
+
//#region node_modules/hono/dist/helper/websocket/index.js
|
|
20390
|
+
var defineWebSocketHelper = (handler) => {
|
|
20391
|
+
return ((...args) => {
|
|
20392
|
+
if (typeof args[0] === "function") {
|
|
20393
|
+
const [createEvents, options] = args;
|
|
20394
|
+
return async function upgradeWebSocket(c, next) {
|
|
20395
|
+
const result = await handler(c, await createEvents(c), options);
|
|
20396
|
+
if (result) return result;
|
|
20397
|
+
await next();
|
|
20398
|
+
};
|
|
20399
|
+
} else {
|
|
20400
|
+
const [c, events, options] = args;
|
|
20401
|
+
return (async () => {
|
|
20402
|
+
const upgraded = await handler(c, events, options);
|
|
20403
|
+
if (!upgraded) throw new Error("Failed to upgrade WebSocket");
|
|
20404
|
+
return upgraded;
|
|
20405
|
+
})();
|
|
20406
|
+
}
|
|
20407
|
+
});
|
|
20408
|
+
};
|
|
20409
|
+
//#endregion
|
|
20298
20410
|
//#region node_modules/@hono/node-server/dist/index.mjs
|
|
20299
20411
|
var RequestError = class extends Error {
|
|
20300
20412
|
constructor(message, options) {
|
|
@@ -20302,6 +20414,22 @@ var RequestError = class extends Error {
|
|
|
20302
20414
|
this.name = "RequestError";
|
|
20303
20415
|
}
|
|
20304
20416
|
};
|
|
20417
|
+
var reValidRequestUrl = /^\/[!#$&-;=?-\[\]_a-z~]*$/;
|
|
20418
|
+
var reDotSegment = /\/\.\.?(?:[/?#]|$)/;
|
|
20419
|
+
var reValidHost = /^[a-z0-9._-]+(?::(?:[1-5]\d{3,4}|[6-9]\d{3}))?$/;
|
|
20420
|
+
var buildUrl = (scheme, host, incomingUrl) => {
|
|
20421
|
+
const url = `${scheme}://${host}${incomingUrl}`;
|
|
20422
|
+
if (!reValidHost.test(host)) {
|
|
20423
|
+
const urlObj = new URL(url);
|
|
20424
|
+
if (urlObj.hostname.length !== host.length && urlObj.hostname !== (host.includes(":") ? host.replace(/:\d+$/, "") : host).toLowerCase()) throw new RequestError("Invalid host header");
|
|
20425
|
+
return urlObj.href;
|
|
20426
|
+
} else if (incomingUrl.length === 0) return url + "/";
|
|
20427
|
+
else {
|
|
20428
|
+
if (incomingUrl.charCodeAt(0) !== 47) throw new RequestError("Invalid URL");
|
|
20429
|
+
if (!reValidRequestUrl.test(incomingUrl) || reDotSegment.test(incomingUrl)) return new URL(url).href;
|
|
20430
|
+
return url;
|
|
20431
|
+
}
|
|
20432
|
+
};
|
|
20305
20433
|
var toRequestError = (e) => {
|
|
20306
20434
|
if (e instanceof RequestError) return e;
|
|
20307
20435
|
return new RequestError(e.message, { cause: e });
|
|
@@ -20309,17 +20437,21 @@ var toRequestError = (e) => {
|
|
|
20309
20437
|
var GlobalRequest = global.Request;
|
|
20310
20438
|
var Request$1 = class extends GlobalRequest {
|
|
20311
20439
|
constructor(input, options) {
|
|
20312
|
-
if (typeof input === "object" && getRequestCache in input)
|
|
20313
|
-
|
|
20440
|
+
if (typeof input === "object" && getRequestCache in input) {
|
|
20441
|
+
const hasReplacementBody = options !== void 0 && "body" in options && options.body != null;
|
|
20442
|
+
if (input[bodyConsumedDirectlyKey] && !hasReplacementBody) throw new TypeError("Cannot construct a Request with a Request object that has already been used.");
|
|
20443
|
+
input = input[getRequestCache]();
|
|
20444
|
+
}
|
|
20445
|
+
if (typeof (options?.body)?.getReader !== "undefined") options.duplex ??= "half";
|
|
20314
20446
|
super(input, options);
|
|
20315
20447
|
}
|
|
20316
20448
|
};
|
|
20317
20449
|
var newHeadersFromIncoming = (incoming) => {
|
|
20318
20450
|
const headerRecord = [];
|
|
20319
20451
|
const rawHeaders = incoming.rawHeaders;
|
|
20320
|
-
for (let i = 0
|
|
20321
|
-
const
|
|
20322
|
-
if (key.charCodeAt(0) !== 58) headerRecord.push([key,
|
|
20452
|
+
for (let i = 0, len = rawHeaders.length; i < len; i += 2) {
|
|
20453
|
+
const key = rawHeaders[i];
|
|
20454
|
+
if (key.charCodeAt(0) !== 58) headerRecord.push([key, rawHeaders[i + 1]]);
|
|
20323
20455
|
}
|
|
20324
20456
|
return new Headers(headerRecord);
|
|
20325
20457
|
};
|
|
@@ -20361,11 +20493,158 @@ var getRequestCache = Symbol("getRequestCache");
|
|
|
20361
20493
|
var requestCache = Symbol("requestCache");
|
|
20362
20494
|
var incomingKey = Symbol("incomingKey");
|
|
20363
20495
|
var urlKey = Symbol("urlKey");
|
|
20496
|
+
var methodKey = Symbol("methodKey");
|
|
20364
20497
|
var headersKey = Symbol("headersKey");
|
|
20365
20498
|
var abortControllerKey = Symbol("abortControllerKey");
|
|
20499
|
+
var getAbortController = Symbol("getAbortController");
|
|
20500
|
+
var abortRequest = Symbol("abortRequest");
|
|
20501
|
+
var bodyBufferKey = Symbol("bodyBuffer");
|
|
20502
|
+
var bodyReadPromiseKey = Symbol("bodyReadPromise");
|
|
20503
|
+
var bodyConsumedDirectlyKey = Symbol("bodyConsumedDirectly");
|
|
20504
|
+
var bodyLockReaderKey = Symbol("bodyLockReader");
|
|
20505
|
+
var abortReasonKey = Symbol("abortReason");
|
|
20506
|
+
var newBodyUnusableError = () => {
|
|
20507
|
+
return /* @__PURE__ */ new TypeError("Body is unusable");
|
|
20508
|
+
};
|
|
20509
|
+
var rejectBodyUnusable = () => {
|
|
20510
|
+
return Promise.reject(newBodyUnusableError());
|
|
20511
|
+
};
|
|
20512
|
+
var textDecoder = new TextDecoder();
|
|
20513
|
+
var consumeBodyDirectOnce = (request) => {
|
|
20514
|
+
if (request[bodyConsumedDirectlyKey]) return rejectBodyUnusable();
|
|
20515
|
+
request[bodyConsumedDirectlyKey] = true;
|
|
20516
|
+
};
|
|
20517
|
+
var toArrayBuffer = (buf) => {
|
|
20518
|
+
return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
|
|
20519
|
+
};
|
|
20520
|
+
var contentType = (request) => {
|
|
20521
|
+
return (request[headersKey] ||= newHeadersFromIncoming(request[incomingKey])).get("content-type") || "";
|
|
20522
|
+
};
|
|
20523
|
+
var methodTokenRegExp = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
|
|
20524
|
+
var normalizeIncomingMethod = (method) => {
|
|
20525
|
+
if (typeof method !== "string" || method.length === 0) return "GET";
|
|
20526
|
+
switch (method) {
|
|
20527
|
+
case "DELETE":
|
|
20528
|
+
case "GET":
|
|
20529
|
+
case "HEAD":
|
|
20530
|
+
case "OPTIONS":
|
|
20531
|
+
case "POST":
|
|
20532
|
+
case "PUT": return method;
|
|
20533
|
+
}
|
|
20534
|
+
const upper = method.toUpperCase();
|
|
20535
|
+
switch (upper) {
|
|
20536
|
+
case "DELETE":
|
|
20537
|
+
case "GET":
|
|
20538
|
+
case "HEAD":
|
|
20539
|
+
case "OPTIONS":
|
|
20540
|
+
case "POST":
|
|
20541
|
+
case "PUT": return upper;
|
|
20542
|
+
default: return method;
|
|
20543
|
+
}
|
|
20544
|
+
};
|
|
20545
|
+
var validateDirectReadMethod = (method) => {
|
|
20546
|
+
if (!methodTokenRegExp.test(method)) return /* @__PURE__ */ new TypeError(`'${method}' is not a valid HTTP method.`);
|
|
20547
|
+
const normalized = method.toUpperCase();
|
|
20548
|
+
if (normalized === "CONNECT" || normalized === "TRACK" || normalized === "TRACE" && method !== "TRACE") return /* @__PURE__ */ new TypeError(`'${method}' HTTP method is unsupported.`);
|
|
20549
|
+
};
|
|
20550
|
+
var readBodyWithFastPath = (request, method, fromBuffer) => {
|
|
20551
|
+
if (request[bodyConsumedDirectlyKey]) return rejectBodyUnusable();
|
|
20552
|
+
const methodName = request.method;
|
|
20553
|
+
if (methodName === "GET" || methodName === "HEAD") return request[getRequestCache]()[method]();
|
|
20554
|
+
const methodValidationError = validateDirectReadMethod(methodName);
|
|
20555
|
+
if (methodValidationError) return Promise.reject(methodValidationError);
|
|
20556
|
+
if (request[requestCache]) {
|
|
20557
|
+
if (methodName !== "TRACE") return request[requestCache][method]();
|
|
20558
|
+
}
|
|
20559
|
+
const alreadyUsedError = consumeBodyDirectOnce(request);
|
|
20560
|
+
if (alreadyUsedError) return alreadyUsedError;
|
|
20561
|
+
const raw = readRawBodyIfAvailable(request);
|
|
20562
|
+
if (raw) {
|
|
20563
|
+
const result = Promise.resolve(fromBuffer(raw, request));
|
|
20564
|
+
request[bodyBufferKey] = void 0;
|
|
20565
|
+
return result;
|
|
20566
|
+
}
|
|
20567
|
+
return readBodyDirect(request).then((buf) => {
|
|
20568
|
+
const result = fromBuffer(buf, request);
|
|
20569
|
+
request[bodyBufferKey] = void 0;
|
|
20570
|
+
return result;
|
|
20571
|
+
});
|
|
20572
|
+
};
|
|
20573
|
+
var readRawBodyIfAvailable = (request) => {
|
|
20574
|
+
const incoming = request[incomingKey];
|
|
20575
|
+
if ("rawBody" in incoming && incoming.rawBody instanceof Buffer) return incoming.rawBody;
|
|
20576
|
+
};
|
|
20577
|
+
var readBodyDirect = (request) => {
|
|
20578
|
+
if (request[bodyBufferKey]) return Promise.resolve(request[bodyBufferKey]);
|
|
20579
|
+
if (request[bodyReadPromiseKey]) return request[bodyReadPromiseKey];
|
|
20580
|
+
const incoming = request[incomingKey];
|
|
20581
|
+
if (Readable.isDisturbed(incoming)) return rejectBodyUnusable();
|
|
20582
|
+
const promise = new Promise((resolve, reject) => {
|
|
20583
|
+
const chunks = [];
|
|
20584
|
+
let settled = false;
|
|
20585
|
+
const finish = (callback) => {
|
|
20586
|
+
if (settled) return;
|
|
20587
|
+
settled = true;
|
|
20588
|
+
cleanup();
|
|
20589
|
+
callback();
|
|
20590
|
+
};
|
|
20591
|
+
const onData = (chunk) => {
|
|
20592
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
20593
|
+
};
|
|
20594
|
+
const onEnd = () => {
|
|
20595
|
+
finish(() => {
|
|
20596
|
+
const buffer = chunks.length === 1 ? chunks[0] : Buffer.concat(chunks);
|
|
20597
|
+
request[bodyBufferKey] = buffer;
|
|
20598
|
+
resolve(buffer);
|
|
20599
|
+
});
|
|
20600
|
+
};
|
|
20601
|
+
const onError = (error) => {
|
|
20602
|
+
finish(() => {
|
|
20603
|
+
reject(error);
|
|
20604
|
+
});
|
|
20605
|
+
};
|
|
20606
|
+
const onClose = () => {
|
|
20607
|
+
if (incoming.readableEnded) {
|
|
20608
|
+
onEnd();
|
|
20609
|
+
return;
|
|
20610
|
+
}
|
|
20611
|
+
finish(() => {
|
|
20612
|
+
if (incoming.errored) {
|
|
20613
|
+
reject(incoming.errored);
|
|
20614
|
+
return;
|
|
20615
|
+
}
|
|
20616
|
+
const reason = request[abortReasonKey];
|
|
20617
|
+
if (reason !== void 0) {
|
|
20618
|
+
reject(reason instanceof Error ? reason : new Error(String(reason)));
|
|
20619
|
+
return;
|
|
20620
|
+
}
|
|
20621
|
+
reject(/* @__PURE__ */ new Error("Client connection prematurely closed."));
|
|
20622
|
+
});
|
|
20623
|
+
};
|
|
20624
|
+
const cleanup = () => {
|
|
20625
|
+
incoming.off("data", onData);
|
|
20626
|
+
incoming.off("end", onEnd);
|
|
20627
|
+
incoming.off("error", onError);
|
|
20628
|
+
incoming.off("close", onClose);
|
|
20629
|
+
request[bodyReadPromiseKey] = void 0;
|
|
20630
|
+
};
|
|
20631
|
+
incoming.on("data", onData);
|
|
20632
|
+
incoming.on("end", onEnd);
|
|
20633
|
+
incoming.on("error", onError);
|
|
20634
|
+
incoming.on("close", onClose);
|
|
20635
|
+
queueMicrotask(() => {
|
|
20636
|
+
if (settled) return;
|
|
20637
|
+
if (incoming.readableEnded) onEnd();
|
|
20638
|
+
else if (incoming.errored) onError(incoming.errored);
|
|
20639
|
+
else if (incoming.destroyed) onClose();
|
|
20640
|
+
});
|
|
20641
|
+
});
|
|
20642
|
+
request[bodyReadPromiseKey] = promise;
|
|
20643
|
+
return promise;
|
|
20644
|
+
};
|
|
20366
20645
|
var requestPrototype = {
|
|
20367
20646
|
get method() {
|
|
20368
|
-
return this[
|
|
20647
|
+
return this[methodKey];
|
|
20369
20648
|
},
|
|
20370
20649
|
get url() {
|
|
20371
20650
|
return this[urlKey];
|
|
@@ -20373,18 +20652,57 @@ var requestPrototype = {
|
|
|
20373
20652
|
get headers() {
|
|
20374
20653
|
return this[headersKey] ||= newHeadersFromIncoming(this[incomingKey]);
|
|
20375
20654
|
},
|
|
20376
|
-
[
|
|
20377
|
-
this[
|
|
20655
|
+
[abortRequest](reason) {
|
|
20656
|
+
if (this[abortReasonKey] === void 0) this[abortReasonKey] = reason;
|
|
20657
|
+
const abortController = this[abortControllerKey];
|
|
20658
|
+
if (abortController && !abortController.signal.aborted) abortController.abort(reason);
|
|
20659
|
+
},
|
|
20660
|
+
[getAbortController]() {
|
|
20661
|
+
this[abortControllerKey] ||= new AbortController();
|
|
20662
|
+
if (this[abortReasonKey] !== void 0 && !this[abortControllerKey].signal.aborted) this[abortControllerKey].abort(this[abortReasonKey]);
|
|
20378
20663
|
return this[abortControllerKey];
|
|
20379
20664
|
},
|
|
20380
20665
|
[getRequestCache]() {
|
|
20381
|
-
this[
|
|
20382
|
-
|
|
20666
|
+
const abortController = this[getAbortController]();
|
|
20667
|
+
if (this[requestCache]) return this[requestCache];
|
|
20668
|
+
const method = this.method;
|
|
20669
|
+
if (this[bodyConsumedDirectlyKey] && !(method === "GET" || method === "HEAD")) {
|
|
20670
|
+
this[bodyBufferKey] = void 0;
|
|
20671
|
+
const init = {
|
|
20672
|
+
method: method === "TRACE" ? "GET" : method,
|
|
20673
|
+
headers: this.headers,
|
|
20674
|
+
signal: abortController.signal
|
|
20675
|
+
};
|
|
20676
|
+
if (method !== "TRACE") {
|
|
20677
|
+
init.body = new ReadableStream({ start(c) {
|
|
20678
|
+
c.close();
|
|
20679
|
+
} });
|
|
20680
|
+
init.duplex = "half";
|
|
20681
|
+
}
|
|
20682
|
+
const req = new Request$1(this[urlKey], init);
|
|
20683
|
+
if (method === "TRACE") Object.defineProperty(req, "method", { get() {
|
|
20684
|
+
return "TRACE";
|
|
20685
|
+
} });
|
|
20686
|
+
return this[requestCache] = req;
|
|
20687
|
+
}
|
|
20688
|
+
return this[requestCache] = newRequestFromIncoming(this.method, this[urlKey], this.headers, this[incomingKey], abortController);
|
|
20689
|
+
},
|
|
20690
|
+
get body() {
|
|
20691
|
+
if (!this[bodyConsumedDirectlyKey]) return this[getRequestCache]().body;
|
|
20692
|
+
const request = this[getRequestCache]();
|
|
20693
|
+
if (!this[bodyLockReaderKey] && request.body) this[bodyLockReaderKey] = request.body.getReader();
|
|
20694
|
+
return request.body;
|
|
20695
|
+
},
|
|
20696
|
+
get bodyUsed() {
|
|
20697
|
+
if (this[bodyConsumedDirectlyKey]) return true;
|
|
20698
|
+
if (this[requestCache]) return this[requestCache].bodyUsed;
|
|
20699
|
+
return false;
|
|
20383
20700
|
}
|
|
20384
20701
|
};
|
|
20702
|
+
Object.defineProperty(requestPrototype, "signal", { get() {
|
|
20703
|
+
return this[getAbortController]().signal;
|
|
20704
|
+
} });
|
|
20385
20705
|
[
|
|
20386
|
-
"body",
|
|
20387
|
-
"bodyUsed",
|
|
20388
20706
|
"cache",
|
|
20389
20707
|
"credentials",
|
|
20390
20708
|
"destination",
|
|
@@ -20393,25 +20711,37 @@ var requestPrototype = {
|
|
|
20393
20711
|
"redirect",
|
|
20394
20712
|
"referrer",
|
|
20395
20713
|
"referrerPolicy",
|
|
20396
|
-
"signal",
|
|
20397
20714
|
"keepalive"
|
|
20398
20715
|
].forEach((k) => {
|
|
20399
20716
|
Object.defineProperty(requestPrototype, k, { get() {
|
|
20400
20717
|
return this[getRequestCache]()[k];
|
|
20401
20718
|
} });
|
|
20402
20719
|
});
|
|
20403
|
-
[
|
|
20404
|
-
"arrayBuffer",
|
|
20405
|
-
"blob",
|
|
20406
|
-
"clone",
|
|
20407
|
-
"formData",
|
|
20408
|
-
"json",
|
|
20409
|
-
"text"
|
|
20410
|
-
].forEach((k) => {
|
|
20720
|
+
["clone", "formData"].forEach((k) => {
|
|
20411
20721
|
Object.defineProperty(requestPrototype, k, { value: function() {
|
|
20722
|
+
if (this[bodyConsumedDirectlyKey]) {
|
|
20723
|
+
if (k === "clone") throw newBodyUnusableError();
|
|
20724
|
+
return rejectBodyUnusable();
|
|
20725
|
+
}
|
|
20412
20726
|
return this[getRequestCache]()[k]();
|
|
20413
20727
|
} });
|
|
20414
20728
|
});
|
|
20729
|
+
Object.defineProperty(requestPrototype, "text", { value: function() {
|
|
20730
|
+
return readBodyWithFastPath(this, "text", (buf) => textDecoder.decode(buf));
|
|
20731
|
+
} });
|
|
20732
|
+
Object.defineProperty(requestPrototype, "arrayBuffer", { value: function() {
|
|
20733
|
+
return readBodyWithFastPath(this, "arrayBuffer", (buf) => toArrayBuffer(buf));
|
|
20734
|
+
} });
|
|
20735
|
+
Object.defineProperty(requestPrototype, "blob", { value: function() {
|
|
20736
|
+
return readBodyWithFastPath(this, "blob", (buf, request) => {
|
|
20737
|
+
const type = contentType(request);
|
|
20738
|
+
return new Response(buf, type ? { headers: { "content-type": type } } : void 0).blob();
|
|
20739
|
+
});
|
|
20740
|
+
} });
|
|
20741
|
+
Object.defineProperty(requestPrototype, "json", { value: function() {
|
|
20742
|
+
if (this[bodyConsumedDirectlyKey]) return rejectBodyUnusable();
|
|
20743
|
+
return this.text().then(JSON.parse);
|
|
20744
|
+
} });
|
|
20415
20745
|
Object.defineProperty(requestPrototype, Symbol.for("nodejs.util.inspect.custom"), { value: function(depth, options, inspectFn) {
|
|
20416
20746
|
return `Request (lightweight) ${inspectFn({
|
|
20417
20747
|
method: this.method,
|
|
@@ -20427,6 +20757,7 @@ Object.setPrototypeOf(requestPrototype, Request$1.prototype);
|
|
|
20427
20757
|
var newRequest = (incoming, defaultHostname) => {
|
|
20428
20758
|
const req = Object.create(requestPrototype);
|
|
20429
20759
|
req[incomingKey] = incoming;
|
|
20760
|
+
req[methodKey] = normalizeIncomingMethod(incoming.method);
|
|
20430
20761
|
const incomingUrl = incoming.url || "";
|
|
20431
20762
|
if (incomingUrl[0] !== "/" && (incomingUrl.startsWith("http://") || incomingUrl.startsWith("https://"))) {
|
|
20432
20763
|
if (incoming instanceof Http2ServerRequest) throw new RequestError("Absolute URL for :path is not allowed in HTTP/2");
|
|
@@ -20444,16 +20775,20 @@ var newRequest = (incoming, defaultHostname) => {
|
|
|
20444
20775
|
scheme = incoming.scheme;
|
|
20445
20776
|
if (!(scheme === "http" || scheme === "https")) throw new RequestError("Unsupported scheme");
|
|
20446
20777
|
} else scheme = incoming.socket && incoming.socket.encrypted ? "https" : "http";
|
|
20447
|
-
|
|
20448
|
-
|
|
20449
|
-
|
|
20778
|
+
try {
|
|
20779
|
+
req[urlKey] = buildUrl(scheme, host, incomingUrl);
|
|
20780
|
+
} catch (e) {
|
|
20781
|
+
if (e instanceof RequestError) throw e;
|
|
20782
|
+
else throw new RequestError("Invalid URL", { cause: e });
|
|
20783
|
+
}
|
|
20450
20784
|
return req;
|
|
20451
20785
|
};
|
|
20786
|
+
var defaultContentType = "text/plain; charset=UTF-8";
|
|
20452
20787
|
var responseCache = Symbol("responseCache");
|
|
20453
20788
|
var getResponseCache = Symbol("getResponseCache");
|
|
20454
20789
|
var cacheKey = Symbol("cache");
|
|
20455
20790
|
var GlobalResponse = global.Response;
|
|
20456
|
-
var
|
|
20791
|
+
var Response$1 = class Response$1 {
|
|
20457
20792
|
#body;
|
|
20458
20793
|
#init;
|
|
20459
20794
|
[getResponseCache]() {
|
|
@@ -20463,7 +20798,7 @@ var Response2 = class _Response {
|
|
|
20463
20798
|
constructor(body, init) {
|
|
20464
20799
|
let headers;
|
|
20465
20800
|
this.#body = body;
|
|
20466
|
-
if (init instanceof
|
|
20801
|
+
if (init instanceof Response$1) {
|
|
20467
20802
|
const cachedGlobalResponse = init[responseCache];
|
|
20468
20803
|
if (cachedGlobalResponse) {
|
|
20469
20804
|
this.#init = cachedGlobalResponse;
|
|
@@ -20474,16 +20809,16 @@ var Response2 = class _Response {
|
|
|
20474
20809
|
headers = new Headers(init.#init.headers);
|
|
20475
20810
|
}
|
|
20476
20811
|
} else this.#init = init;
|
|
20477
|
-
if (typeof body === "string" || typeof body?.getReader !== "undefined" || body instanceof Blob || body instanceof Uint8Array) this[cacheKey] = [
|
|
20812
|
+
if (body == null || typeof body === "string" || typeof body?.getReader !== "undefined" || body instanceof Blob || body instanceof Uint8Array) this[cacheKey] = [
|
|
20478
20813
|
init?.status || 200,
|
|
20479
|
-
body,
|
|
20814
|
+
body ?? null,
|
|
20480
20815
|
headers || init?.headers
|
|
20481
20816
|
];
|
|
20482
20817
|
}
|
|
20483
20818
|
get headers() {
|
|
20484
20819
|
const cache = this[cacheKey];
|
|
20485
20820
|
if (cache) {
|
|
20486
|
-
if (!(cache[2] instanceof Headers)) cache[2] = new Headers(cache[2] || { "content-type":
|
|
20821
|
+
if (!(cache[2] instanceof Headers)) cache[2] = new Headers(cache[2] || (cache[1] === null ? void 0 : { "content-type": defaultContentType }));
|
|
20487
20822
|
return cache[2];
|
|
20488
20823
|
}
|
|
20489
20824
|
return this[getResponseCache]().headers;
|
|
@@ -20505,7 +20840,7 @@ var Response2 = class _Response {
|
|
|
20505
20840
|
"type",
|
|
20506
20841
|
"url"
|
|
20507
20842
|
].forEach((k) => {
|
|
20508
|
-
Object.defineProperty(
|
|
20843
|
+
Object.defineProperty(Response$1.prototype, k, { get() {
|
|
20509
20844
|
return this[getResponseCache]()[k];
|
|
20510
20845
|
} });
|
|
20511
20846
|
});
|
|
@@ -20517,11 +20852,11 @@ var Response2 = class _Response {
|
|
|
20517
20852
|
"json",
|
|
20518
20853
|
"text"
|
|
20519
20854
|
].forEach((k) => {
|
|
20520
|
-
Object.defineProperty(
|
|
20855
|
+
Object.defineProperty(Response$1.prototype, k, { value: function() {
|
|
20521
20856
|
return this[getResponseCache]()[k]();
|
|
20522
20857
|
} });
|
|
20523
20858
|
});
|
|
20524
|
-
Object.defineProperty(
|
|
20859
|
+
Object.defineProperty(Response$1.prototype, Symbol.for("nodejs.util.inspect.custom"), { value: function(depth, options, inspectFn) {
|
|
20525
20860
|
return `Response (lightweight) ${inspectFn({
|
|
20526
20861
|
status: this.status,
|
|
20527
20862
|
headers: this.headers,
|
|
@@ -20532,8 +20867,51 @@ Object.defineProperty(Response2.prototype, Symbol.for("nodejs.util.inspect.custo
|
|
|
20532
20867
|
depth: depth == null ? null : depth - 1
|
|
20533
20868
|
})}`;
|
|
20534
20869
|
} });
|
|
20535
|
-
Object.setPrototypeOf(
|
|
20536
|
-
Object.setPrototypeOf(
|
|
20870
|
+
Object.setPrototypeOf(Response$1, GlobalResponse);
|
|
20871
|
+
Object.setPrototypeOf(Response$1.prototype, GlobalResponse.prototype);
|
|
20872
|
+
var validRedirectUrl = /^https?:\/\/[!#-;=?-[\]_a-z~A-Z]+$/;
|
|
20873
|
+
var parseRedirectUrl = (url) => {
|
|
20874
|
+
if (url instanceof URL) return url.href;
|
|
20875
|
+
if (validRedirectUrl.test(url)) return url;
|
|
20876
|
+
return new URL(url).href;
|
|
20877
|
+
};
|
|
20878
|
+
var validRedirectStatuses = new Set([
|
|
20879
|
+
301,
|
|
20880
|
+
302,
|
|
20881
|
+
303,
|
|
20882
|
+
307,
|
|
20883
|
+
308
|
|
20884
|
+
]);
|
|
20885
|
+
Object.defineProperty(Response$1, "redirect", {
|
|
20886
|
+
value: function redirect(url, status = 302) {
|
|
20887
|
+
if (!validRedirectStatuses.has(status)) throw new RangeError("Invalid status code");
|
|
20888
|
+
return new Response$1(null, {
|
|
20889
|
+
status,
|
|
20890
|
+
headers: { location: parseRedirectUrl(url) }
|
|
20891
|
+
});
|
|
20892
|
+
},
|
|
20893
|
+
writable: true,
|
|
20894
|
+
configurable: true
|
|
20895
|
+
});
|
|
20896
|
+
Object.defineProperty(Response$1, "json", {
|
|
20897
|
+
value: function json(data, init) {
|
|
20898
|
+
const body = JSON.stringify(data);
|
|
20899
|
+
if (body === void 0) throw new TypeError("The data is not JSON serializable");
|
|
20900
|
+
const initHeaders = init?.headers;
|
|
20901
|
+
let headers;
|
|
20902
|
+
if (initHeaders) {
|
|
20903
|
+
headers = new Headers(initHeaders);
|
|
20904
|
+
if (!headers.has("content-type")) headers.set("content-type", "application/json");
|
|
20905
|
+
} else headers = { "content-type": "application/json" };
|
|
20906
|
+
return new Response$1(body, {
|
|
20907
|
+
status: init?.status ?? 200,
|
|
20908
|
+
statusText: init?.statusText,
|
|
20909
|
+
headers
|
|
20910
|
+
});
|
|
20911
|
+
},
|
|
20912
|
+
writable: true,
|
|
20913
|
+
configurable: true
|
|
20914
|
+
});
|
|
20537
20915
|
async function readWithoutBlocking(readPromise) {
|
|
20538
20916
|
return Promise.race([readPromise, Promise.resolve().then(() => Promise.resolve(void 0))]);
|
|
20539
20917
|
}
|
|
@@ -20569,18 +20947,18 @@ function writeFromReadableStream(stream, writable) {
|
|
|
20569
20947
|
else if (writable.destroyed) return;
|
|
20570
20948
|
return writeFromReadableStreamDefaultReader(stream.getReader(), writable);
|
|
20571
20949
|
}
|
|
20572
|
-
var buildOutgoingHttpHeaders = (headers) => {
|
|
20950
|
+
var buildOutgoingHttpHeaders = (headers, defaultContentType) => {
|
|
20573
20951
|
const res = {};
|
|
20574
20952
|
if (!(headers instanceof Headers)) headers = new Headers(headers ?? void 0);
|
|
20575
|
-
|
|
20576
|
-
|
|
20577
|
-
|
|
20578
|
-
|
|
20579
|
-
|
|
20953
|
+
if (headers.has("set-cookie")) {
|
|
20954
|
+
const cookies = [];
|
|
20955
|
+
for (const [k, v] of headers) if (k === "set-cookie") cookies.push(v);
|
|
20956
|
+
else res[k] = v;
|
|
20957
|
+
if (cookies.length > 0) res["set-cookie"] = cookies;
|
|
20958
|
+
} else for (const [k, v] of headers) res[k] = v;
|
|
20959
|
+
if (defaultContentType) res["content-type"] ??= defaultContentType;
|
|
20580
20960
|
return res;
|
|
20581
20961
|
};
|
|
20582
|
-
var X_ALREADY_SENT = "x-hono-already-sent";
|
|
20583
|
-
if (typeof global.crypto === "undefined") global.crypto = crypto$2;
|
|
20584
20962
|
var outgoingEnded = Symbol("outgoingEnded");
|
|
20585
20963
|
var incomingDraining = Symbol("incomingDraining");
|
|
20586
20964
|
var DRAIN_TIMEOUT_MS = 500;
|
|
@@ -20618,6 +20996,20 @@ var drainIncoming = (incoming) => {
|
|
|
20618
20996
|
incoming.on("error", cleanup);
|
|
20619
20997
|
incoming.resume();
|
|
20620
20998
|
};
|
|
20999
|
+
var makeCloseHandler = (req, incoming, outgoing, needsBodyCleanup) => () => {
|
|
21000
|
+
if (incoming.errored) req[abortRequest](incoming.errored.toString());
|
|
21001
|
+
else if (!outgoing.writableFinished) req[abortRequest]("Client connection prematurely closed.");
|
|
21002
|
+
if (needsBodyCleanup && !incoming.readableEnded) setTimeout(() => {
|
|
21003
|
+
if (!incoming.readableEnded) setTimeout(() => {
|
|
21004
|
+
drainIncoming(incoming);
|
|
21005
|
+
});
|
|
21006
|
+
});
|
|
21007
|
+
};
|
|
21008
|
+
var isImmediateCacheableResponse = (res) => {
|
|
21009
|
+
if (!(cacheKey in res)) return false;
|
|
21010
|
+
const body = res[cacheKey][1];
|
|
21011
|
+
return body === null || typeof body === "string" || body instanceof Uint8Array;
|
|
21012
|
+
};
|
|
20621
21013
|
var handleRequestError = () => new Response(null, { status: 400 });
|
|
20622
21014
|
var handleFetchError = (e) => new Response(null, { status: e instanceof Error && (e.name === "TimeoutError" || e.constructor.name === "TimeoutError") ? 504 : 500 });
|
|
20623
21015
|
var handleResponseError = (e, outgoing) => {
|
|
@@ -20635,15 +21027,44 @@ var flushHeaders = (outgoing) => {
|
|
|
20635
21027
|
};
|
|
20636
21028
|
var responseViaCache = async (res, outgoing) => {
|
|
20637
21029
|
let [status, body, header] = res[cacheKey];
|
|
21030
|
+
if (!header) {
|
|
21031
|
+
if (body === null) {
|
|
21032
|
+
outgoing.writeHead(status);
|
|
21033
|
+
outgoing.end();
|
|
21034
|
+
} else if (typeof body === "string") {
|
|
21035
|
+
outgoing.writeHead(status, {
|
|
21036
|
+
"Content-Type": defaultContentType,
|
|
21037
|
+
"Content-Length": Buffer.byteLength(body)
|
|
21038
|
+
});
|
|
21039
|
+
outgoing.end(body);
|
|
21040
|
+
} else if (body instanceof Uint8Array) {
|
|
21041
|
+
outgoing.writeHead(status, {
|
|
21042
|
+
"Content-Type": defaultContentType,
|
|
21043
|
+
"Content-Length": body.byteLength
|
|
21044
|
+
});
|
|
21045
|
+
outgoing.end(body);
|
|
21046
|
+
} else if (body instanceof Blob) {
|
|
21047
|
+
outgoing.writeHead(status, {
|
|
21048
|
+
"Content-Type": defaultContentType,
|
|
21049
|
+
"Content-Length": body.size
|
|
21050
|
+
});
|
|
21051
|
+
outgoing.end(new Uint8Array(await body.arrayBuffer()));
|
|
21052
|
+
} else {
|
|
21053
|
+
outgoing.writeHead(status, { "Content-Type": defaultContentType });
|
|
21054
|
+
flushHeaders(outgoing);
|
|
21055
|
+
await writeFromReadableStream(body, outgoing)?.catch((e) => handleResponseError(e, outgoing));
|
|
21056
|
+
}
|
|
21057
|
+
outgoing[outgoingEnded]?.();
|
|
21058
|
+
return;
|
|
21059
|
+
}
|
|
20638
21060
|
let hasContentLength = false;
|
|
20639
|
-
if (
|
|
20640
|
-
else if (header instanceof Headers) {
|
|
21061
|
+
if (header instanceof Headers) {
|
|
20641
21062
|
hasContentLength = header.has("content-length");
|
|
20642
|
-
header = buildOutgoingHttpHeaders(header);
|
|
21063
|
+
header = buildOutgoingHttpHeaders(header, body === null ? void 0 : defaultContentType);
|
|
20643
21064
|
} else if (Array.isArray(header)) {
|
|
20644
21065
|
const headerObj = new Headers(header);
|
|
20645
21066
|
hasContentLength = headerObj.has("content-length");
|
|
20646
|
-
header = buildOutgoingHttpHeaders(headerObj);
|
|
21067
|
+
header = buildOutgoingHttpHeaders(headerObj, body === null ? void 0 : defaultContentType);
|
|
20647
21068
|
} else for (const key in header) if (key.length === 14 && key.toLowerCase() === "content-length") {
|
|
20648
21069
|
hasContentLength = true;
|
|
20649
21070
|
break;
|
|
@@ -20654,7 +21075,8 @@ var responseViaCache = async (res, outgoing) => {
|
|
|
20654
21075
|
else if (body instanceof Blob) header["Content-Length"] = body.size;
|
|
20655
21076
|
}
|
|
20656
21077
|
outgoing.writeHead(status, header);
|
|
20657
|
-
if (
|
|
21078
|
+
if (body == null) outgoing.end();
|
|
21079
|
+
else if (typeof body === "string" || body instanceof Uint8Array) outgoing.end(body);
|
|
20658
21080
|
else if (body instanceof Blob) outgoing.end(new Uint8Array(await body.arrayBuffer()));
|
|
20659
21081
|
else {
|
|
20660
21082
|
flushHeaders(outgoing);
|
|
@@ -20673,7 +21095,7 @@ var responseViaResponseObject = async (res, outgoing, options = {}) => {
|
|
|
20673
21095
|
}
|
|
20674
21096
|
else res = await res.catch(handleFetchError);
|
|
20675
21097
|
if (cacheKey in res) return responseViaCache(res, outgoing);
|
|
20676
|
-
const resHeaderRecord = buildOutgoingHttpHeaders(res.headers);
|
|
21098
|
+
const resHeaderRecord = buildOutgoingHttpHeaders(res.headers, res.body === null ? void 0 : defaultContentType);
|
|
20677
21099
|
if (res.body) {
|
|
20678
21100
|
const reader = res.body.getReader();
|
|
20679
21101
|
const values = [];
|
|
@@ -20713,7 +21135,7 @@ var responseViaResponseObject = async (res, outgoing, options = {}) => {
|
|
|
20713
21135
|
if (values.length === 0) flushHeaders(outgoing);
|
|
20714
21136
|
await writeFromReadableStreamDefaultReader(reader, outgoing, currentReadPromise);
|
|
20715
21137
|
}
|
|
20716
|
-
} else if (resHeaderRecord[
|
|
21138
|
+
} else if (resHeaderRecord["x-hono-already-sent"]) {} else {
|
|
20717
21139
|
outgoing.writeHead(res.status, resHeaderRecord);
|
|
20718
21140
|
outgoing.end();
|
|
20719
21141
|
}
|
|
@@ -20723,47 +21145,45 @@ var getRequestListener = (fetchCallback, options = {}) => {
|
|
|
20723
21145
|
const autoCleanupIncoming = options.autoCleanupIncoming ?? true;
|
|
20724
21146
|
if (options.overrideGlobalObjects !== false && global.Request !== Request$1) {
|
|
20725
21147
|
Object.defineProperty(global, "Request", { value: Request$1 });
|
|
20726
|
-
Object.defineProperty(global, "Response", { value:
|
|
21148
|
+
Object.defineProperty(global, "Response", { value: Response$1 });
|
|
20727
21149
|
}
|
|
20728
21150
|
return async (incoming, outgoing) => {
|
|
20729
21151
|
let res, req;
|
|
21152
|
+
let needsBodyCleanup = false;
|
|
21153
|
+
let closeHandlerAttached = false;
|
|
21154
|
+
const ensureCloseHandler = () => {
|
|
21155
|
+
if (!req || closeHandlerAttached) return;
|
|
21156
|
+
closeHandlerAttached = true;
|
|
21157
|
+
outgoing.on("close", makeCloseHandler(req, incoming, outgoing, needsBodyCleanup));
|
|
21158
|
+
};
|
|
20730
21159
|
try {
|
|
20731
21160
|
req = newRequest(incoming, options.hostname);
|
|
20732
|
-
|
|
20733
|
-
if (
|
|
21161
|
+
needsBodyCleanup = autoCleanupIncoming && !(incoming.method === "GET" || incoming.method === "HEAD");
|
|
21162
|
+
if (needsBodyCleanup) {
|
|
20734
21163
|
incoming[wrapBodyStream] = true;
|
|
20735
|
-
incoming.on("end", () => {
|
|
20736
|
-
incomingEnded = true;
|
|
20737
|
-
});
|
|
20738
21164
|
if (incoming instanceof Http2ServerRequest) outgoing[outgoingEnded] = () => {
|
|
20739
|
-
if (!
|
|
20740
|
-
if (!
|
|
20741
|
-
|
|
21165
|
+
if (!incoming.readableEnded) setTimeout(() => {
|
|
21166
|
+
if (!incoming.readableEnded) setTimeout(() => {
|
|
21167
|
+
incoming.destroy();
|
|
21168
|
+
outgoing.destroy();
|
|
20742
21169
|
});
|
|
20743
21170
|
});
|
|
20744
21171
|
};
|
|
20745
|
-
outgoing.on("finish", () => {
|
|
20746
|
-
if (!incomingEnded) drainIncoming(incoming);
|
|
20747
|
-
});
|
|
20748
21172
|
}
|
|
20749
|
-
outgoing.on("close", () => {
|
|
20750
|
-
if (req[abortControllerKey]) {
|
|
20751
|
-
if (incoming.errored) req[abortControllerKey].abort(incoming.errored.toString());
|
|
20752
|
-
else if (!outgoing.writableFinished) req[abortControllerKey].abort("Client connection prematurely closed.");
|
|
20753
|
-
}
|
|
20754
|
-
if (!incomingEnded) setTimeout(() => {
|
|
20755
|
-
if (!incomingEnded) setTimeout(() => {
|
|
20756
|
-
drainIncoming(incoming);
|
|
20757
|
-
});
|
|
20758
|
-
});
|
|
20759
|
-
});
|
|
20760
21173
|
res = fetchCallback(req, {
|
|
20761
21174
|
incoming,
|
|
20762
21175
|
outgoing
|
|
20763
21176
|
});
|
|
20764
|
-
if (
|
|
21177
|
+
if (!isPromise(res) && isImmediateCacheableResponse(res)) {
|
|
21178
|
+
if (needsBodyCleanup && !incoming.readableEnded) outgoing.once("finish", () => {
|
|
21179
|
+
if (!incoming.readableEnded) drainIncoming(incoming);
|
|
21180
|
+
});
|
|
21181
|
+
return responseViaCache(res, outgoing);
|
|
21182
|
+
}
|
|
21183
|
+
ensureCloseHandler();
|
|
20765
21184
|
} catch (e) {
|
|
20766
21185
|
if (!res) if (options.errorHandler) {
|
|
21186
|
+
ensureCloseHandler();
|
|
20767
21187
|
res = await options.errorHandler(req ? e : toRequestError(e));
|
|
20768
21188
|
if (!res) return;
|
|
20769
21189
|
} else if (!req) res = handleRequestError();
|
|
@@ -20777,6 +21197,160 @@ var getRequestListener = (fetchCallback, options = {}) => {
|
|
|
20777
21197
|
}
|
|
20778
21198
|
};
|
|
20779
21199
|
};
|
|
21200
|
+
/**
|
|
21201
|
+
* @link https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent
|
|
21202
|
+
*/
|
|
21203
|
+
var CloseEvent$1 = globalThis.CloseEvent ?? class extends Event {
|
|
21204
|
+
#eventInitDict;
|
|
21205
|
+
constructor(type, eventInitDict = {}) {
|
|
21206
|
+
super(type, eventInitDict);
|
|
21207
|
+
this.#eventInitDict = eventInitDict;
|
|
21208
|
+
}
|
|
21209
|
+
get wasClean() {
|
|
21210
|
+
return this.#eventInitDict.wasClean ?? false;
|
|
21211
|
+
}
|
|
21212
|
+
get code() {
|
|
21213
|
+
return this.#eventInitDict.code ?? 0;
|
|
21214
|
+
}
|
|
21215
|
+
get reason() {
|
|
21216
|
+
return this.#eventInitDict.reason ?? "";
|
|
21217
|
+
}
|
|
21218
|
+
};
|
|
21219
|
+
var generateConnectionSymbol$1 = () => Symbol("connection");
|
|
21220
|
+
var CONNECTION_SYMBOL_KEY$1 = Symbol("CONNECTION_SYMBOL_KEY");
|
|
21221
|
+
var WAIT_FOR_WEBSOCKET_SYMBOL = Symbol("WAIT_FOR_WEBSOCKET_SYMBOL");
|
|
21222
|
+
var rejectUpgradeRequest = (socket, status) => {
|
|
21223
|
+
socket.end(`HTTP/1.1 ${status.toString()} ${STATUS_CODES[status] ?? ""}\r\nConnection: close\r
|
|
21224
|
+
Content-Length: 0\r
|
|
21225
|
+
\r
|
|
21226
|
+
`);
|
|
21227
|
+
};
|
|
21228
|
+
var createUpgradeRequest = (request) => {
|
|
21229
|
+
const protocol = request.socket.encrypted ? "https" : "http";
|
|
21230
|
+
const url = new URL(request.url ?? "/", `${protocol}://${request.headers.host ?? "localhost"}`);
|
|
21231
|
+
const headers = new Headers();
|
|
21232
|
+
for (const key in request.headers) {
|
|
21233
|
+
const value = request.headers[key];
|
|
21234
|
+
if (!value) continue;
|
|
21235
|
+
headers.append(key, Array.isArray(value) ? value[0] : value);
|
|
21236
|
+
}
|
|
21237
|
+
return new Request(url, { headers });
|
|
21238
|
+
};
|
|
21239
|
+
var setupWebSocket = (options) => {
|
|
21240
|
+
const { server, fetchCallback, wss } = options;
|
|
21241
|
+
const waiterMap = /* @__PURE__ */ new Map();
|
|
21242
|
+
wss.on("connection", (ws, request) => {
|
|
21243
|
+
const waiter = waiterMap.get(request);
|
|
21244
|
+
if (waiter) {
|
|
21245
|
+
waiter.resolve(ws);
|
|
21246
|
+
waiterMap.delete(request);
|
|
21247
|
+
}
|
|
21248
|
+
});
|
|
21249
|
+
const waitForWebSocket = (request, connectionSymbol) => {
|
|
21250
|
+
return new Promise((resolve) => {
|
|
21251
|
+
waiterMap.set(request, {
|
|
21252
|
+
resolve,
|
|
21253
|
+
connectionSymbol
|
|
21254
|
+
});
|
|
21255
|
+
});
|
|
21256
|
+
};
|
|
21257
|
+
server.on("upgrade", async (request, socket, head) => {
|
|
21258
|
+
if (request.headers.upgrade?.toLowerCase() !== "websocket") return;
|
|
21259
|
+
const env = {
|
|
21260
|
+
incoming: request,
|
|
21261
|
+
outgoing: void 0,
|
|
21262
|
+
wss,
|
|
21263
|
+
[WAIT_FOR_WEBSOCKET_SYMBOL]: waitForWebSocket
|
|
21264
|
+
};
|
|
21265
|
+
let status = 400;
|
|
21266
|
+
try {
|
|
21267
|
+
const response = await fetchCallback(createUpgradeRequest(request), env);
|
|
21268
|
+
if (response instanceof Response) status = response.status;
|
|
21269
|
+
} catch {
|
|
21270
|
+
if (server.listenerCount("upgrade") === 1) rejectUpgradeRequest(socket, 500);
|
|
21271
|
+
return;
|
|
21272
|
+
}
|
|
21273
|
+
const waiter = waiterMap.get(request);
|
|
21274
|
+
if (!waiter || waiter.connectionSymbol !== env[CONNECTION_SYMBOL_KEY$1]) {
|
|
21275
|
+
waiterMap.delete(request);
|
|
21276
|
+
if (server.listenerCount("upgrade") === 1) rejectUpgradeRequest(socket, status);
|
|
21277
|
+
return;
|
|
21278
|
+
}
|
|
21279
|
+
wss.handleUpgrade(request, socket, head, (ws) => {
|
|
21280
|
+
wss.emit("connection", ws, request);
|
|
21281
|
+
});
|
|
21282
|
+
});
|
|
21283
|
+
server.on("close", () => {
|
|
21284
|
+
wss.close();
|
|
21285
|
+
});
|
|
21286
|
+
};
|
|
21287
|
+
defineWebSocketHelper(async (c, events, options) => {
|
|
21288
|
+
if (c.req.header("upgrade")?.toLowerCase() !== "websocket") return;
|
|
21289
|
+
const env = c.env;
|
|
21290
|
+
const waitForWebSocket = env[WAIT_FOR_WEBSOCKET_SYMBOL];
|
|
21291
|
+
if (!waitForWebSocket || !env.incoming) return new Response(null, { status: 500 });
|
|
21292
|
+
const connectionSymbol = generateConnectionSymbol$1();
|
|
21293
|
+
env[CONNECTION_SYMBOL_KEY$1] = connectionSymbol;
|
|
21294
|
+
(async () => {
|
|
21295
|
+
const ws = await waitForWebSocket(env.incoming, connectionSymbol);
|
|
21296
|
+
const messagesReceivedInStarting = [];
|
|
21297
|
+
const bufferMessage = (data, isBinary) => {
|
|
21298
|
+
messagesReceivedInStarting.push([data, isBinary]);
|
|
21299
|
+
};
|
|
21300
|
+
ws.on("message", bufferMessage);
|
|
21301
|
+
const ctx = {
|
|
21302
|
+
binaryType: "arraybuffer",
|
|
21303
|
+
close(code, reason) {
|
|
21304
|
+
ws.close(code, reason);
|
|
21305
|
+
},
|
|
21306
|
+
protocol: ws.protocol,
|
|
21307
|
+
raw: ws,
|
|
21308
|
+
get readyState() {
|
|
21309
|
+
return ws.readyState;
|
|
21310
|
+
},
|
|
21311
|
+
send(source, opts) {
|
|
21312
|
+
ws.send(source, { compress: opts?.compress });
|
|
21313
|
+
},
|
|
21314
|
+
url: new URL(c.req.url)
|
|
21315
|
+
};
|
|
21316
|
+
try {
|
|
21317
|
+
events?.onOpen?.(new Event("open"), ctx);
|
|
21318
|
+
} catch (e) {
|
|
21319
|
+
(options?.onError ?? console.error)(e);
|
|
21320
|
+
}
|
|
21321
|
+
const handleMessage = (data, isBinary) => {
|
|
21322
|
+
const datas = Array.isArray(data) ? data : [data];
|
|
21323
|
+
for (const data of datas) try {
|
|
21324
|
+
events?.onMessage?.(new MessageEvent("message", { data: isBinary ? data instanceof ArrayBuffer ? data : data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength) : data.toString("utf-8") }), ctx);
|
|
21325
|
+
} catch (e) {
|
|
21326
|
+
(options?.onError ?? console.error)(e);
|
|
21327
|
+
}
|
|
21328
|
+
};
|
|
21329
|
+
ws.off("message", bufferMessage);
|
|
21330
|
+
for (const message of messagesReceivedInStarting) handleMessage(...message);
|
|
21331
|
+
ws.on("message", (data, isBinary) => {
|
|
21332
|
+
handleMessage(data, isBinary);
|
|
21333
|
+
});
|
|
21334
|
+
ws.on("close", (code, reason) => {
|
|
21335
|
+
try {
|
|
21336
|
+
events?.onClose?.(new CloseEvent$1("close", {
|
|
21337
|
+
code,
|
|
21338
|
+
reason: reason.toString()
|
|
21339
|
+
}), ctx);
|
|
21340
|
+
} catch (e) {
|
|
21341
|
+
(options?.onError ?? console.error)(e);
|
|
21342
|
+
}
|
|
21343
|
+
});
|
|
21344
|
+
ws.on("error", (error) => {
|
|
21345
|
+
try {
|
|
21346
|
+
events?.onError?.(new ErrorEvent("error", { error }), ctx);
|
|
21347
|
+
} catch (e) {
|
|
21348
|
+
(options?.onError ?? console.error)(e);
|
|
21349
|
+
}
|
|
21350
|
+
});
|
|
21351
|
+
})();
|
|
21352
|
+
return new Response();
|
|
21353
|
+
});
|
|
20780
21354
|
var createAdaptorServer = (options) => {
|
|
20781
21355
|
const fetchCallback = options.fetch;
|
|
20782
21356
|
const requestListener = getRequestListener(fetchCallback, {
|
|
@@ -20784,7 +21358,16 @@ var createAdaptorServer = (options) => {
|
|
|
20784
21358
|
overrideGlobalObjects: options.overrideGlobalObjects,
|
|
20785
21359
|
autoCleanupIncoming: options.autoCleanupIncoming
|
|
20786
21360
|
});
|
|
20787
|
-
|
|
21361
|
+
const server = (options.createServer || createServer)(options.serverOptions || {}, requestListener);
|
|
21362
|
+
if (options.websocket && options.websocket.server) {
|
|
21363
|
+
if (options.websocket.server.options.noServer !== true) throw new Error("WebSocket server must be created with { noServer: true } option");
|
|
21364
|
+
setupWebSocket({
|
|
21365
|
+
server,
|
|
21366
|
+
fetchCallback,
|
|
21367
|
+
wss: options.websocket.server
|
|
21368
|
+
});
|
|
21369
|
+
}
|
|
21370
|
+
return server;
|
|
20788
21371
|
};
|
|
20789
21372
|
var serve = (options, listeningListener) => {
|
|
20790
21373
|
const server = createAdaptorServer(options);
|
|
@@ -21083,6 +21666,8 @@ var ActionName = /* @__PURE__ */ function(ActionName) {
|
|
|
21083
21666
|
ActionName["SetDoubtFriendsAddRequest"] = "set_doubt_friends_add_request";
|
|
21084
21667
|
ActionName["DeleteGroupNotice"] = "_delete_group_notice";
|
|
21085
21668
|
ActionName["SendPoke"] = "send_poke";
|
|
21669
|
+
ActionName["SetInputStatus"] = "set_input_status";
|
|
21670
|
+
ActionName["GetGroupAlbumMediaList"] = "get_group_album_media_list";
|
|
21086
21671
|
ActionName["SendLike"] = "send_like";
|
|
21087
21672
|
ActionName["GetLoginInfo"] = "get_login_info";
|
|
21088
21673
|
ActionName["GetFriendList"] = "get_friend_list";
|
|
@@ -21159,15 +21744,24 @@ var GetMsg = class extends BaseAction {
|
|
|
21159
21744
|
async _handle(payload, config) {
|
|
21160
21745
|
const msgInfo = await this.ctx.store.getMsgInfoByShortId(+payload.message_id);
|
|
21161
21746
|
if (!msgInfo) throw new Error("消息不存在");
|
|
21162
|
-
let
|
|
21163
|
-
|
|
21164
|
-
|
|
21165
|
-
|
|
21166
|
-
|
|
21167
|
-
|
|
21747
|
+
let status = "normal";
|
|
21748
|
+
let msg;
|
|
21749
|
+
const res = await this.ctx.ntMsgApi.getMsgsByMsgId(msgInfo.peer, [msgInfo.msgId]);
|
|
21750
|
+
if (res.msgList.length === 0 || res.msgList[0].elements[0].grayTipElement?.revokeElement) {
|
|
21751
|
+
const msgCache = this.ctx.store.getMsgCache(msgInfo.msgId);
|
|
21752
|
+
if (msgCache) {
|
|
21753
|
+
msg = msgCache;
|
|
21754
|
+
status = "deleted";
|
|
21755
|
+
} else if (res.msgList.length === 0) throw new Error("无法获取该消息");
|
|
21756
|
+
else {
|
|
21757
|
+
msg = res.msgList[0];
|
|
21758
|
+
status = "deleted";
|
|
21759
|
+
}
|
|
21760
|
+
} else msg = res.msgList[0];
|
|
21168
21761
|
const retMsg = await OB11Entities.message(this.ctx, msg, void 0, void 0, config);
|
|
21169
21762
|
if (!retMsg) throw new Error("消息为空");
|
|
21170
21763
|
retMsg.real_id = retMsg.message_seq;
|
|
21764
|
+
retMsg.status = status;
|
|
21171
21765
|
return retMsg;
|
|
21172
21766
|
}
|
|
21173
21767
|
};
|
|
@@ -23260,7 +23854,8 @@ var MessageEncoder$1 = class MessageEncoder$1 {
|
|
|
23260
23854
|
"forward",
|
|
23261
23855
|
"node",
|
|
23262
23856
|
"video",
|
|
23263
|
-
"file"
|
|
23857
|
+
"file",
|
|
23858
|
+
"at"
|
|
23264
23859
|
];
|
|
23265
23860
|
results;
|
|
23266
23861
|
children;
|
|
@@ -23291,7 +23886,7 @@ var MessageEncoder$1 = class MessageEncoder$1 {
|
|
|
23291
23886
|
}
|
|
23292
23887
|
async flush() {
|
|
23293
23888
|
if (this.children.length === 0 && !this.content) return;
|
|
23294
|
-
const nick = this.name
|
|
23889
|
+
const nick = this.name ?? selfInfo.nick;
|
|
23295
23890
|
if (this.news.length < 4) this.news.push({ text: `${nick}: ${this.preview}` });
|
|
23296
23891
|
this.results.push({
|
|
23297
23892
|
routingHead: {
|
|
@@ -23537,7 +24132,7 @@ var MessageEncoder$1 = class MessageEncoder$1 {
|
|
|
23537
24132
|
} });
|
|
23538
24133
|
} else {
|
|
23539
24134
|
const data = await this.ctx.ntFileApi.uploadC2CFile(this.peer.peerUid, path, fileName);
|
|
23540
|
-
|
|
24135
|
+
const extra = Msg.FileExtra.encode({ file: {
|
|
23541
24136
|
fileType: 0,
|
|
23542
24137
|
fileUuid: data.fileId,
|
|
23543
24138
|
fileMd5: data.file10MMd5,
|
|
@@ -23548,8 +24143,25 @@ var MessageEncoder$1 = class MessageEncoder$1 {
|
|
|
23548
24143
|
expireTime: Math.floor(Date.now() / 1e3 + 10080 * 60),
|
|
23549
24144
|
fileIdCrcMedia: data.crcMedia
|
|
23550
24145
|
} });
|
|
24146
|
+
this.content = extra;
|
|
23551
24147
|
}
|
|
23552
24148
|
this.preview += `[文件] ${fileName}`;
|
|
24149
|
+
} else if (type === OB11MessageDataType.At) {
|
|
24150
|
+
if (!this.isGroup) return;
|
|
24151
|
+
let str;
|
|
24152
|
+
if (isNonNullable(data.name)) str = `@${data.name}`;
|
|
24153
|
+
else if (data.qq === "all") str = "@全体成员";
|
|
24154
|
+
else {
|
|
24155
|
+
const uid = await this.ctx.ntUserApi.getUidByUin(data.qq, this.isGroup ? this.peer.peerUid : void 0);
|
|
24156
|
+
try {
|
|
24157
|
+
const info = await this.ctx.ntGroupApi.getGroupMember(this.peer.peerUid, uid, false, 50);
|
|
24158
|
+
str = `@${info.cardName || info.nick}`;
|
|
24159
|
+
} catch (e) {
|
|
24160
|
+
str = `@${(await this.ctx.ntUserApi.getUserSimpleInfo(uid)).coreInfo.nick}`;
|
|
24161
|
+
}
|
|
24162
|
+
}
|
|
24163
|
+
this.children.push({ text: { str } });
|
|
24164
|
+
this.preview += str;
|
|
23553
24165
|
}
|
|
23554
24166
|
}
|
|
23555
24167
|
async render(segments) {
|
|
@@ -25904,6 +26516,43 @@ var SendPoke = class extends BaseAction {
|
|
|
25904
26516
|
}
|
|
25905
26517
|
};
|
|
25906
26518
|
//#endregion
|
|
26519
|
+
//#region src/onebot11/action/llbot/user/SetInputStatus.ts
|
|
26520
|
+
var SetInputStatus = class extends BaseAction {
|
|
26521
|
+
actionName = ActionName.SetInputStatus;
|
|
26522
|
+
payloadSchema = lib_default$1.object({
|
|
26523
|
+
user_id: lib_default$1.union([Number, String]).required(),
|
|
26524
|
+
event_type: lib_default$1.union([Number, String]).required()
|
|
26525
|
+
});
|
|
26526
|
+
async _handle(payload) {
|
|
26527
|
+
const uin = payload.user_id.toString();
|
|
26528
|
+
const uid = await this.ctx.ntUserApi.getUidByUin(uin);
|
|
26529
|
+
if (!uid) throw new Error("无法获取用户信息");
|
|
26530
|
+
const result = await this.ctx.ntMsgApi.sendShowInputStatusReq(ChatType.C2C, +payload.event_type, uid);
|
|
26531
|
+
if (result.result !== 0) throw new Error(result.errMsg);
|
|
26532
|
+
return null;
|
|
26533
|
+
}
|
|
26534
|
+
};
|
|
26535
|
+
//#endregion
|
|
26536
|
+
//#region src/onebot11/action/llbot/group/GroupAlbum/GetGroupAlbumMediaList.ts
|
|
26537
|
+
var GetGroupAlbumMediaList = class extends BaseAction {
|
|
26538
|
+
actionName = ActionName.GetGroupAlbumMediaList;
|
|
26539
|
+
payloadSchema = lib_default$1.object({
|
|
26540
|
+
group_id: lib_default$1.union([Number, String]).required(),
|
|
26541
|
+
album_id: lib_default$1.string().required(),
|
|
26542
|
+
attach_info: lib_default$1.string()
|
|
26543
|
+
});
|
|
26544
|
+
async _handle(payload) {
|
|
26545
|
+
const res = await this.ctx.ntGroupApi.getGroupAlbumMediaList(payload.group_id.toString(), payload.album_id, payload.attach_info);
|
|
26546
|
+
if (res.response.result !== 0) throw new Error(res.response.errMs);
|
|
26547
|
+
return pick(res.response, [
|
|
26548
|
+
"album",
|
|
26549
|
+
"media_list",
|
|
26550
|
+
"next_attach_info",
|
|
26551
|
+
"next_has_more"
|
|
26552
|
+
]);
|
|
26553
|
+
}
|
|
26554
|
+
};
|
|
26555
|
+
//#endregion
|
|
25907
26556
|
//#region src/onebot11/action/index.ts
|
|
25908
26557
|
function initActionMap(adapter) {
|
|
25909
26558
|
const actionHandlers = [
|
|
@@ -25957,6 +26606,8 @@ function initActionMap(adapter) {
|
|
|
25957
26606
|
new SetDoubtFriendsAddRequest(adapter),
|
|
25958
26607
|
new DeleteGroupNotice(adapter),
|
|
25959
26608
|
new SendPoke(adapter),
|
|
26609
|
+
new SetInputStatus(adapter),
|
|
26610
|
+
new GetGroupAlbumMediaList(adapter),
|
|
25960
26611
|
new SendLike(adapter),
|
|
25961
26612
|
new GetMsg(adapter),
|
|
25962
26613
|
new GetLoginInfo$1(adapter),
|
|
@@ -26203,7 +26854,8 @@ var Onebot11Adapter = class extends Service {
|
|
|
26203
26854
|
"app",
|
|
26204
26855
|
"logger",
|
|
26205
26856
|
"pmhq",
|
|
26206
|
-
"timer"
|
|
26857
|
+
"timer",
|
|
26858
|
+
"config"
|
|
26207
26859
|
];
|
|
26208
26860
|
connect;
|
|
26209
26861
|
actionMap;
|
|
@@ -28215,27 +28867,6 @@ var handlers = {
|
|
|
28215
28867
|
deleteFriend
|
|
28216
28868
|
};
|
|
28217
28869
|
//#endregion
|
|
28218
|
-
//#region node_modules/hono/dist/helper/websocket/index.js
|
|
28219
|
-
var defineWebSocketHelper = (handler) => {
|
|
28220
|
-
return ((...args) => {
|
|
28221
|
-
if (typeof args[0] === "function") {
|
|
28222
|
-
const [createEvents, options] = args;
|
|
28223
|
-
return async function upgradeWebSocket(c, next) {
|
|
28224
|
-
const result = await handler(c, await createEvents(c), options);
|
|
28225
|
-
if (result) return result;
|
|
28226
|
-
await next();
|
|
28227
|
-
};
|
|
28228
|
-
} else {
|
|
28229
|
-
const [c, events, options] = args;
|
|
28230
|
-
return (async () => {
|
|
28231
|
-
const upgraded = await handler(c, events, options);
|
|
28232
|
-
if (!upgraded) throw new Error("Failed to upgrade WebSocket");
|
|
28233
|
-
return upgraded;
|
|
28234
|
-
})();
|
|
28235
|
-
}
|
|
28236
|
-
});
|
|
28237
|
-
};
|
|
28238
|
-
//#endregion
|
|
28239
28870
|
//#region node_modules/@hono/node-ws/dist/index.js
|
|
28240
28871
|
/**
|
|
28241
28872
|
* @link https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent
|
|
@@ -43258,7 +43889,7 @@ var ForwardMessageEncoder = class ForwardMessageEncoder {
|
|
|
43258
43889
|
}
|
|
43259
43890
|
async flush() {
|
|
43260
43891
|
if (this.children.length === 0) return;
|
|
43261
|
-
const nick = this.name
|
|
43892
|
+
const nick = this.name ?? selfInfo.nick;
|
|
43262
43893
|
if (this.news.length < 4) this.news.push({ text: `${nick}: ${this.preview}` });
|
|
43263
43894
|
this.results.push({
|
|
43264
43895
|
routingHead: {
|
|
@@ -45776,7 +46407,7 @@ function getIgnoreAttributesFn(ignoreAttributes) {
|
|
|
45776
46407
|
return () => false;
|
|
45777
46408
|
}
|
|
45778
46409
|
//#endregion
|
|
45779
|
-
//#region node_modules/path-expression-matcher/src/Expression.js
|
|
46410
|
+
//#region node_modules/fast-xml-parser/node_modules/path-expression-matcher/src/Expression.js
|
|
45780
46411
|
/**
|
|
45781
46412
|
* Expression - Parses and stores a tag pattern expression
|
|
45782
46413
|
*
|
|
@@ -45928,7 +46559,7 @@ var Expression = class {
|
|
|
45928
46559
|
}
|
|
45929
46560
|
};
|
|
45930
46561
|
//#endregion
|
|
45931
|
-
//#region node_modules/path-expression-matcher/src/ExpressionSet.js
|
|
46562
|
+
//#region node_modules/fast-xml-parser/node_modules/path-expression-matcher/src/ExpressionSet.js
|
|
45932
46563
|
/**
|
|
45933
46564
|
* ExpressionSet - An indexed collection of Expressions for efficient bulk matching
|
|
45934
46565
|
*
|
|
@@ -46101,7 +46732,7 @@ var ExpressionSet = class {
|
|
|
46101
46732
|
}
|
|
46102
46733
|
};
|
|
46103
46734
|
//#endregion
|
|
46104
|
-
//#region node_modules/path-expression-matcher/src/Matcher.js
|
|
46735
|
+
//#region node_modules/fast-xml-parser/node_modules/path-expression-matcher/src/Matcher.js
|
|
46105
46736
|
/**
|
|
46106
46737
|
* MatcherView - A lightweight read-only view over a Matcher's internal state.
|
|
46107
46738
|
*
|
|
@@ -47289,11 +47920,7 @@ async function transformIncomingSegments(ctx, message) {
|
|
|
47289
47920
|
type: "video",
|
|
47290
47921
|
data: {
|
|
47291
47922
|
resource_id: element.videoElement.fileUuid,
|
|
47292
|
-
temp_url: await ctx.ntFileApi.
|
|
47293
|
-
chatType: message.chatType,
|
|
47294
|
-
peerUid: message.peerUid,
|
|
47295
|
-
guildId: message.guildId
|
|
47296
|
-
}, message.msgId, element.elementId),
|
|
47923
|
+
temp_url: await ctx.ntFileApi.getVideoUrlByPacket(element.videoElement.fileUuid, message.chatType === ChatType.Group),
|
|
47297
47924
|
width: element.videoElement.thumbWidth,
|
|
47298
47925
|
height: element.videoElement.thumbHeight,
|
|
47299
47926
|
duration: element.videoElement.fileTime
|
|
@@ -52297,7 +52924,7 @@ var NTQQFileApi = class extends Service {
|
|
|
52297
52924
|
const trans = {
|
|
52298
52925
|
uin: selfInfo.uin,
|
|
52299
52926
|
cmd: 1005,
|
|
52300
|
-
readable: createReadStream
|
|
52927
|
+
readable: createReadStream(filePath, { highWaterMark: maxBlockSize }),
|
|
52301
52928
|
sum: Buffer.from(index.info.md5HexStr, "hex"),
|
|
52302
52929
|
size: index.info.fileSize,
|
|
52303
52930
|
ticket: highwaySession.sigSession,
|
|
@@ -52317,7 +52944,7 @@ var NTQQFileApi = class extends Service {
|
|
|
52317
52944
|
const trans = {
|
|
52318
52945
|
uin: selfInfo.uin,
|
|
52319
52946
|
cmd: 1006,
|
|
52320
|
-
readable: createReadStream
|
|
52947
|
+
readable: createReadStream(thumbPath, { highWaterMark: maxBlockSize }),
|
|
52321
52948
|
sum: Buffer.from(index.info.md5HexStr, "hex"),
|
|
52322
52949
|
size: index.info.fileSize,
|
|
52323
52950
|
ticket: highwaySession.sigSession,
|
|
@@ -52346,7 +52973,7 @@ var NTQQFileApi = class extends Service {
|
|
|
52346
52973
|
const trans = {
|
|
52347
52974
|
uin: selfInfo.uin,
|
|
52348
52975
|
cmd: 1001,
|
|
52349
|
-
readable: createReadStream
|
|
52976
|
+
readable: createReadStream(filePath, { highWaterMark: maxBlockSize }),
|
|
52350
52977
|
sum: Buffer.from(index.info.md5HexStr, "hex"),
|
|
52351
52978
|
size: index.info.fileSize,
|
|
52352
52979
|
ticket: highwaySession.sigSession,
|
|
@@ -52366,7 +52993,7 @@ var NTQQFileApi = class extends Service {
|
|
|
52366
52993
|
const trans = {
|
|
52367
52994
|
uin: selfInfo.uin,
|
|
52368
52995
|
cmd: 1002,
|
|
52369
|
-
readable: createReadStream
|
|
52996
|
+
readable: createReadStream(thumbPath, { highWaterMark: maxBlockSize }),
|
|
52370
52997
|
sum: Buffer.from(index.info.md5HexStr, "hex"),
|
|
52371
52998
|
size: index.info.fileSize,
|
|
52372
52999
|
ticket: highwaySession.sigSession,
|
|
@@ -52425,7 +53052,7 @@ var NTQQFileApi = class extends Service {
|
|
|
52425
53052
|
const trans = {
|
|
52426
53053
|
uin: selfInfo.uin,
|
|
52427
53054
|
cmd: 71,
|
|
52428
|
-
readable: createReadStream
|
|
53055
|
+
readable: createReadStream(filePath, { highWaterMark: 1024 * 1024 }),
|
|
52429
53056
|
sum: result.md5,
|
|
52430
53057
|
size: result.fileSize,
|
|
52431
53058
|
ticket: highwaySession.sigSession,
|
|
@@ -52482,7 +53109,7 @@ var NTQQFileApi = class extends Service {
|
|
|
52482
53109
|
const trans = {
|
|
52483
53110
|
uin: selfInfo.uin,
|
|
52484
53111
|
cmd: 95,
|
|
52485
|
-
readable: createReadStream
|
|
53112
|
+
readable: createReadStream(filePath, { highWaterMark: 1024 * 1024 }),
|
|
52486
53113
|
sum: result.md5CheckSum,
|
|
52487
53114
|
size: result.fileSize,
|
|
52488
53115
|
ticket: highwaySession.sigSession,
|
|
@@ -52636,7 +53263,7 @@ var NTQQGroupApi = class extends Service {
|
|
|
52636
53263
|
async getGroupMembers(groupCode, forceFetch = true) {
|
|
52637
53264
|
return await this.ctx.pmhq.invoke(NTMethod.GROUP_MEMBERS, [groupCode, forceFetch]);
|
|
52638
53265
|
}
|
|
52639
|
-
async getGroupMember(groupCode, uid, forceUpdate = false) {
|
|
53266
|
+
async getGroupMember(groupCode, uid, forceUpdate = false, timeout = 15e3) {
|
|
52640
53267
|
return (await this.ctx.pmhq.invoke("nodeIKernelGroupService/getMemberInfo", [
|
|
52641
53268
|
groupCode,
|
|
52642
53269
|
[uid],
|
|
@@ -52645,7 +53272,8 @@ var NTQQGroupApi = class extends Service {
|
|
|
52645
53272
|
resultCmd: "nodeIKernelGroupListener/onMemberInfoChange",
|
|
52646
53273
|
resultCb: (result) => {
|
|
52647
53274
|
return result[0] === groupCode && result[2].has(uid);
|
|
52648
|
-
}
|
|
53275
|
+
},
|
|
53276
|
+
timeout
|
|
52649
53277
|
}))[2].get(uid);
|
|
52650
53278
|
}
|
|
52651
53279
|
async getSingleScreenNotifies(doubt, number, startSeq = "") {
|
|
@@ -52871,7 +53499,7 @@ var NTQQGroupApi = class extends Service {
|
|
|
52871
53499
|
async getGroupShutUpMemberList(groupCode) {
|
|
52872
53500
|
return (await this.ctx.pmhq.invoke("nodeIKernelGroupService/getGroupShutUpMemberList", [groupCode], {
|
|
52873
53501
|
resultCmd: "nodeIKernelGroupListener/onShutUpMemberListChanged",
|
|
52874
|
-
resultCb: (payload) => payload[0] === groupCode
|
|
53502
|
+
resultCb: (payload) => payload[0] === groupCode || payload[0] === "0"
|
|
52875
53503
|
}))[1];
|
|
52876
53504
|
}
|
|
52877
53505
|
async renameGroupFolder(groupId, folderId, newFolderName) {
|
|
@@ -52939,6 +53567,17 @@ var NTQQGroupApi = class extends Service {
|
|
|
52939
53567
|
}
|
|
52940
53568
|
});
|
|
52941
53569
|
}
|
|
53570
|
+
async getGroupAlbumMediaList(groupCode, albumId, attachInfo = "") {
|
|
53571
|
+
return await this.ctx.pmhq.invoke("nodeIKernelAlbumService/getMediaList", [{
|
|
53572
|
+
qun_id: groupCode,
|
|
53573
|
+
attach_info: attachInfo,
|
|
53574
|
+
seq: 0,
|
|
53575
|
+
request_time_line: { request_invoke_time: "0" },
|
|
53576
|
+
album_id: albumId,
|
|
53577
|
+
lloc: "",
|
|
53578
|
+
batch_id: ""
|
|
53579
|
+
}]);
|
|
53580
|
+
}
|
|
52942
53581
|
};
|
|
52943
53582
|
//#endregion
|
|
52944
53583
|
//#region src/ntqqapi/api/login.ts
|
|
@@ -53307,6 +53946,13 @@ var NTQQMsgApi = class extends Service {
|
|
|
53307
53946
|
async setContactLocalTop(peer, isTop) {
|
|
53308
53947
|
return await this.ctx.pmhq.invoke("nodeIKernelMsgService/setContactLocalTop", [peer, isTop]);
|
|
53309
53948
|
}
|
|
53949
|
+
async sendShowInputStatusReq(chatType, eventType, toUid) {
|
|
53950
|
+
return await this.ctx.pmhq.invoke("nodeIKernelMsgService/sendShowInputStatusReq", [
|
|
53951
|
+
chatType,
|
|
53952
|
+
eventType,
|
|
53953
|
+
toUid
|
|
53954
|
+
]);
|
|
53955
|
+
}
|
|
53310
53956
|
};
|
|
53311
53957
|
//#endregion
|
|
53312
53958
|
//#region src/common/utils/request.ts
|
|
@@ -56782,7 +57428,7 @@ var tryDecodeURI = (str) => tryDecode(str, decodeURI);
|
|
|
56782
57428
|
var serveStatic = (options = { root: "" }) => {
|
|
56783
57429
|
const root = options.root || "";
|
|
56784
57430
|
const optionPath = options.path;
|
|
56785
|
-
if (root !== "" && !existsSync(root)) console.error(`serveStatic: root path '${root}' is not found, are you sure it's correct?`);
|
|
57431
|
+
if (root !== "" && !existsSync$1(root)) console.error(`serveStatic: root path '${root}' is not found, are you sure it's correct?`);
|
|
56786
57432
|
return async (c, next) => {
|
|
56787
57433
|
if (c.finalized) return next();
|
|
56788
57434
|
let filename;
|
|
@@ -60869,7 +61515,19 @@ var require_punycode = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
60869
61515
|
});
|
|
60870
61516
|
};
|
|
60871
61517
|
module.exports = {
|
|
61518
|
+
/**
|
|
61519
|
+
* A string representing the current Punycode.js version number.
|
|
61520
|
+
* @memberOf punycode
|
|
61521
|
+
* @type String
|
|
61522
|
+
*/
|
|
60872
61523
|
version: "2.3.1",
|
|
61524
|
+
/**
|
|
61525
|
+
* An object of methods to convert from JavaScript's internal character
|
|
61526
|
+
* representation (UCS-2) to Unicode code points, and back.
|
|
61527
|
+
* @see <https://mathiasbynens.be/notes/javascript-encoding>
|
|
61528
|
+
* @memberOf punycode
|
|
61529
|
+
* @type Object
|
|
61530
|
+
*/
|
|
60873
61531
|
ucs2: {
|
|
60874
61532
|
decode: ucs2decode,
|
|
60875
61533
|
encode: ucs2encode
|
|
@@ -61142,13 +61800,38 @@ var require_mime_funcs = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
61142
61800
|
var qp = require_qp();
|
|
61143
61801
|
var mimeTypes = require_mime_types();
|
|
61144
61802
|
module.exports = {
|
|
61803
|
+
/**
|
|
61804
|
+
* Checks if a value is plaintext string (uses only printable 7bit chars)
|
|
61805
|
+
*
|
|
61806
|
+
* @param {String} value String to be tested
|
|
61807
|
+
* @returns {Boolean} true if it is a plaintext string
|
|
61808
|
+
*/
|
|
61145
61809
|
isPlainText(value, isParam) {
|
|
61146
61810
|
return typeof value === "string" && !(isParam ? /[\x00-\x08\x0b\x0c\x0e-\x1f"\u0080-\uFFFF]/ : /[\x00-\x08\x0b\x0c\x0e-\x1f\u0080-\uFFFF]/).test(value);
|
|
61147
61811
|
},
|
|
61812
|
+
/**
|
|
61813
|
+
* Checks if a multi line string containes lines longer than the selected value.
|
|
61814
|
+
*
|
|
61815
|
+
* Useful when detecting if a mail message needs any processing at all –
|
|
61816
|
+
* if only plaintext characters are used and lines are short, then there is
|
|
61817
|
+
* no need to encode the values in any way. If the value is plaintext but has
|
|
61818
|
+
* longer lines then allowed, then use format=flowed
|
|
61819
|
+
*
|
|
61820
|
+
* @param {Number} lineLength Max line length to check for
|
|
61821
|
+
* @returns {Boolean} Returns true if there is at least one line longer than lineLength chars
|
|
61822
|
+
*/
|
|
61148
61823
|
hasLongerLines(str, lineLength) {
|
|
61149
61824
|
if (str.length > 128 * 1024) return true;
|
|
61150
61825
|
return new RegExp("^.{" + (lineLength + 1) + ",}", "m").test(str);
|
|
61151
61826
|
},
|
|
61827
|
+
/**
|
|
61828
|
+
* Encodes a string or an Buffer to an UTF-8 MIME Word (rfc2047)
|
|
61829
|
+
*
|
|
61830
|
+
* @param {String|Buffer} data String to be encoded
|
|
61831
|
+
* @param {String} mimeWordEncoding='Q' Encoding for the mime word, either Q or B
|
|
61832
|
+
* @param {Number} [maxLength=0] If set, split mime words into several chunks if needed
|
|
61833
|
+
* @return {String} Single or several mime words joined together
|
|
61834
|
+
*/
|
|
61152
61835
|
encodeWord(data, mimeWordEncoding, maxLength) {
|
|
61153
61836
|
mimeWordEncoding = (mimeWordEncoding || "Q").toString().toUpperCase().trim().charAt(0);
|
|
61154
61837
|
maxLength = maxLength || 0;
|
|
@@ -61184,6 +61867,15 @@ var require_mime_funcs = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
61184
61867
|
else if (mimeWordEncoding === "B") encodedStr = base64.encode(data);
|
|
61185
61868
|
return "=?" + toCharset + "?" + mimeWordEncoding + "?" + encodedStr + (encodedStr.substr(-2) === "?=" ? "" : "?=");
|
|
61186
61869
|
},
|
|
61870
|
+
/**
|
|
61871
|
+
* Finds word sequences with non ascii text and converts these to mime words
|
|
61872
|
+
*
|
|
61873
|
+
* @param {String} value String to be encoded
|
|
61874
|
+
* @param {String} mimeWordEncoding='Q' Encoding for the mime word, either Q or B
|
|
61875
|
+
* @param {Number} [maxLength=0] If set, split mime words into several chunks if needed
|
|
61876
|
+
* @param {Boolean} [encodeAll=false] If true and the value needs encoding then encodes entire string, not just the smallest match
|
|
61877
|
+
* @return {String} String with possible mime words
|
|
61878
|
+
*/
|
|
61187
61879
|
encodeWords(value, mimeWordEncoding, maxLength, encodeAll) {
|
|
61188
61880
|
maxLength = maxLength || 0;
|
|
61189
61881
|
const firstMatch = value.match(/(?:^|\s)([^\s]*["\u0080-\uFFFF])/);
|
|
@@ -61195,6 +61887,13 @@ var require_mime_funcs = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
61195
61887
|
const endIndex = lastMatch.index + (lastMatch[1] || "").length;
|
|
61196
61888
|
return (startIndex ? value.substr(0, startIndex) : "") + this.encodeWord(value.substring(startIndex, endIndex), mimeWordEncoding || "Q", maxLength) + (endIndex < value.length ? value.substr(endIndex) : "");
|
|
61197
61889
|
},
|
|
61890
|
+
/**
|
|
61891
|
+
* Joins parsed header value together as 'value; param1=value1; param2=value2'
|
|
61892
|
+
* PS: We are following RFC 822 for the list of special characters that we need to keep in quotes.
|
|
61893
|
+
* Refer: https://www.w3.org/Protocols/rfc1341/4_Content-Type.html
|
|
61894
|
+
* @param {Object} structured Parsed header value
|
|
61895
|
+
* @return {String} joined header value
|
|
61896
|
+
*/
|
|
61198
61897
|
buildHeaderValue(structured) {
|
|
61199
61898
|
const paramsArray = [];
|
|
61200
61899
|
Object.keys(structured.params || {}).forEach((param) => {
|
|
@@ -61208,6 +61907,21 @@ var require_mime_funcs = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
61208
61907
|
});
|
|
61209
61908
|
return structured.value + (paramsArray.length ? "; " + paramsArray.join("; ") : "");
|
|
61210
61909
|
},
|
|
61910
|
+
/**
|
|
61911
|
+
* Encodes a string or an Buffer to an UTF-8 Parameter Value Continuation encoding (rfc2231)
|
|
61912
|
+
* Useful for splitting long parameter values.
|
|
61913
|
+
*
|
|
61914
|
+
* For example
|
|
61915
|
+
* title="unicode string"
|
|
61916
|
+
* becomes
|
|
61917
|
+
* title*0*=utf-8''unicode
|
|
61918
|
+
* title*1*=%20string
|
|
61919
|
+
*
|
|
61920
|
+
* @param {String|Buffer} data String to be encoded
|
|
61921
|
+
* @param {Number} [maxLength=50] Max length for generated chunks
|
|
61922
|
+
* @param {String} [fromCharset='UTF-8'] Source sharacter set
|
|
61923
|
+
* @return {Array} A list of encoded keys and headers
|
|
61924
|
+
*/
|
|
61211
61925
|
buildHeaderParam(key, data, maxLength) {
|
|
61212
61926
|
const list = [];
|
|
61213
61927
|
let encodedStr = typeof data === "string" ? data : (data || "").toString();
|
|
@@ -61284,6 +61998,21 @@ var require_mime_funcs = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
61284
61998
|
value: item.line
|
|
61285
61999
|
}));
|
|
61286
62000
|
},
|
|
62001
|
+
/**
|
|
62002
|
+
* Parses a header value with key=value arguments into a structured
|
|
62003
|
+
* object.
|
|
62004
|
+
*
|
|
62005
|
+
* parseHeaderValue('content-type: text/plain; CHARSET='UTF-8'') ->
|
|
62006
|
+
* {
|
|
62007
|
+
* 'value': 'text/plain',
|
|
62008
|
+
* 'params': {
|
|
62009
|
+
* 'charset': 'UTF-8'
|
|
62010
|
+
* }
|
|
62011
|
+
* }
|
|
62012
|
+
*
|
|
62013
|
+
* @param {String} str Header value
|
|
62014
|
+
* @return {Object} Header value as a parsed structure
|
|
62015
|
+
*/
|
|
61287
62016
|
parseHeaderValue(str) {
|
|
61288
62017
|
const response = {
|
|
61289
62018
|
value: false,
|
|
@@ -61356,8 +62085,31 @@ var require_mime_funcs = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
61356
62085
|
});
|
|
61357
62086
|
return response;
|
|
61358
62087
|
},
|
|
62088
|
+
/**
|
|
62089
|
+
* Returns file extension for a content type string. If no suitable extensions
|
|
62090
|
+
* are found, 'bin' is used as the default extension
|
|
62091
|
+
*
|
|
62092
|
+
* @param {String} mimeType Content type to be checked for
|
|
62093
|
+
* @return {String} File extension
|
|
62094
|
+
*/
|
|
61359
62095
|
detectExtension: (mimeType) => mimeTypes.detectExtension(mimeType),
|
|
62096
|
+
/**
|
|
62097
|
+
* Returns content type for a file extension. If no suitable content types
|
|
62098
|
+
* are found, 'application/octet-stream' is used as the default content type
|
|
62099
|
+
*
|
|
62100
|
+
* @param {String} extension Extension to be checked for
|
|
62101
|
+
* @return {String} File extension
|
|
62102
|
+
*/
|
|
61360
62103
|
detectMimeType: (extension) => mimeTypes.detectMimeType(extension),
|
|
62104
|
+
/**
|
|
62105
|
+
* Folds long lines, useful for folding header lines (afterSpace=false) and
|
|
62106
|
+
* flowed text (afterSpace=true)
|
|
62107
|
+
*
|
|
62108
|
+
* @param {String} str String to be folded
|
|
62109
|
+
* @param {Number} [lineLength=76] Maximum length of a line
|
|
62110
|
+
* @param {Boolean} afterSpace If true, leave a space in th end of a line
|
|
62111
|
+
* @return {String} String with folded lines
|
|
62112
|
+
*/
|
|
61361
62113
|
foldLines(str, lineLength, afterSpace) {
|
|
61362
62114
|
str = (str || "").toString();
|
|
61363
62115
|
lineLength = lineLength || 76;
|
|
@@ -61384,6 +62136,13 @@ var require_mime_funcs = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
61384
62136
|
}
|
|
61385
62137
|
return result;
|
|
61386
62138
|
},
|
|
62139
|
+
/**
|
|
62140
|
+
* Splits a mime encoded string. Needed for dividing mime words into smaller chunks
|
|
62141
|
+
*
|
|
62142
|
+
* @param {String} str Mime encoded string to be split up
|
|
62143
|
+
* @param {Number} maxlen Maximum length of characters for one part (minimum 12)
|
|
62144
|
+
* @return {Array} Split string
|
|
62145
|
+
*/
|
|
61387
62146
|
splitMimeEncodedString: (str, maxlen) => {
|
|
61388
62147
|
const lines = [];
|
|
61389
62148
|
let curLine, match, chr, done;
|
|
@@ -61799,7 +62558,7 @@ var require_le_unix = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
61799
62558
|
//#endregion
|
|
61800
62559
|
//#region node_modules/nodemailer/lib/mime-node/index.js
|
|
61801
62560
|
var require_mime_node = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
61802
|
-
var crypto$
|
|
62561
|
+
var crypto$8 = __require("crypto");
|
|
61803
62562
|
var fs$4 = __require("fs");
|
|
61804
62563
|
var punycode = require_punycode();
|
|
61805
62564
|
var { PassThrough: PassThrough$2 } = __require("stream");
|
|
@@ -61830,7 +62589,7 @@ var require_mime_node = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
61830
62589
|
/**
|
|
61831
62590
|
* shared part of the unique multipart boundary
|
|
61832
62591
|
*/
|
|
61833
|
-
this.baseBoundary = options.baseBoundary || crypto$
|
|
62592
|
+
this.baseBoundary = options.baseBoundary || crypto$8.randomBytes(8).toString("hex");
|
|
61834
62593
|
this.boundaryPrefix = options.boundaryPrefix || "--_NmP";
|
|
61835
62594
|
this.disableFileAccess = !!options.disableFileAccess;
|
|
61836
62595
|
this.disableUrlAccess = !!options.disableUrlAccess;
|
|
@@ -62717,7 +63476,7 @@ var require_mime_node = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
62717
63476
|
2,
|
|
62718
63477
|
2,
|
|
62719
63478
|
6
|
|
62720
|
-
].reduce((prev, len) => prev + "-" + crypto$
|
|
63479
|
+
].reduce((prev, len) => prev + "-" + crypto$8.randomBytes(len).toString("hex"), crypto$8.randomBytes(4).toString("hex")) + "@" + (this.getEnvelope().from || this.hostname || "localhost").split("@").pop() + ">";
|
|
62721
63480
|
}
|
|
62722
63481
|
};
|
|
62723
63482
|
}));
|
|
@@ -63182,14 +63941,14 @@ var require_message_parser = /* @__PURE__ */ __commonJSMin(((exports, module) =>
|
|
|
63182
63941
|
//#region node_modules/nodemailer/lib/dkim/relaxed-body.js
|
|
63183
63942
|
var require_relaxed_body = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
63184
63943
|
var { Transform: Transform$2 } = __require("stream");
|
|
63185
|
-
var crypto$
|
|
63944
|
+
var crypto$7 = __require("crypto");
|
|
63186
63945
|
var RelaxedBody = class extends Transform$2 {
|
|
63187
63946
|
constructor(options) {
|
|
63188
63947
|
super();
|
|
63189
63948
|
options = options || {};
|
|
63190
63949
|
this.chunkBuffer = [];
|
|
63191
63950
|
this.chunkBufferLen = 0;
|
|
63192
|
-
this.bodyHash = crypto$
|
|
63951
|
+
this.bodyHash = crypto$7.createHash(options.hashAlgo || "sha1");
|
|
63193
63952
|
this.remainder = "";
|
|
63194
63953
|
this.byteLength = 0;
|
|
63195
63954
|
this.debug = options.debug;
|
|
@@ -63268,7 +64027,7 @@ var require_relaxed_body = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
63268
64027
|
var require_sign = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
63269
64028
|
var punycode = require_punycode();
|
|
63270
64029
|
var mimeFuncs = require_mime_funcs();
|
|
63271
|
-
var crypto$
|
|
64030
|
+
var crypto$6 = __require("crypto");
|
|
63272
64031
|
/**
|
|
63273
64032
|
* Returns DKIM signature header line
|
|
63274
64033
|
*
|
|
@@ -63285,7 +64044,7 @@ var require_sign = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
63285
64044
|
const canonicalizedHeaderData = relaxedHeaders(headers, options.headerFieldNames || "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", options.skipFields);
|
|
63286
64045
|
const dkimHeader = generateDKIMHeader(options.domainName, options.keySelector, canonicalizedHeaderData.fieldNames, hashAlgo, bodyHash);
|
|
63287
64046
|
canonicalizedHeaderData.headers += "dkim-signature:" + relaxedHeaderLine(dkimHeader);
|
|
63288
|
-
const signer = crypto$
|
|
64047
|
+
const signer = crypto$6.createSign(("rsa-" + hashAlgo).toUpperCase());
|
|
63289
64048
|
signer.update(canonicalizedHeaderData.headers);
|
|
63290
64049
|
let signature;
|
|
63291
64050
|
try {
|
|
@@ -63349,7 +64108,7 @@ var require_dkim = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
63349
64108
|
var { PassThrough: PassThrough$1 } = __require("stream");
|
|
63350
64109
|
var fs$3 = __require("fs");
|
|
63351
64110
|
var path$2 = __require("path");
|
|
63352
|
-
var crypto$
|
|
64111
|
+
var crypto$5 = __require("crypto");
|
|
63353
64112
|
var DKIM_ALGO = "sha256";
|
|
63354
64113
|
var MAX_MESSAGE_SIZE = 2 * 1024 * 1024;
|
|
63355
64114
|
var DKIMSigner = class {
|
|
@@ -63362,7 +64121,7 @@ var require_dkim = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
63362
64121
|
this.chunks = [];
|
|
63363
64122
|
this.chunklen = 0;
|
|
63364
64123
|
this.readPos = 0;
|
|
63365
|
-
this.cachePath = this.cacheDir ? path$2.join(this.cacheDir, "message." + Date.now() + "-" + crypto$
|
|
64124
|
+
this.cachePath = this.cacheDir ? path$2.join(this.cacheDir, "message." + Date.now() + "-" + crypto$5.randomBytes(14).toString("hex")) : false;
|
|
63366
64125
|
this.cache = false;
|
|
63367
64126
|
this.headers = false;
|
|
63368
64127
|
this.bodyHash = false;
|
|
@@ -63821,7 +64580,7 @@ var require_mailer = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
63821
64580
|
var MailMessage = require_mail_message();
|
|
63822
64581
|
var net$2 = __require("net");
|
|
63823
64582
|
var dns = __require("dns");
|
|
63824
|
-
var crypto$
|
|
64583
|
+
var crypto$4 = __require("crypto");
|
|
63825
64584
|
/**
|
|
63826
64585
|
* Creates an object for exposing the Mail API
|
|
63827
64586
|
*
|
|
@@ -64070,7 +64829,7 @@ var require_mailer = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
64070
64829
|
if (err) return callback(err);
|
|
64071
64830
|
let cidCounter = 0;
|
|
64072
64831
|
html = (html || "").toString().replace(/(<img\b[^<>]{0,1024} src\s{0,20}=[\s"']{0,20})(data:([^;]+);[^"'>\s]+)/gi, (match, prefix, dataUri, mimeType) => {
|
|
64073
|
-
const cid = crypto$
|
|
64832
|
+
const cid = crypto$4.randomBytes(10).toString("hex") + "@localhost";
|
|
64074
64833
|
if (!mail.data.attachments) mail.data.attachments = [];
|
|
64075
64834
|
if (!Array.isArray(mail.data.attachments)) mail.data.attachments = [].concat(mail.data.attachments || []);
|
|
64076
64835
|
mail.data.attachments.push({
|
|
@@ -64179,7 +64938,7 @@ var require_smtp_connection = /* @__PURE__ */ __commonJSMin(((exports, module) =
|
|
|
64179
64938
|
var net$1 = __require("net");
|
|
64180
64939
|
var tls = __require("tls");
|
|
64181
64940
|
var os$1 = __require("os");
|
|
64182
|
-
var crypto$
|
|
64941
|
+
var crypto$3 = __require("crypto");
|
|
64183
64942
|
var DataStream = require_data_stream();
|
|
64184
64943
|
var { PassThrough } = __require("stream");
|
|
64185
64944
|
var shared = require_shared();
|
|
@@ -64234,7 +64993,7 @@ var require_smtp_connection = /* @__PURE__ */ __commonJSMin(((exports, module) =
|
|
|
64234
64993
|
var SMTPConnection = class extends EventEmitter$4 {
|
|
64235
64994
|
constructor(options) {
|
|
64236
64995
|
super(options);
|
|
64237
|
-
this.id = crypto$
|
|
64996
|
+
this.id = crypto$3.randomBytes(8).toString("base64").replace(/\W/g, "");
|
|
64238
64997
|
this.stage = "init";
|
|
64239
64998
|
this.options = options || {};
|
|
64240
64999
|
this.secureConnection = !!this.options.secure;
|
|
@@ -65182,7 +65941,7 @@ var require_smtp_connection = /* @__PURE__ */ __commonJSMin(((exports, module) =
|
|
|
65182
65941
|
const challengeMatch = str.match(/^334\s+(.+)$/);
|
|
65183
65942
|
if (!challengeMatch) return callback(this._formatError("Invalid login sequence while waiting for server challenge string", "EAUTH", str, "AUTH CRAM-MD5"));
|
|
65184
65943
|
const base64decoded = Buffer.from(challengeMatch[1], "base64").toString("ascii");
|
|
65185
|
-
const hmacMD5 = crypto$
|
|
65944
|
+
const hmacMD5 = crypto$3.createHmac("md5", this._auth.credentials.pass);
|
|
65186
65945
|
hmacMD5.update(base64decoded);
|
|
65187
65946
|
const prepended = this._auth.credentials.user + " " + hmacMD5.digest("hex");
|
|
65188
65947
|
this._responseActions.push((str) => {
|
|
@@ -65408,7 +66167,7 @@ var require_smtp_connection = /* @__PURE__ */ __commonJSMin(((exports, module) =
|
|
|
65408
66167
|
var require_xoauth2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
65409
66168
|
var { Stream } = __require("stream");
|
|
65410
66169
|
var nmfetch = require_fetch();
|
|
65411
|
-
var crypto$
|
|
66170
|
+
var crypto$2 = __require("crypto");
|
|
65412
66171
|
var shared = require_shared();
|
|
65413
66172
|
var errors = require_errors();
|
|
65414
66173
|
/**
|
|
@@ -65724,7 +66483,7 @@ var require_xoauth2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
65724
66483
|
*/
|
|
65725
66484
|
jwtSignRS256(payload) {
|
|
65726
66485
|
payload = ["{\"alg\":\"RS256\",\"typ\":\"JWT\"}", JSON.stringify(payload)].map((val) => this.toBase64URL(val)).join(".");
|
|
65727
|
-
const signature = crypto$
|
|
66486
|
+
const signature = crypto$2.createSign("RSA-SHA256").update(payload).sign(this.options.privateKey);
|
|
65728
66487
|
return payload + "." + this.toBase64URL(signature);
|
|
65729
66488
|
}
|
|
65730
66489
|
};
|
|
@@ -68331,7 +69090,6 @@ var PMHQBase = class extends Service {
|
|
|
68331
69090
|
super(ctx, "pmhq");
|
|
68332
69091
|
this.ctx = ctx;
|
|
68333
69092
|
this.logger = ctx.logger("pmhq");
|
|
68334
|
-
this.logger.info(process.argv);
|
|
68335
69093
|
const { pmhqHost, pmhqPort } = this.getPMHQHostPort();
|
|
68336
69094
|
this.httpUrl = `http://${pmhqHost}:${pmhqPort}/`;
|
|
68337
69095
|
this.wsUrl = `ws://${pmhqHost}:${pmhqPort}/ws`;
|
|
@@ -68589,6 +69347,15 @@ var PMHQBase = class extends Service {
|
|
|
68589
69347
|
});
|
|
68590
69348
|
this.call(funcName, args, timeout).then((r) => {
|
|
68591
69349
|
firstResult = r;
|
|
69350
|
+
if (options.onCallResult) {
|
|
69351
|
+
const result = options.onCallResult(r);
|
|
69352
|
+
if (result !== void 0) {
|
|
69353
|
+
resolve(result);
|
|
69354
|
+
this.removeReceiveHook(hookId);
|
|
69355
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
69356
|
+
return;
|
|
69357
|
+
}
|
|
69358
|
+
}
|
|
68592
69359
|
if (r && Object.hasOwn(r, "result") && +r.result !== 0) {
|
|
68593
69360
|
const displayReq = inspect(args, {
|
|
68594
69361
|
depth: 10,
|
|
@@ -69670,7 +70437,7 @@ async function onLoad() {
|
|
|
69670
70437
|
ctx.plugin(EmailNotificationService);
|
|
69671
70438
|
};
|
|
69672
70439
|
const isDocker = isDockerEnvironment();
|
|
69673
|
-
let
|
|
70440
|
+
let lastQrCodeTime = 0;
|
|
69674
70441
|
const printLoginQrCode = async () => {
|
|
69675
70442
|
try {
|
|
69676
70443
|
const data = await ctx.ntLoginApi.getLoginQrCode();
|
|
@@ -69702,8 +70469,9 @@ async function onLoad() {
|
|
|
69702
70469
|
return;
|
|
69703
70470
|
}
|
|
69704
70471
|
if (!pmhqSelfInfo.online) {
|
|
69705
|
-
|
|
69706
|
-
|
|
70472
|
+
const now = Date.now();
|
|
70473
|
+
if (isDocker && now - lastQrCodeTime > 12e4) {
|
|
70474
|
+
lastQrCodeTime = now;
|
|
69707
70475
|
printLoginQrCode();
|
|
69708
70476
|
}
|
|
69709
70477
|
setTimeout(checkLogin, 1e3);
|
|
@@ -69732,6 +70500,7 @@ async function onLoad() {
|
|
|
69732
70500
|
ctx.inject(["logger"], (ctx) => {
|
|
69733
70501
|
ctx.logger.exporter(new Log(ctx, true));
|
|
69734
70502
|
ctx.logger.info(`LLBot ${version$2}`);
|
|
70503
|
+
ctx.logger.info(process.argv);
|
|
69735
70504
|
});
|
|
69736
70505
|
ctx.inject([
|
|
69737
70506
|
"pmhq",
|