@napuketto/adapter 0.18.1 → 0.18.2
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/dist/core/index.d.mts +2 -2
- package/dist/core/index.mjs +1 -1
- package/dist/{core-4PwF_pJB.mjs → core-5cq8w_zB.mjs} +36 -2
- package/dist/core-5cq8w_zB.mjs.map +1 -0
- package/dist/{index-DAsCCf9S.d.mts → index-BFvhy1hU.d.mts} +2 -2
- package/dist/{index-DAsCCf9S.d.mts.map → index-BFvhy1hU.d.mts.map} +1 -1
- package/dist/{index-lKqnKSwo.d.mts → index-BHS4Wz74.d.mts} +2 -2
- package/dist/{index-lKqnKSwo.d.mts.map → index-BHS4Wz74.d.mts.map} +1 -1
- package/dist/{index-D9Nwf0_4.d.mts → index-BZfGz6FA.d.mts} +26 -3
- package/dist/index-BZfGz6FA.d.mts.map +1 -0
- package/dist/{index-CiitTshy.d.mts → index-BlRIp4xi.d.mts} +2 -2
- package/dist/{index-CiitTshy.d.mts.map → index-BlRIp4xi.d.mts.map} +1 -1
- package/dist/{index-CKH8uaU-.d.mts → index-oinf9f75.d.mts} +2 -2
- package/dist/{index-CKH8uaU-.d.mts.map → index-oinf9f75.d.mts.map} +1 -1
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +5 -5
- package/dist/kurobot/index.d.mts +1 -1
- package/dist/kurobot/index.mjs +1 -1
- package/dist/{kurobot-CG2qGU9G.mjs → kurobot-Bow0EtKl.mjs} +2 -2
- package/dist/{kurobot-CG2qGU9G.mjs.map → kurobot-Bow0EtKl.mjs.map} +1 -1
- package/dist/milky/index.d.mts +1 -1
- package/dist/milky/index.mjs +1 -1
- package/dist/{milky-DMmeotN9.mjs → milky-BW1_XOn6.mjs} +12 -24
- package/dist/{milky-DMmeotN9.mjs.map → milky-BW1_XOn6.mjs.map} +1 -1
- package/dist/onebot11/index.d.mts +1 -1
- package/dist/onebot11/index.mjs +1 -1
- package/dist/{onebot11-CAf9fBoJ.mjs → onebot11-Bypcd8J6.mjs} +12 -31
- package/dist/{onebot11-CAf9fBoJ.mjs.map → onebot11-Bypcd8J6.mjs.map} +1 -1
- package/dist/satori/index.d.mts +1 -1
- package/dist/satori/index.mjs +1 -1
- package/dist/{satori-D5lM6S3L.mjs → satori-9fwjhn6g.mjs} +4 -13
- package/dist/{satori-D5lM6S3L.mjs.map → satori-9fwjhn6g.mjs.map} +1 -1
- package/package.json +1 -1
- package/dist/core-4PwF_pJB.mjs.map +0 -1
- package/dist/index-D9Nwf0_4.d.mts.map +0 -1
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* OneBot 11 协议适配器(当前主战场)
|
|
3
3
|
* 公共面:类型 + 动作注册表 + 配置 schema + 翻译层(adapter.ts 于 打通 kernel 事件后接入)。
|
|
4
4
|
*/
|
|
5
|
-
import { $ as OB11Return, A as Ob11ActionDeps, B as cqMessageToCanonical, C as CqCode, D as parseCqMessage, E as escapeCqText, F as OneBotApiOptions, G as GroupHonorInfo, H as segmentsToCanonical, I as OneBotSystemOptions, J as HonorMember, K as GroupInfo, L as MessageUnique, M as AtAllRemainInfo, N as ob11ErrorCodeMap, O as serializeCqParts, P as OneBotApi, Q as OB11MessageSegment, R as canonicalToCqMessage, S as segmentsToCqMessage, T as escapeCqParam, U as CurrentTalkative, V as cqMessageToSegments, W as FriendInfo, X as OB11Message, Y as LoginInfo, Z as OB11MessageInfo, _ as OB11PrivateMessageEvent, a as OneBot11AdapterOptions, b as OB11Config, c as OB11GroupRequestEvent, d as OB11HeartbeatMetaEvent, et as Sender, f as OB11LifecycleMetaEvent, g as OB11MessageEvent, h as OB11GroupMessageEvent, i as NapukettoOneBot11Adapter, j as createOb11ActionRegistry, k as unescapeCqText, l as OB11RequestEvent, m as OB11Status, n as Ob11TransportSet, nt as StrangerInfo, o as OB11Event, p as OB11MetaEvent, q as GroupMemberInfo, r as assembleOb11Transports, rt as VersionInfo, s as OB11FriendRequestEvent, t as AssembleOb11TransportsOptions, tt as Sex, u as OB11NoticeEvent, v as OB11BaseEvent, w as encodeCqCode, x as ob11ConfigSchema, y as OB11PostType, z as canonicalToSegments } from "../index-
|
|
5
|
+
import { $ as OB11Return, A as Ob11ActionDeps, B as cqMessageToCanonical, C as CqCode, D as parseCqMessage, E as escapeCqText, F as OneBotApiOptions, G as GroupHonorInfo, H as segmentsToCanonical, I as OneBotSystemOptions, J as HonorMember, K as GroupInfo, L as MessageUnique, M as AtAllRemainInfo, N as ob11ErrorCodeMap, O as serializeCqParts, P as OneBotApi, Q as OB11MessageSegment, R as canonicalToCqMessage, S as segmentsToCqMessage, T as escapeCqParam, U as CurrentTalkative, V as cqMessageToSegments, W as FriendInfo, X as OB11Message, Y as LoginInfo, Z as OB11MessageInfo, _ as OB11PrivateMessageEvent, a as OneBot11AdapterOptions, b as OB11Config, c as OB11GroupRequestEvent, d as OB11HeartbeatMetaEvent, et as Sender, f as OB11LifecycleMetaEvent, g as OB11MessageEvent, h as OB11GroupMessageEvent, i as NapukettoOneBot11Adapter, j as createOb11ActionRegistry, k as unescapeCqText, l as OB11RequestEvent, m as OB11Status, n as Ob11TransportSet, nt as StrangerInfo, o as OB11Event, p as OB11MetaEvent, q as GroupMemberInfo, r as assembleOb11Transports, rt as VersionInfo, s as OB11FriendRequestEvent, t as AssembleOb11TransportsOptions, tt as Sex, u as OB11NoticeEvent, v as OB11BaseEvent, w as encodeCqCode, x as ob11ConfigSchema, y as OB11PostType, z as canonicalToSegments } from "../index-BHS4Wz74.mjs";
|
|
6
6
|
export { type AssembleOb11TransportsOptions, type AtAllRemainInfo, type CqCode, type CurrentTalkative, type FriendInfo, type GroupHonorInfo, type GroupInfo, type GroupMemberInfo, type HonorMember, type LoginInfo, MessageUnique, NapukettoOneBot11Adapter, type OB11BaseEvent, type OB11Config, type OB11Event, type OB11FriendRequestEvent, type OB11GroupMessageEvent, type OB11GroupRequestEvent, type OB11HeartbeatMetaEvent, type OB11LifecycleMetaEvent, type OB11Message, type OB11MessageEvent, type OB11MessageInfo, type OB11MessageSegment, type OB11MetaEvent, type OB11NoticeEvent, type OB11PostType, type OB11PrivateMessageEvent, type OB11RequestEvent, type OB11Return, type OB11Status, type Ob11ActionDeps, type Ob11TransportSet, type OneBot11AdapterOptions, OneBotApi, type OneBotApiOptions, type OneBotSystemOptions, type Sender, type Sex, type StrangerInfo, type VersionInfo, assembleOb11Transports, canonicalToCqMessage, canonicalToSegments, cqMessageToCanonical, cqMessageToSegments, createOb11ActionRegistry, encodeCqCode, escapeCqParam, escapeCqText, ob11ConfigSchema, ob11ErrorCodeMap, parseCqMessage, segmentsToCanonical, segmentsToCqMessage, serializeCqParts, unescapeCqText };
|
package/dist/onebot11/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { y as MessageUnique, t as NapukettoOneBot11Adapter, r as OneBotApi, n as assembleOb11Transports, a as canonicalToCqMessage, o as canonicalToSegments, s as cqMessageToCanonical, c as cqMessageToSegments, i as createOb11ActionRegistry, f as encodeCqCode, p as escapeCqParam, m as escapeCqText, u as ob11ConfigSchema, v as ob11ErrorCodeMap, h as parseCqMessage, l as segmentsToCanonical, d as segmentsToCqMessage, g as serializeCqParts, _ as unescapeCqText } from "../onebot11-
|
|
1
|
+
export { y as MessageUnique, t as NapukettoOneBot11Adapter, r as OneBotApi, n as assembleOb11Transports, a as canonicalToCqMessage, o as canonicalToSegments, s as cqMessageToCanonical, c as cqMessageToSegments, i as createOb11ActionRegistry, f as encodeCqCode, p as escapeCqParam, m as escapeCqText, u as ob11ConfigSchema, v as ob11ErrorCodeMap, h as parseCqMessage, l as segmentsToCanonical, d as segmentsToCqMessage, g as serializeCqParts, _ as unescapeCqText } from "../onebot11-Bypcd8J6.mjs";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as resolveProtocolConfig, i as BaseProtocolAdapter,
|
|
1
|
+
import { a as resolveProtocolConfig, i as BaseProtocolAdapter, l as ActionRegistry, o as BEARER_PREFIX, r as createServerSchema, s as createTokenAuthorize, u as runAction } from "./core-5cq8w_zB.mjs";
|
|
2
2
|
import { a as firstNonEmptyString, c as MS_TO_SEC, f as toUin, i as toUnixSeconds, l as NUMERIC_RE, n as senderNickname, o as stringOrUndefined, r as subscribeRawMessages, s as startupBaselineSec, u as numericUin } from "./raw-message-Cs4vDKUU.mjs";
|
|
3
3
|
import { a as logEventFailure, c as downloadBufferToFile, d as prepareVideoElements, i as hasGrayTip, l as ensureSilk, o as sliceRaw, r as firstUntranslatedGrayTip, s as truncRaw, t as collectGrayTipUids, u as fileUriToPath } from "./gray-tip-DmZmdtjP.mjs";
|
|
4
4
|
import { a as EssenceListSync, c as OBSERVED_UNNAMED_SYSMSG_KEYS, d as processSysMsgBlob, f as recognizeSysMsg, i as narrowBuddyReqs, l as narrowSysMsgBlobs, n as batchUnreadNums, o as extractEssenceSetSysMsg, r as filterBuddyReqs, s as narrowEssenceGroupArg, t as BuddyReqDedup } from "./buddy-req-CN7gzJpq.mjs";
|
|
@@ -3689,35 +3689,10 @@ var Ob11EventPipeline = class {
|
|
|
3689
3689
|
* - HTTP 正向(httpPost.enabled):HttpClient 事件上报(fire-and-forget)
|
|
3690
3690
|
* - WS 正向(wsReverse.enabled):WsClient 主动连第三方(双向)
|
|
3691
3691
|
*
|
|
3692
|
-
* 鉴权:token 存在时校验 Authorization: Bearer <token> /
|
|
3692
|
+
* 鉴权:token 存在时校验 Authorization: Bearer <token> / 裸 authorization 头 /
|
|
3693
|
+
* access_token 查询参数(方言开关由 core 鉴权原语参数化)。
|
|
3693
3694
|
* 返回 transports(事件上报用,注册到 broadcaster)与 close(停止时关闭全部)。
|
|
3694
3695
|
*/
|
|
3695
|
-
/** Authorization 头前缀。 */
|
|
3696
|
-
const BEARER_PREFIX = "Bearer ";
|
|
3697
|
-
/** 校验 URL 查询参数里的 access_token(WS client 连接 URL 可能带)。
|
|
3698
|
-
* ⚠️ req.url 是纯路径(无 origin),new URL(相对路径) 必抛——
|
|
3699
|
-
* E2E 实测抓到的 bug(查询参数鉴权从未生效,WS 全被 4401 关闭),
|
|
3700
|
-
* 用 dummy base 解析。 */
|
|
3701
|
-
function hasAccessTokenQuery(url, token) {
|
|
3702
|
-
try {
|
|
3703
|
-
return new URL(url, "http://localhost").searchParams.get("access_token") === token;
|
|
3704
|
-
} catch {
|
|
3705
|
-
return false;
|
|
3706
|
-
}
|
|
3707
|
-
}
|
|
3708
|
-
/** 校验 Authorization: Bearer <token> 头。 */
|
|
3709
|
-
function checkBearer(auth, token) {
|
|
3710
|
-
if (auth === void 0 || !auth.startsWith(BEARER_PREFIX)) return false;
|
|
3711
|
-
return auth.slice(7) === token;
|
|
3712
|
-
}
|
|
3713
|
-
/** 构造鉴权钩子(token 未配置则不鉴权)。 */
|
|
3714
|
-
function makeAuthorize(token) {
|
|
3715
|
-
if (token === void 0 || token === "") return;
|
|
3716
|
-
return (ctx) => {
|
|
3717
|
-
if (checkBearer(ctx.headers["authorization"] ?? ctx.headers["Authorization"], token) || ctx.headers["authorization"] === token) return true;
|
|
3718
|
-
return hasAccessTokenQuery(ctx.url, token);
|
|
3719
|
-
};
|
|
3720
|
-
}
|
|
3721
3696
|
/**
|
|
3722
3697
|
* OneBot 客户端标识头:koishi 的 onebot 适配器按
|
|
3723
3698
|
* x-client-role === "Universal" 与 x-self-id 校验 WS 连接(NapCat 同款头),
|
|
@@ -3757,7 +3732,10 @@ function assembleHttpServers(config, handleRequest, servers) {
|
|
|
3757
3732
|
host: item.host,
|
|
3758
3733
|
port: item.port
|
|
3759
3734
|
};
|
|
3760
|
-
const authorize =
|
|
3735
|
+
const authorize = createTokenAuthorize(item.token ?? config.token, {
|
|
3736
|
+
allowQueryToken: true,
|
|
3737
|
+
allowRawHeader: true
|
|
3738
|
+
});
|
|
3761
3739
|
if (authorize !== void 0) options.authorize = authorize;
|
|
3762
3740
|
const server = new HttpServer(options);
|
|
3763
3741
|
server.onRequest = handleRequest;
|
|
@@ -3772,7 +3750,10 @@ function assembleWsServers(config, handleRequest, servers) {
|
|
|
3772
3750
|
port: item.port,
|
|
3773
3751
|
heartbeat: { intervalMs: item.heartbeatInterval }
|
|
3774
3752
|
};
|
|
3775
|
-
const authorize =
|
|
3753
|
+
const authorize = createTokenAuthorize(item.token ?? config.token, {
|
|
3754
|
+
allowQueryToken: true,
|
|
3755
|
+
allowRawHeader: true
|
|
3756
|
+
});
|
|
3776
3757
|
if (authorize !== void 0) options.authorize = authorize;
|
|
3777
3758
|
const server = new WsServer(options);
|
|
3778
3759
|
server.onRequest = handleRequest;
|
|
@@ -4001,4 +3982,4 @@ function echoFieldOf(req) {
|
|
|
4001
3982
|
}
|
|
4002
3983
|
export { unescapeCqText as _, canonicalToCqMessage as a, cqMessageToSegments as c, segmentsToCqMessage as d, encodeCqCode as f, serializeCqParts as g, parseCqMessage as h, createOb11ActionRegistry as i, segmentsToCanonical as l, escapeCqText as m, assembleOb11Transports as n, canonicalToSegments as o, escapeCqParam as p, OneBotApi as r, cqMessageToCanonical as s, NapukettoOneBot11Adapter as t, ob11ConfigSchema as u, ob11ErrorCodeMap as v, MessageUnique as y };
|
|
4003
3984
|
|
|
4004
|
-
//# sourceMappingURL=onebot11-
|
|
3985
|
+
//# sourceMappingURL=onebot11-Bypcd8J6.mjs.map
|