@napuketto/adapter 0.18.0 → 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-C7Nnl45P.mjs → core-5cq8w_zB.mjs} +42 -3
- package/dist/core-5cq8w_zB.mjs.map +1 -0
- package/dist/{index-dsurF2t_.d.mts → index-BFvhy1hU.d.mts} +2 -2
- package/dist/{index-dsurF2t_.d.mts.map → index-BFvhy1hU.d.mts.map} +1 -1
- package/dist/{index-B2Hf9yzT.d.mts → index-BHS4Wz74.d.mts} +2 -2
- package/dist/{index-B2Hf9yzT.d.mts.map → index-BHS4Wz74.d.mts.map} +1 -1
- package/dist/{index-DBjlR2dn.d.mts → index-BZfGz6FA.d.mts} +30 -4
- package/dist/index-BZfGz6FA.d.mts.map +1 -0
- package/dist/{index-d_RSpWyb.d.mts → index-BlRIp4xi.d.mts} +2 -2
- package/dist/{index-d_RSpWyb.d.mts.map → index-BlRIp4xi.d.mts.map} +1 -1
- package/dist/{index-B-HpCes-.d.mts → index-oinf9f75.d.mts} +2 -2
- package/dist/{index-B-HpCes-.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-B3por6f4.mjs → kurobot-Bow0EtKl.mjs} +2 -2
- package/dist/{kurobot-B3por6f4.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-Dpk2r5RV.mjs → milky-BW1_XOn6.mjs} +12 -24
- package/dist/{milky-Dpk2r5RV.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-D_JlAsjy.mjs → onebot11-Bypcd8J6.mjs} +12 -31
- package/dist/{onebot11-D_JlAsjy.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-Deamai7y.mjs → satori-9fwjhn6g.mjs} +4 -13
- package/dist/{satori-Deamai7y.mjs.map → satori-9fwjhn6g.mjs.map} +1 -1
- package/package.json +2 -2
- package/dist/core-C7Nnl45P.mjs.map +0 -1
- package/dist/index-DBjlR2dn.d.mts.map +0 -1
package/dist/satori/index.d.mts
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* Satori 协议适配器
|
|
3
3
|
* 公共面:类型 + 动作注册表 + 配置 schema + 传输装配 + 适配器。
|
|
4
4
|
*/
|
|
5
|
-
import { A as Message, B as SatoriActionDeps, C as Emoji, D as GuildRole, E as GuildMember, F as Order, G as SatoriToCanonicalDeps, H as SatoriActionError, I as HTTP_STATUS, J as renderElements, K as SatoriElement, L as satoriHttpStatusMap, M as BidiList, N as Direction, O as Login, P as List, R as SatoriConfig, S as ChannelType, T as Guild, U as SatoriApi, V as createSatoriActionRegistry, W as SatoriApiOptions, _ as MetaBody, a as parseContentToCanonical, b as Signal, c as canonicalToSatoriElements, d as NapukettoSatoriAdapter, f as SatoriAdapterOptions, g as IdentifyBody, h as Event, i as toEventSignal, j as User, k as LoginStatus, l as SatoriEventContent, m as Button, n as SatoriTransportSet, o as satoriToCanonicalElements, p as Argv, q as parseElements, r as assembleSatoriTransports, s as CanonicalToSatoriDeps, t as AssembleSatoriTransportsOptions, u as SatoriEventDeps, v as Opcode, w as Friend, x as Channel, y as ReadyBody, z as satoriConfigSchema } from "../index-
|
|
5
|
+
import { A as Message, B as SatoriActionDeps, C as Emoji, D as GuildRole, E as GuildMember, F as Order, G as SatoriToCanonicalDeps, H as SatoriActionError, I as HTTP_STATUS, J as renderElements, K as SatoriElement, L as satoriHttpStatusMap, M as BidiList, N as Direction, O as Login, P as List, R as SatoriConfig, S as ChannelType, T as Guild, U as SatoriApi, V as createSatoriActionRegistry, W as SatoriApiOptions, _ as MetaBody, a as parseContentToCanonical, b as Signal, c as canonicalToSatoriElements, d as NapukettoSatoriAdapter, f as SatoriAdapterOptions, g as IdentifyBody, h as Event, i as toEventSignal, j as User, k as LoginStatus, l as SatoriEventContent, m as Button, n as SatoriTransportSet, o as satoriToCanonicalElements, p as Argv, q as parseElements, r as assembleSatoriTransports, s as CanonicalToSatoriDeps, t as AssembleSatoriTransportsOptions, u as SatoriEventDeps, v as Opcode, w as Friend, x as Channel, y as ReadyBody, z as satoriConfigSchema } from "../index-BFvhy1hU.mjs";
|
|
6
6
|
export { type Argv, type AssembleSatoriTransportsOptions, type BidiList, type Button, type CanonicalToSatoriDeps, type Channel, type ChannelType, type Direction, type Emoji, type Event, type Friend, type Guild, type GuildMember, type GuildRole, HTTP_STATUS, type IdentifyBody, type List, type Login, type LoginStatus, type Message, type MetaBody, NapukettoSatoriAdapter, type Opcode, type Order, type ReadyBody, type SatoriActionDeps, SatoriActionError, type SatoriAdapterOptions, SatoriApi, type SatoriApiOptions, type SatoriConfig, type SatoriElement, type SatoriEventContent, type SatoriEventDeps, type SatoriToCanonicalDeps, type SatoriTransportSet, type Signal, type User, assembleSatoriTransports, canonicalToSatoriElements, createSatoriActionRegistry, parseContentToCanonical, parseElements, renderElements, satoriConfigSchema, satoriHttpStatusMap, satoriToCanonicalElements, toEventSignal };
|
package/dist/satori/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { f as HTTP_STATUS, t as NapukettoSatoriAdapter, c as SatoriActionError, i as SatoriApi, n as assembleSatoriTransports, d as canonicalToSatoriElements, a as createSatoriActionRegistry, o as parseContentToCanonical, l as parseElements, u as renderElements, m as satoriConfigSchema, p as satoriHttpStatusMap, s as satoriToCanonicalElements, r as toEventSignal } from "../satori-
|
|
1
|
+
export { f as HTTP_STATUS, t as NapukettoSatoriAdapter, c as SatoriActionError, i as SatoriApi, n as assembleSatoriTransports, d as canonicalToSatoriElements, a as createSatoriActionRegistry, o as parseContentToCanonical, l as parseElements, u as renderElements, m as satoriConfigSchema, p as satoriHttpStatusMap, s as satoriToCanonicalElements, r as toEventSignal } from "../satori-9fwjhn6g.mjs";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as resolveProtocolConfig, i as BaseProtocolAdapter,
|
|
1
|
+
import { a as resolveProtocolConfig, i as BaseProtocolAdapter, l as ActionRegistry, r as createServerSchema, s as createTokenAuthorize, u as runAction } from "./core-5cq8w_zB.mjs";
|
|
2
2
|
import { c as MS_TO_SEC, i as toUnixSeconds, p as toUinString, r as subscribeRawMessages } from "./raw-message-Cs4vDKUU.mjs";
|
|
3
3
|
import { a as logEventFailure, c as downloadBufferToFile, l as ensureSilk, t as collectGrayTipUids } from "./gray-tip-DmZmdtjP.mjs";
|
|
4
4
|
import { ChatType, GrayTipSubType, NTGroupRequestOperateTypes, TipGroupElementType, isRecord, kernelError, toCanonicalElements } from "@napuketto/kernel";
|
|
@@ -1518,8 +1518,6 @@ function toMember(uid, nick, remark, uidToUinMap) {
|
|
|
1518
1518
|
const WS_EVENTS_PATH = "/v1/events";
|
|
1519
1519
|
/** HTTP RPC 版本前缀。 */
|
|
1520
1520
|
const V1_PREFIX = "/v1/";
|
|
1521
|
-
/** Authorization 头前缀。 */
|
|
1522
|
-
const BEARER_PREFIX = "Bearer ";
|
|
1523
1521
|
/** resource.method 路径模式(resource 与 method 均为字母开头的小写标识符,可含连字符/数字)。 */
|
|
1524
1522
|
const ACTION_PATH_RE = /^([a-z][a-z0-9-]*)(?:\.[a-z][a-z0-9-]*)+$/i;
|
|
1525
1523
|
/** 按配置装配 Satori 传输。 */
|
|
@@ -1529,10 +1527,11 @@ function assembleSatoriTransports(opts) {
|
|
|
1529
1527
|
for (const item of config.httpServers) {
|
|
1530
1528
|
if (!item.enabled) continue;
|
|
1531
1529
|
const token = item.token ?? config.token;
|
|
1530
|
+
const authorize = createTokenAuthorize(token);
|
|
1532
1531
|
const server = new HttpServer({
|
|
1533
1532
|
host: item.host,
|
|
1534
1533
|
port: item.port,
|
|
1535
|
-
...
|
|
1534
|
+
...authorize !== void 0 ? { authorize } : {}
|
|
1536
1535
|
});
|
|
1537
1536
|
server.onPathRequest = (ctx, req, respond) => {
|
|
1538
1537
|
handleHttpRequest(ctx, req, respond, registry, login);
|
|
@@ -1561,14 +1560,6 @@ function assembleSatoriTransports(opts) {
|
|
|
1561
1560
|
}
|
|
1562
1561
|
};
|
|
1563
1562
|
}
|
|
1564
|
-
/** Bearer token 鉴权钩子。 */
|
|
1565
|
-
function makeBearerAuthorize(token) {
|
|
1566
|
-
return (ctx) => {
|
|
1567
|
-
const auth = ctx.headers["authorization"] ?? ctx.headers["Authorization"];
|
|
1568
|
-
if (auth?.startsWith(BEARER_PREFIX)) return auth.slice(7) === token;
|
|
1569
|
-
return false;
|
|
1570
|
-
};
|
|
1571
|
-
}
|
|
1572
1563
|
/** 解析路径:/v1/{resource}.{method} → 动作名;不匹配返回 null。 */
|
|
1573
1564
|
function parseActionPath(path) {
|
|
1574
1565
|
if (!path.startsWith(V1_PREFIX)) return null;
|
|
@@ -1776,4 +1767,4 @@ function pickEventResources(content) {
|
|
|
1776
1767
|
}
|
|
1777
1768
|
export { createSatoriActionRegistry as a, SatoriActionError as c, canonicalToSatoriElements as d, HTTP_STATUS as f, SatoriApi as i, parseElements as l, satoriConfigSchema as m, assembleSatoriTransports as n, parseContentToCanonical as o, satoriHttpStatusMap as p, toEventSignal as r, satoriToCanonicalElements as s, NapukettoSatoriAdapter as t, renderElements as u };
|
|
1778
1769
|
|
|
1779
|
-
//# sourceMappingURL=satori-
|
|
1770
|
+
//# sourceMappingURL=satori-9fwjhn6g.mjs.map
|