node-karin 1.4.2-pr.289.c5ac700 → 1.4.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.
Files changed (45) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/index.d.ts +35 -3
  3. package/dist/index.js +197 -55
  4. package/dist/web/assets/cssMode-D0MFGTnU.js.gz +0 -0
  5. package/dist/web/assets/freemarker2-Bs2lMW21.js.gz +0 -0
  6. package/dist/web/assets/handlebars-hau7kLvX.js.gz +0 -0
  7. package/dist/web/assets/html-EfV5-p8p.js.gz +0 -0
  8. package/dist/web/assets/htmlMode-B11x7obO.js.gz +0 -0
  9. package/dist/web/assets/index-Cesl7tCG.css.gz +0 -0
  10. package/dist/web/assets/index-CkssMGQE.js +1 -0
  11. package/dist/web/assets/index-DguHakyI.js +1 -0
  12. package/dist/web/assets/index-QlhSWQs5.js.gz +0 -0
  13. package/dist/web/assets/javascript-CDp1tiYu.js.gz +0 -0
  14. package/dist/web/assets/jsonMode-Bh9xUWG2.js.gz +0 -0
  15. package/dist/web/assets/liquid-D9tHjDZI.js.gz +0 -0
  16. package/dist/web/assets/mdx-DGwk3wRw.js.gz +0 -0
  17. package/dist/web/assets/python-B2RDInDI.js.gz +0 -0
  18. package/dist/web/assets/razor-6iiQQLjm.js.gz +0 -0
  19. package/dist/web/assets/ts.worker-B_RpyLgm.js.gz +0 -0
  20. package/dist/web/assets/tsMode-D4K4N8KB.js.gz +0 -0
  21. package/dist/web/assets/typescript-BGr6sMkH.js.gz +0 -0
  22. package/dist/web/assets/xml-B4nWz7lb.js.gz +0 -0
  23. package/dist/web/assets/yaml-CT9hdUXO.js.gz +0 -0
  24. package/dist/web/index.html +2 -2
  25. package/package.json +4 -1
  26. package/dist/web/assets/cssMode-DC7rmhs6.js.gz +0 -0
  27. package/dist/web/assets/freemarker2-B35y-egq.js.gz +0 -0
  28. package/dist/web/assets/handlebars-G_6buPPD.js.gz +0 -0
  29. package/dist/web/assets/html-BSzxGPdE.js.gz +0 -0
  30. package/dist/web/assets/htmlMode-72hNF9NW.js.gz +0 -0
  31. package/dist/web/assets/index-Bku4ZGCh.js.gz +0 -0
  32. package/dist/web/assets/index-DFjfWRsH.js +0 -1
  33. package/dist/web/assets/index-DIGplvke.css.gz +0 -0
  34. package/dist/web/assets/index-Dw9pKAoC.js +0 -1
  35. package/dist/web/assets/javascript-DGD-9rc7.js.gz +0 -0
  36. package/dist/web/assets/jsonMode-BaBkZaI9.js.gz +0 -0
  37. package/dist/web/assets/liquid-C7veN3Bv.js.gz +0 -0
  38. package/dist/web/assets/mdx-C3_UdmNR.js.gz +0 -0
  39. package/dist/web/assets/python-DT_GcFUe.js.gz +0 -0
  40. package/dist/web/assets/razor-D_kcb_h_.js.gz +0 -0
  41. package/dist/web/assets/ts.worker-Bd4z-OY3.js.gz +0 -0
  42. package/dist/web/assets/tsMode-CRjvNRYF.js.gz +0 -0
  43. package/dist/web/assets/typescript-Dx5VlDYn.js.gz +0 -0
  44. package/dist/web/assets/xml-D_An8ZBt.js.gz +0 -0
  45. package/dist/web/assets/yaml-CGJk8KzB.js.gz +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # 更新日志
2
2
 
3
+ ## [1.4.2](https://github.com/KarinJS/Karin/compare/core-v1.4.1...core-v1.4.2) (2025-03-01)
4
+
5
+
6
+ ### 🐛 Bug Fixes
7
+
8
+ * fix [#287](https://github.com/KarinJS/Karin/issues/287) 提供兼容性 ([1ac554f](https://github.com/KarinJS/Karin/commit/1ac554fcb7b60aacb31fcfc4c5107fd84c1c9ae3))
9
+ * 登录api增加阈值 fix [#288](https://github.com/KarinJS/Karin/issues/288) ([116ed45](https://github.com/KarinJS/Karin/commit/116ed45b0cf9c6e4980d6810c8b4569edee1a0a2))
10
+
3
11
  ## [1.4.1](https://github.com/KarinJS/Karin/compare/core-v1.4.0...core-v1.4.1) (2025-02-28)
4
12
 
5
13
 
package/dist/index.d.ts CHANGED
@@ -8042,13 +8042,37 @@ declare const SEND_MSG = "karin:count:send";
8042
8042
  declare const EVENT_COUNT = "karin:count:fnc";
8043
8043
  /** 文件变动 */
8044
8044
  declare const FILE_CHANGE = "karin:file:change";
8045
+ /** 传递ws连接 */
8046
+ declare const WS_CONNECTION = "ws:connection";
8047
+ /** 传递onebot ws连接 */
8048
+ declare const WS_CONNECTION_ONEBOT = "ws:connection:onebot";
8049
+ /** 传递puppeteer ws连接 */
8050
+ declare const WS_CONNECTION_PUPPETEER = "ws:connection:puppeteer";
8051
+ /** 传递sandbox ws连接 */
8052
+ declare const WS_CONNECTION_SANDBOX = "ws:connection:sandbox";
8053
+ /** 传递ws关闭 */
8054
+ declare const WS_CLOSE = "ws:close";
8055
+ /** 传递onebot ws关闭 */
8056
+ declare const WS_CLOSE_ONEBOT = "ws:close:onebot";
8057
+ /** 传递puppeteer ws关闭 */
8058
+ declare const WS_CLOSE_PUPPETEER = "ws:close:puppeteer";
8059
+ /** 传递sandbox ws关闭 */
8060
+ declare const WS_CLOSE_SANDBOX = "ws:close:sandbox";
8045
8061
 
8046
8062
  declare const key_EVENT_COUNT: typeof EVENT_COUNT;
8047
8063
  declare const key_FILE_CHANGE: typeof FILE_CHANGE;
8048
8064
  declare const key_RECV_MSG: typeof RECV_MSG;
8049
8065
  declare const key_SEND_MSG: typeof SEND_MSG;
8066
+ declare const key_WS_CLOSE: typeof WS_CLOSE;
8067
+ declare const key_WS_CLOSE_ONEBOT: typeof WS_CLOSE_ONEBOT;
8068
+ declare const key_WS_CLOSE_PUPPETEER: typeof WS_CLOSE_PUPPETEER;
8069
+ declare const key_WS_CLOSE_SANDBOX: typeof WS_CLOSE_SANDBOX;
8070
+ declare const key_WS_CONNECTION: typeof WS_CONNECTION;
8071
+ declare const key_WS_CONNECTION_ONEBOT: typeof WS_CONNECTION_ONEBOT;
8072
+ declare const key_WS_CONNECTION_PUPPETEER: typeof WS_CONNECTION_PUPPETEER;
8073
+ declare const key_WS_CONNECTION_SANDBOX: typeof WS_CONNECTION_SANDBOX;
8050
8074
  declare namespace key {
8051
- export { key_EVENT_COUNT as EVENT_COUNT, key_FILE_CHANGE as FILE_CHANGE, key_RECV_MSG as RECV_MSG, key_SEND_MSG as SEND_MSG };
8075
+ export { key_EVENT_COUNT as EVENT_COUNT, key_FILE_CHANGE as FILE_CHANGE, key_RECV_MSG as RECV_MSG, key_SEND_MSG as SEND_MSG, key_WS_CLOSE as WS_CLOSE, key_WS_CLOSE_ONEBOT as WS_CLOSE_ONEBOT, key_WS_CLOSE_PUPPETEER as WS_CLOSE_PUPPETEER, key_WS_CLOSE_SANDBOX as WS_CLOSE_SANDBOX, key_WS_CONNECTION as WS_CONNECTION, key_WS_CONNECTION_ONEBOT as WS_CONNECTION_ONEBOT, key_WS_CONNECTION_PUPPETEER as WS_CONNECTION_PUPPETEER, key_WS_CONNECTION_SANDBOX as WS_CONNECTION_SANDBOX };
8052
8076
  }
8053
8077
 
8054
8078
  type fs_CacheEntry<T = any> = CacheEntry<T>;
@@ -8137,6 +8161,14 @@ type index$3_RequireFunction = RequireFunction;
8137
8161
  type index$3_RequireFunctionSync = RequireFunctionSync;
8138
8162
  type index$3_RequireOptions = RequireOptions;
8139
8163
  declare const index$3_SEND_MSG: typeof SEND_MSG;
8164
+ declare const index$3_WS_CLOSE: typeof WS_CLOSE;
8165
+ declare const index$3_WS_CLOSE_ONEBOT: typeof WS_CLOSE_ONEBOT;
8166
+ declare const index$3_WS_CLOSE_PUPPETEER: typeof WS_CLOSE_PUPPETEER;
8167
+ declare const index$3_WS_CLOSE_SANDBOX: typeof WS_CLOSE_SANDBOX;
8168
+ declare const index$3_WS_CONNECTION: typeof WS_CONNECTION;
8169
+ declare const index$3_WS_CONNECTION_ONEBOT: typeof WS_CONNECTION_ONEBOT;
8170
+ declare const index$3_WS_CONNECTION_PUPPETEER: typeof WS_CONNECTION_PUPPETEER;
8171
+ declare const index$3_WS_CONNECTION_SANDBOX: typeof WS_CONNECTION_SANDBOX;
8140
8172
  type index$3_Watch<T> = Watch<T>;
8141
8173
  declare const index$3_Watch: typeof Watch;
8142
8174
  type index$3_Watcher<T> = Watcher<T>;
@@ -8204,7 +8236,7 @@ declare const index$3_writeJson: typeof writeJson;
8204
8236
  declare const index$3_writeJsonSync: typeof writeJsonSync;
8205
8237
  declare const index$3_yaml: typeof yaml;
8206
8238
  declare namespace index$3 {
8207
- export { type index$3_CacheEntry as CacheEntry, index$3_EVENT_COUNT as EVENT_COUNT, index$3_FILE_CHANGE as FILE_CHANGE, type index$3_Parser as Parser, type index$3_PkgData as PkgData, index$3_RECV_MSG as RECV_MSG, type index$3_RequireFunction as RequireFunction, type index$3_RequireFunctionSync as RequireFunctionSync, type index$3_RequireOptions as RequireOptions, index$3_SEND_MSG as SEND_MSG, index$3_Watch as Watch, index$3_Watcher as Watcher, type index$3_YamlComment as YamlComment, index$3_YamlEditor as YamlEditor, type index$3_YamlValue as YamlValue, index$3_absPath as absPath, index$3_applyComments as applyComments, index$3_base64 as base64, index$3_buffer as buffer, index$3_clearRequire as clearRequire, index$3_clearRequireFile as clearRequireFile, index$3_comment as comment, index$3_copyConfig as copyConfig, index$3_copyConfigSync as copyConfigSync, index$3_copyFiles as copyFiles, index$3_copyFilesSync as copyFilesSync, index$3_createPluginDir as createPluginDir, index$3_downFile as downFile, index$3_existToMkdir as existToMkdir, index$3_existToMkdirSync as existToMkdirSync, index$3_exists as exists, index$3_existsSync as existsSync, fs as file, index$3_filesByExt as filesByExt, index$3_getFiles as getFiles, index$3_getPluginInfo as getPluginInfo, index$3_getRelPath as getRelPath, index$3_isDir as isDir, index$3_isDirSync as isDirSync, index$3_isFile as isFile, index$3_isFileSync as isFileSync, index$3_isPlugin as isPlugin, index$3_isStatic as isStatic, index$3_isSubPath as isSubPath, json$1 as json, index$3_key as key, index$3_lock as lock, index$3_lockMethod as lockMethod, index$3_lockProp as lockProp, index$3_log as log, index$3_logs as logs, index$3_mkdir as mkdir, index$3_mkdirSync as mkdirSync, index$3_parseChangelog as parseChangelog, index$3_pkgRoot as pkgRoot, index$3_randomStr as randomStr, index$3_range as range, index$3_read as read, index$3_readFile as readFile, index$3_readJson as readJson, index$3_readJsonSync as readJsonSync, index$3_requireFile as requireFile, index$3_requireFileSync as requireFileSync, index$3_rmSync as rmSync, index$3_save as save, index$3_sep as sep, index$3_splitPath as splitPath, index$3_stream as stream, index$3_urlToPath as urlToPath, index$3_watch as watch, index$3_watchAndMerge as watchAndMerge, index$3_write as write, index$3_writeJson as writeJson, index$3_writeJsonSync as writeJsonSync, index$3_yaml as yaml };
8239
+ export { type index$3_CacheEntry as CacheEntry, index$3_EVENT_COUNT as EVENT_COUNT, index$3_FILE_CHANGE as FILE_CHANGE, type index$3_Parser as Parser, type index$3_PkgData as PkgData, index$3_RECV_MSG as RECV_MSG, type index$3_RequireFunction as RequireFunction, type index$3_RequireFunctionSync as RequireFunctionSync, type index$3_RequireOptions as RequireOptions, index$3_SEND_MSG as SEND_MSG, index$3_WS_CLOSE as WS_CLOSE, index$3_WS_CLOSE_ONEBOT as WS_CLOSE_ONEBOT, index$3_WS_CLOSE_PUPPETEER as WS_CLOSE_PUPPETEER, index$3_WS_CLOSE_SANDBOX as WS_CLOSE_SANDBOX, index$3_WS_CONNECTION as WS_CONNECTION, index$3_WS_CONNECTION_ONEBOT as WS_CONNECTION_ONEBOT, index$3_WS_CONNECTION_PUPPETEER as WS_CONNECTION_PUPPETEER, index$3_WS_CONNECTION_SANDBOX as WS_CONNECTION_SANDBOX, index$3_Watch as Watch, index$3_Watcher as Watcher, type index$3_YamlComment as YamlComment, index$3_YamlEditor as YamlEditor, type index$3_YamlValue as YamlValue, index$3_absPath as absPath, index$3_applyComments as applyComments, index$3_base64 as base64, index$3_buffer as buffer, index$3_clearRequire as clearRequire, index$3_clearRequireFile as clearRequireFile, index$3_comment as comment, index$3_copyConfig as copyConfig, index$3_copyConfigSync as copyConfigSync, index$3_copyFiles as copyFiles, index$3_copyFilesSync as copyFilesSync, index$3_createPluginDir as createPluginDir, index$3_downFile as downFile, index$3_existToMkdir as existToMkdir, index$3_existToMkdirSync as existToMkdirSync, index$3_exists as exists, index$3_existsSync as existsSync, fs as file, index$3_filesByExt as filesByExt, index$3_getFiles as getFiles, index$3_getPluginInfo as getPluginInfo, index$3_getRelPath as getRelPath, index$3_isDir as isDir, index$3_isDirSync as isDirSync, index$3_isFile as isFile, index$3_isFileSync as isFileSync, index$3_isPlugin as isPlugin, index$3_isStatic as isStatic, index$3_isSubPath as isSubPath, json$1 as json, index$3_key as key, index$3_lock as lock, index$3_lockMethod as lockMethod, index$3_lockProp as lockProp, index$3_log as log, index$3_logs as logs, index$3_mkdir as mkdir, index$3_mkdirSync as mkdirSync, index$3_parseChangelog as parseChangelog, index$3_pkgRoot as pkgRoot, index$3_randomStr as randomStr, index$3_range as range, index$3_read as read, index$3_readFile as readFile, index$3_readJson as readJson, index$3_readJsonSync as readJsonSync, index$3_requireFile as requireFile, index$3_requireFileSync as requireFileSync, index$3_rmSync as rmSync, index$3_save as save, index$3_sep as sep, index$3_splitPath as splitPath, index$3_stream as stream, index$3_urlToPath as urlToPath, index$3_watch as watch, index$3_watchAndMerge as watchAndMerge, index$3_write as write, index$3_writeJson as writeJson, index$3_writeJsonSync as writeJsonSync, index$3_yaml as yaml };
8208
8240
  }
8209
8241
 
8210
8242
  /**
@@ -11325,4 +11357,4 @@ declare let level: ReturnType<typeof createLevelDB>;
11325
11357
  */
11326
11358
  declare const start: () => Promise<void>;
11327
11359
 
11328
- export { type Accept, type AccordionItemProps, type AccordionKV, type AccordionProProps, type AccordionProResult, type AccordionProps, type AccordionResult, type AccountInfo, type Adapter, AdapterBase, type AdapterCommunication, type AdapterInfo, AdapterOneBot, type AdapterOptions, type AdapterPlatform, type AdapterProtocol, type AdapterStandard, type AdapterType, type Adapters, type AllPluginMethods, type AnonymousSegment, type Apps, type ArrayField, type AtElement, type AtSegment, type BaseContact, BaseEvent, type BaseEventOptions, type BaseEventType, type BaseForwardCallback, type BaseMessageCallback, type BasketballElement, Bot, type BoundingBox, type BubbleFaceElement, type Button, type ButtonElement, type Cache, type CacheEntry, type CheckboxField, type CheckboxGroupProps, type CheckboxProps, type CheckboxResult, type Children, type CmdFnc, type Command, type CommandClass, type ComponentConfig, type ComponentProps, type ComponentType, type Components, type ComponentsClass, type Config, type Contact, type ContactElement, type ContactSegment, type Count, type CreateGroupFolderResponse, type CustomMusicElement, type CustomMusicSegment, type CustomNodeElement, type CustomNodeSegments, type DbStreamStatus, type DbStreams, type DiceElement, type DiceSegment, type DirectContact, DirectMessage, type DirectMessageOptions, type DirectNodeElement, type DirectNodeSegment, type DirectSender, type DividerField, type DividerProps, type DownloadFileOptions, type DownloadFileResponse, EVENT_COUNT, type ElementTypes, type Elements, type Env, type Event, type EventParent, type EventToSubEvent, type ExecOptions, type ExecReturn, type ExecType, FILE_CHANGE, type FaceElement, type FaceSegment, type FieldType, type FileElement, type FileList, type FileListMap, type FileSegment, type FileToUrlHandler, type FileToUrlResult, type FormField, type ForwardMessageCallback, type ForwardOptions, type ForwardSegment, type FriendContact, type FriendData, FriendDecreaseNotice, type FriendDecreaseOptions, FriendIncreaseNotice, type FriendIncreaseOptions, FriendMessage, type FriendMessageOptions, type FriendNoticeEventMap, type FriendRequestEventMap, type FriendRequestOptions, type FriendSender, type GetAtAllCountResponse, type GetBot, type GetConfigRequest, type GetConfigResponse, type GetGroupFileListResponse, type GetGroupFileSystemInfoResponse, type GetGroupHighlightsResponse, type GetGroupInfo, type GetGroupMemberInfo, type GetGroupMuteListResponse, type GetMsg, type GetPluginReturn, type GetPluginType, type GiftElement, type GoToOptions, GroupAdminChangedNotice, type GroupAdminChangedOptions, GroupApplyRequest, type GroupApplyRequestOptions, GroupCardChangedNotice, type GroupCardChangedOptions, type GroupContact, type GroupData, GroupFileUploadedNotice, type GroupFileUploadedOptions, GroupHlightsChangedNotice, type GroupHlightsChangedOptions, GroupHonorChangedNotice, type GroupHonorChangedOptions, type GroupInfo, GroupInviteRequest, type GroupInviteRequestOptions, GroupLuckKingNotice, type GroupLuckKingOptions, GroupMemberBanNotice, type GroupMemberBanOptions, type GroupMemberData, GroupMemberDecreaseNotice, type GroupMemberDecreaseOptions, GroupMemberIncreaseNotice, type GroupMemberIncreaseOptions, type GroupMemberInfo, GroupMemberTitleUpdatedNotice, type GroupMemberUniqueTitleChangedOptions, GroupMessage, type GroupMessageOptions, GroupMessageReactionNotice, type GroupMessageReactionOptions, GroupNotice, type GroupNoticeEventMap, GroupPokeNotice, type GroupPokeOptions, GroupRecallNotice, type GroupRecallOptions, type GroupRequestEventMap, type GroupSender, GroupSignInNotice, type GroupSignInOptions, type GroupTempContact, GroupTempMessage, type GroupTempMessageOptions, type GroupTempSender, GroupWholeBanNotice, type GroupWholeBanOptions, type Groups, type GroupsObjectValue, type GuildContact, GuildMessage, type GuildMessageOptions, type GuildSender, type Handler, type HandlerType, type HonorInfoList, type HookCache, type HookCallback, type HookEmitForward, type HookEmitMessage, type HookNext, type HookOptions, type ImageElement, type ImageSegment, type InputGroupProps, type InputProps, type InputResult, type JsonElement, type JsonSegment, type JwtVerifyBase, type JwtVerifyError, type JwtVerifyExpired, type JwtVerifyResult, type JwtVerifySuccess, type JwtVerifyUnauthorized, type KarinButton, type KeyboardElement, type LocalApiResponse, type LocationElement, type LocationSegment, type Log, type Logger, type LoggerExpand, type LoggerLevel, type LoggerOptions, type LongMsgElement, type MarkdownElement, type MarkdownTplElement, type MarketFaceElement, type Message$2 as Message, MessageBase, type MessageEventMap, type MessageEventSub, type MessageHookItem, type MessageOptions, type MessageResponse, type MetaEventBase, type MusicElement, type MusicPlatform, type MusicSegment, type NodeElement, type NormalMessageCallback, type Notice, type NoticeAndRequest, NoticeBase, type NoticeEventMap, type NoticeEventSub, type NoticeOptions, type NumberField, type OB11AllEvent, OB11ApiAction, type OB11ApiParams, type OB11ApiRequest, OB11Event, type OB11EventBase, type OB11FriendSender, type OB11GroupMessage, type OB11GroupSender, type OB11GroupTempMessage, type OB11Message, OB11MessageSubType, OB11MessageType, type OB11Meta, type OB11NodeSegment, type OB11Notice, type OB11NoticeBaseType, OB11NoticeType, type OB11OtherFriendMessage, type OB11PrivateMessage, type OB11Request, type OB11RequestBaseType, OB11RequestType, type OB11Segment, type OB11SegmentBase, type OB11SegmentType, OB11Sex, type OB11serInfo, type ObjectArrayField, type ObjectField, type OneBot11FriendAdd, type OneBot11FriendRecall, type OneBot11FriendRequest, type OneBot11GroupAdmin, type OneBot11GroupBan, type OneBot11GroupCard, type OneBot11GroupDecrease, type OneBot11GroupEssence, type OneBot11GroupIncrease, type OneBot11GroupMessageReaction, type OneBot11GroupMessageReactionLagrange, type OneBot11GroupRecall, type OneBot11GroupRequest, type OneBot11GroupUpload, type OneBot11Heartbeat, type OneBot11Honor, type OneBot11Lifecycle, type OneBot11LuckyKing, type OneBot11Poke, type OnlinePluginInfo, type Option, type Options, type PM2, type Package, type Parser, type PasmsgElement, type Permission, type PkgData, type PkgInfo, Plugin, type PluginFile, type PluginFncTypes, type PluginLists, type PluginOptions, type PluginRule, type PluginUpdateInfo, type Point, type PokeSegment, PrivateApplyRequest, type PrivateApplyRequestOptions, PrivateFileUploadedNotice, type PrivateFileUploadedOptions, PrivatePokeNotice, type PrivatePokeOptions, PrivateRecallNotice, type PrivateRecallOptions, type Privates, type PrivatesObjectValue, type PuppeteerLifeCycleEvent, type QQBotButton, type QQButtonTextType, type QQGroupFileInfo, type QQGroupFolderInfo, type QQGroupHonorInfo, RECV_MSG, type Radio, type RadioField, type RadioGroupProps, type RadioResult, type RawElement, type ReadyMusicElement, ReceiveLikeNotice, type ReceiveLikeOptions, type RecordElement, type RecordSegment, type Redis, type Render, type RenderResult, Renderer, type Renders, type Reply, type ReplyElement, type ReplySegment, type Request, RequestBase, type RequestEventMap, type RequestEventSub, type RequestOptions, type RequireFunction, type RequireFunctionSync, type RequireOptions, type Role, type RpsElement, type RpsSegment, SEND_MSG, type SandBoxAccountInfo, type SandboxMsgRecord, type SandboxSendApi, type SandboxSendSendFriendMsg, type SandboxSendSendGroupMsg, type SandboxSendSendMsg, type SaveResult, type Scene, type ScreenshotClip, type ScreenshotOptions, type SectionField, type Segment, type SelectField, type SendElement, type SendForwardMessageResponse, type SendMessage, type SendMsgHookItem, type SendMsgResults, type Sender, type SenderBase, type SenderGroup, type Sex, type ShakeSegment, type ShareElement, type ShareSegment, type SrcReply, type SwitchField, type SwitchProps, type SwitchResult, type Task, type TextElement, type TextField, type TextSegment, type TitleField, type UnionMessage, type UnregisterBot, type UserInfo, type ValidationRule, type ValueType, type VideoElement, type VideoSegment, type WaitForOptions, Watch, Watcher, type WeatherElement, type XmlElement, type XmlSegment, type YamlComment, YamlEditor, type YamlValue, absPath, accordion, accordionItem, accordionPro, app, applyComments, base64, buffer, buttonHandle, callRender, changelog, checkGitPluginUpdate, checkPkgUpdate, clearRequire, clearRequireFile, comment, index$1 as common, components, index as config, contact, contactDirect, contactFriend, contactGroup, contactGroupTemp, contactGuild, copyConfig, copyConfigSync, copyFiles, copyFilesSync, createDirectMessage, createFriendDecreaseNotice, createFriendIncreaseNotice, createFriendMessage, createGroupAdminChangedNotice, createGroupApplyRequest, createGroupCardChangedNotice, createGroupFileUploadedNotice, createGroupHlightsChangedNotice, createGroupHonorChangedNotice, createGroupInviteRequest, createGroupLuckKingNotice, createGroupMemberAddNotice, createGroupMemberBanNotice, createGroupMemberDelNotice, createGroupMemberTitleUpdatedNotice, createGroupMessage, createGroupMessageReactionNotice, createGroupPokeNotice, createGroupRecallNotice, createGroupSignInNotice, createGroupTempMessage, createGroupWholeBanNotice, createGuildMessage, createInnerLogger, createPluginDir, createPrivateApplyRequest, createPrivateFileUploadedNotice, createPrivatePokeNotice, createPrivateRecallNotice, createRawMessage, createReceiveLikeNotice, debug, karin as default, divider, downFile, errorToString, exec, existToMkdir, existToMkdirSync, exists, existsSync, ffmpeg, ffplay, ffprobe, fs as file, fileToUrl, fileToUrlHandlerKey, filesByExt, formatTime$1 as formatTime, index$3 as fs, getAllBot, getAllBotID, getAllBotList, getBot, getBotCount, getCommit, getFiles, getHash, getPid, getPkgVersion, getPluginInfo, getPlugins, getRelPath, getRemotePkgVersion, getRender, getRenderCount, getRenderList, getRequestIp, getTime, handler$1 as handler, hooks, importModule, initOneBot, input, isClass, isDir, isDirSync, isDocker, isFile, isFileSync, isIPv4Loop, isIPv6Loop, isLinux, isLocalRequest, isLoopback, isMac, isPlugin, isRoot, isStatic, isSubPath, isWin, json$1 as json, karin, karinToQQBot, key, level, lock, lockMethod, lockProp, log, logger, logs, makeForward, makeMessage, type messageType, mkdir, mkdirSync, parseChangelog, pkgRoot, qqbotToKarin, randomStr, range, read, readFile, readJson, readJsonSync, redis, registerBot, registerRender, render, renderHtml, renderMultiHtml, requireFile, requireFileSync, restart, restartDirect, rmSync, save, type screenshot, segment, sendMsg, sender, senderDirect, senderFriend, senderGroup, senderGroupTemp, senderGuild, sep, server, splitPath, start, stream, stringifyError, switchComponent, index$2 as system, unregisterBot, unregisterRender, updateAllGitPlugin, updateAllPkg, updateGitPlugin, updatePkg, uptime$1 as uptime, urlToPath, watch, watchAndMerge, write, writeJson, writeJsonSync, yaml };
11360
+ export { type Accept, type AccordionItemProps, type AccordionKV, type AccordionProProps, type AccordionProResult, type AccordionProps, type AccordionResult, type AccountInfo, type Adapter, AdapterBase, type AdapterCommunication, type AdapterInfo, AdapterOneBot, type AdapterOptions, type AdapterPlatform, type AdapterProtocol, type AdapterStandard, type AdapterType, type Adapters, type AllPluginMethods, type AnonymousSegment, type Apps, type ArrayField, type AtElement, type AtSegment, type BaseContact, BaseEvent, type BaseEventOptions, type BaseEventType, type BaseForwardCallback, type BaseMessageCallback, type BasketballElement, Bot, type BoundingBox, type BubbleFaceElement, type Button, type ButtonElement, type Cache, type CacheEntry, type CheckboxField, type CheckboxGroupProps, type CheckboxProps, type CheckboxResult, type Children, type CmdFnc, type Command, type CommandClass, type ComponentConfig, type ComponentProps, type ComponentType, type Components, type ComponentsClass, type Config, type Contact, type ContactElement, type ContactSegment, type Count, type CreateGroupFolderResponse, type CustomMusicElement, type CustomMusicSegment, type CustomNodeElement, type CustomNodeSegments, type DbStreamStatus, type DbStreams, type DiceElement, type DiceSegment, type DirectContact, DirectMessage, type DirectMessageOptions, type DirectNodeElement, type DirectNodeSegment, type DirectSender, type DividerField, type DividerProps, type DownloadFileOptions, type DownloadFileResponse, EVENT_COUNT, type ElementTypes, type Elements, type Env, type Event, type EventParent, type EventToSubEvent, type ExecOptions, type ExecReturn, type ExecType, FILE_CHANGE, type FaceElement, type FaceSegment, type FieldType, type FileElement, type FileList, type FileListMap, type FileSegment, type FileToUrlHandler, type FileToUrlResult, type FormField, type ForwardMessageCallback, type ForwardOptions, type ForwardSegment, type FriendContact, type FriendData, FriendDecreaseNotice, type FriendDecreaseOptions, FriendIncreaseNotice, type FriendIncreaseOptions, FriendMessage, type FriendMessageOptions, type FriendNoticeEventMap, type FriendRequestEventMap, type FriendRequestOptions, type FriendSender, type GetAtAllCountResponse, type GetBot, type GetConfigRequest, type GetConfigResponse, type GetGroupFileListResponse, type GetGroupFileSystemInfoResponse, type GetGroupHighlightsResponse, type GetGroupInfo, type GetGroupMemberInfo, type GetGroupMuteListResponse, type GetMsg, type GetPluginReturn, type GetPluginType, type GiftElement, type GoToOptions, GroupAdminChangedNotice, type GroupAdminChangedOptions, GroupApplyRequest, type GroupApplyRequestOptions, GroupCardChangedNotice, type GroupCardChangedOptions, type GroupContact, type GroupData, GroupFileUploadedNotice, type GroupFileUploadedOptions, GroupHlightsChangedNotice, type GroupHlightsChangedOptions, GroupHonorChangedNotice, type GroupHonorChangedOptions, type GroupInfo, GroupInviteRequest, type GroupInviteRequestOptions, GroupLuckKingNotice, type GroupLuckKingOptions, GroupMemberBanNotice, type GroupMemberBanOptions, type GroupMemberData, GroupMemberDecreaseNotice, type GroupMemberDecreaseOptions, GroupMemberIncreaseNotice, type GroupMemberIncreaseOptions, type GroupMemberInfo, GroupMemberTitleUpdatedNotice, type GroupMemberUniqueTitleChangedOptions, GroupMessage, type GroupMessageOptions, GroupMessageReactionNotice, type GroupMessageReactionOptions, GroupNotice, type GroupNoticeEventMap, GroupPokeNotice, type GroupPokeOptions, GroupRecallNotice, type GroupRecallOptions, type GroupRequestEventMap, type GroupSender, GroupSignInNotice, type GroupSignInOptions, type GroupTempContact, GroupTempMessage, type GroupTempMessageOptions, type GroupTempSender, GroupWholeBanNotice, type GroupWholeBanOptions, type Groups, type GroupsObjectValue, type GuildContact, GuildMessage, type GuildMessageOptions, type GuildSender, type Handler, type HandlerType, type HonorInfoList, type HookCache, type HookCallback, type HookEmitForward, type HookEmitMessage, type HookNext, type HookOptions, type ImageElement, type ImageSegment, type InputGroupProps, type InputProps, type InputResult, type JsonElement, type JsonSegment, type JwtVerifyBase, type JwtVerifyError, type JwtVerifyExpired, type JwtVerifyResult, type JwtVerifySuccess, type JwtVerifyUnauthorized, type KarinButton, type KeyboardElement, type LocalApiResponse, type LocationElement, type LocationSegment, type Log, type Logger, type LoggerExpand, type LoggerLevel, type LoggerOptions, type LongMsgElement, type MarkdownElement, type MarkdownTplElement, type MarketFaceElement, type Message$2 as Message, MessageBase, type MessageEventMap, type MessageEventSub, type MessageHookItem, type MessageOptions, type MessageResponse, type MetaEventBase, type MusicElement, type MusicPlatform, type MusicSegment, type NodeElement, type NormalMessageCallback, type Notice, type NoticeAndRequest, NoticeBase, type NoticeEventMap, type NoticeEventSub, type NoticeOptions, type NumberField, type OB11AllEvent, OB11ApiAction, type OB11ApiParams, type OB11ApiRequest, OB11Event, type OB11EventBase, type OB11FriendSender, type OB11GroupMessage, type OB11GroupSender, type OB11GroupTempMessage, type OB11Message, OB11MessageSubType, OB11MessageType, type OB11Meta, type OB11NodeSegment, type OB11Notice, type OB11NoticeBaseType, OB11NoticeType, type OB11OtherFriendMessage, type OB11PrivateMessage, type OB11Request, type OB11RequestBaseType, OB11RequestType, type OB11Segment, type OB11SegmentBase, type OB11SegmentType, OB11Sex, type OB11serInfo, type ObjectArrayField, type ObjectField, type OneBot11FriendAdd, type OneBot11FriendRecall, type OneBot11FriendRequest, type OneBot11GroupAdmin, type OneBot11GroupBan, type OneBot11GroupCard, type OneBot11GroupDecrease, type OneBot11GroupEssence, type OneBot11GroupIncrease, type OneBot11GroupMessageReaction, type OneBot11GroupMessageReactionLagrange, type OneBot11GroupRecall, type OneBot11GroupRequest, type OneBot11GroupUpload, type OneBot11Heartbeat, type OneBot11Honor, type OneBot11Lifecycle, type OneBot11LuckyKing, type OneBot11Poke, type OnlinePluginInfo, type Option, type Options, type PM2, type Package, type Parser, type PasmsgElement, type Permission, type PkgData, type PkgInfo, Plugin, type PluginFile, type PluginFncTypes, type PluginLists, type PluginOptions, type PluginRule, type PluginUpdateInfo, type Point, type PokeSegment, PrivateApplyRequest, type PrivateApplyRequestOptions, PrivateFileUploadedNotice, type PrivateFileUploadedOptions, PrivatePokeNotice, type PrivatePokeOptions, PrivateRecallNotice, type PrivateRecallOptions, type Privates, type PrivatesObjectValue, type PuppeteerLifeCycleEvent, type QQBotButton, type QQButtonTextType, type QQGroupFileInfo, type QQGroupFolderInfo, type QQGroupHonorInfo, RECV_MSG, type Radio, type RadioField, type RadioGroupProps, type RadioResult, type RawElement, type ReadyMusicElement, ReceiveLikeNotice, type ReceiveLikeOptions, type RecordElement, type RecordSegment, type Redis, type Render, type RenderResult, Renderer, type Renders, type Reply, type ReplyElement, type ReplySegment, type Request, RequestBase, type RequestEventMap, type RequestEventSub, type RequestOptions, type RequireFunction, type RequireFunctionSync, type RequireOptions, type Role, type RpsElement, type RpsSegment, SEND_MSG, type SandBoxAccountInfo, type SandboxMsgRecord, type SandboxSendApi, type SandboxSendSendFriendMsg, type SandboxSendSendGroupMsg, type SandboxSendSendMsg, type SaveResult, type Scene, type ScreenshotClip, type ScreenshotOptions, type SectionField, type Segment, type SelectField, type SendElement, type SendForwardMessageResponse, type SendMessage, type SendMsgHookItem, type SendMsgResults, type Sender, type SenderBase, type SenderGroup, type Sex, type ShakeSegment, type ShareElement, type ShareSegment, type SrcReply, type SwitchField, type SwitchProps, type SwitchResult, type Task, type TextElement, type TextField, type TextSegment, type TitleField, type UnionMessage, type UnregisterBot, type UserInfo, type ValidationRule, type ValueType, type VideoElement, type VideoSegment, WS_CLOSE, WS_CLOSE_ONEBOT, WS_CLOSE_PUPPETEER, WS_CLOSE_SANDBOX, WS_CONNECTION, WS_CONNECTION_ONEBOT, WS_CONNECTION_PUPPETEER, WS_CONNECTION_SANDBOX, type WaitForOptions, Watch, Watcher, type WeatherElement, type XmlElement, type XmlSegment, type YamlComment, YamlEditor, type YamlValue, absPath, accordion, accordionItem, accordionPro, app, applyComments, base64, buffer, buttonHandle, callRender, changelog, checkGitPluginUpdate, checkPkgUpdate, clearRequire, clearRequireFile, comment, index$1 as common, components, index as config, contact, contactDirect, contactFriend, contactGroup, contactGroupTemp, contactGuild, copyConfig, copyConfigSync, copyFiles, copyFilesSync, createDirectMessage, createFriendDecreaseNotice, createFriendIncreaseNotice, createFriendMessage, createGroupAdminChangedNotice, createGroupApplyRequest, createGroupCardChangedNotice, createGroupFileUploadedNotice, createGroupHlightsChangedNotice, createGroupHonorChangedNotice, createGroupInviteRequest, createGroupLuckKingNotice, createGroupMemberAddNotice, createGroupMemberBanNotice, createGroupMemberDelNotice, createGroupMemberTitleUpdatedNotice, createGroupMessage, createGroupMessageReactionNotice, createGroupPokeNotice, createGroupRecallNotice, createGroupSignInNotice, createGroupTempMessage, createGroupWholeBanNotice, createGuildMessage, createInnerLogger, createPluginDir, createPrivateApplyRequest, createPrivateFileUploadedNotice, createPrivatePokeNotice, createPrivateRecallNotice, createRawMessage, createReceiveLikeNotice, debug, karin as default, divider, downFile, errorToString, exec, existToMkdir, existToMkdirSync, exists, existsSync, ffmpeg, ffplay, ffprobe, fs as file, fileToUrl, fileToUrlHandlerKey, filesByExt, formatTime$1 as formatTime, index$3 as fs, getAllBot, getAllBotID, getAllBotList, getBot, getBotCount, getCommit, getFiles, getHash, getPid, getPkgVersion, getPluginInfo, getPlugins, getRelPath, getRemotePkgVersion, getRender, getRenderCount, getRenderList, getRequestIp, getTime, handler$1 as handler, hooks, importModule, initOneBot, input, isClass, isDir, isDirSync, isDocker, isFile, isFileSync, isIPv4Loop, isIPv6Loop, isLinux, isLocalRequest, isLoopback, isMac, isPlugin, isRoot, isStatic, isSubPath, isWin, json$1 as json, karin, karinToQQBot, key, level, lock, lockMethod, lockProp, log, logger, logs, makeForward, makeMessage, type messageType, mkdir, mkdirSync, parseChangelog, pkgRoot, qqbotToKarin, randomStr, range, read, readFile, readJson, readJsonSync, redis, registerBot, registerRender, render, renderHtml, renderMultiHtml, requireFile, requireFileSync, restart, restartDirect, rmSync, save, type screenshot, segment, sendMsg, sender, senderDirect, senderFriend, senderGroup, senderGroupTemp, senderGuild, sep, server, splitPath, start, stream, stringifyError, switchComponent, index$2 as system, unregisterBot, unregisterRender, updateAllGitPlugin, updateAllPkg, updateGitPlugin, updatePkg, uptime$1 as uptime, urlToPath, watch, watchAndMerge, write, writeJson, writeJsonSync, yaml };
package/dist/index.js CHANGED
@@ -14,9 +14,9 @@ var __export = (target, all) => {
14
14
  __defProp(target, name, { get: all[name], enumerable: true });
15
15
  };
16
16
 
17
- // ../../node_modules/.pnpm/tsup@8.4.0_tsx@4.19.3_typescript@5.7.3/node_modules/tsup/assets/esm_shims.js
17
+ // ../../node_modules/.pnpm/tsup@8.3.6_@swc+core@1.10.18_@swc+helpers@0.5.15__jiti@1.21.7_postcss@8.5.3_tsx@4.19.3_typescript@5.7.3_yaml@2.7.0/node_modules/tsup/assets/esm_shims.js
18
18
  var init_esm_shims = __esm({
19
- "../../node_modules/.pnpm/tsup@8.4.0_tsx@4.19.3_typescript@5.7.3/node_modules/tsup/assets/esm_shims.js"() {
19
+ "../../node_modules/.pnpm/tsup@8.3.6_@swc+core@1.10.18_@swc+helpers@0.5.15__jiti@1.21.7_postcss@8.5.3_tsx@4.19.3_typescript@5.7.3_yaml@2.7.0/node_modules/tsup/assets/esm_shims.js"() {
20
20
  "use strict";
21
21
  }
22
22
  });
@@ -1688,9 +1688,17 @@ __export(key_exports, {
1688
1688
  EVENT_COUNT: () => EVENT_COUNT,
1689
1689
  FILE_CHANGE: () => FILE_CHANGE,
1690
1690
  RECV_MSG: () => RECV_MSG,
1691
- SEND_MSG: () => SEND_MSG
1691
+ SEND_MSG: () => SEND_MSG,
1692
+ WS_CLOSE: () => WS_CLOSE,
1693
+ WS_CLOSE_ONEBOT: () => WS_CLOSE_ONEBOT,
1694
+ WS_CLOSE_PUPPETEER: () => WS_CLOSE_PUPPETEER,
1695
+ WS_CLOSE_SANDBOX: () => WS_CLOSE_SANDBOX,
1696
+ WS_CONNECTION: () => WS_CONNECTION,
1697
+ WS_CONNECTION_ONEBOT: () => WS_CONNECTION_ONEBOT,
1698
+ WS_CONNECTION_PUPPETEER: () => WS_CONNECTION_PUPPETEER,
1699
+ WS_CONNECTION_SANDBOX: () => WS_CONNECTION_SANDBOX
1692
1700
  });
1693
- var RECV_MSG, SEND_MSG, EVENT_COUNT, FILE_CHANGE;
1701
+ var RECV_MSG, SEND_MSG, EVENT_COUNT, FILE_CHANGE, WS_CONNECTION, WS_CONNECTION_ONEBOT, WS_CONNECTION_PUPPETEER, WS_CONNECTION_SANDBOX, WS_CLOSE, WS_CLOSE_ONEBOT, WS_CLOSE_PUPPETEER, WS_CLOSE_SANDBOX;
1694
1702
  var init_key = __esm({
1695
1703
  "src/utils/fs/key.ts"() {
1696
1704
  "use strict";
@@ -1699,6 +1707,14 @@ var init_key = __esm({
1699
1707
  SEND_MSG = "karin:count:send";
1700
1708
  EVENT_COUNT = "karin:count:fnc";
1701
1709
  FILE_CHANGE = "karin:file:change";
1710
+ WS_CONNECTION = "ws:connection";
1711
+ WS_CONNECTION_ONEBOT = "ws:connection:onebot";
1712
+ WS_CONNECTION_PUPPETEER = "ws:connection:puppeteer";
1713
+ WS_CONNECTION_SANDBOX = "ws:connection:sandbox";
1714
+ WS_CLOSE = "ws:close";
1715
+ WS_CLOSE_ONEBOT = "ws:close:onebot";
1716
+ WS_CLOSE_PUPPETEER = "ws:close:puppeteer";
1717
+ WS_CLOSE_SANDBOX = "ws:close:sandbox";
1702
1718
  }
1703
1719
  });
1704
1720
 
@@ -1796,6 +1812,14 @@ __export(fs_exports2, {
1796
1812
  FILE_CHANGE: () => FILE_CHANGE,
1797
1813
  RECV_MSG: () => RECV_MSG,
1798
1814
  SEND_MSG: () => SEND_MSG,
1815
+ WS_CLOSE: () => WS_CLOSE,
1816
+ WS_CLOSE_ONEBOT: () => WS_CLOSE_ONEBOT,
1817
+ WS_CLOSE_PUPPETEER: () => WS_CLOSE_PUPPETEER,
1818
+ WS_CLOSE_SANDBOX: () => WS_CLOSE_SANDBOX,
1819
+ WS_CONNECTION: () => WS_CONNECTION,
1820
+ WS_CONNECTION_ONEBOT: () => WS_CONNECTION_ONEBOT,
1821
+ WS_CONNECTION_PUPPETEER: () => WS_CONNECTION_PUPPETEER,
1822
+ WS_CONNECTION_SANDBOX: () => WS_CONNECTION_SANDBOX,
1799
1823
  Watch: () => Watch,
1800
1824
  Watcher: () => Watcher,
1801
1825
  YamlEditor: () => YamlEditor,
@@ -3136,10 +3160,10 @@ var init_auth = __esm({
3136
3160
  }
3137
3161
  });
3138
3162
 
3139
- // src/server/middleware.ts
3163
+ // src/server/auth/middleware.ts
3140
3164
  var authMiddleware;
3141
3165
  var init_middleware = __esm({
3142
- "src/server/middleware.ts"() {
3166
+ "src/server/auth/middleware.ts"() {
3143
3167
  "use strict";
3144
3168
  init_esm_shims();
3145
3169
  init_auth();
@@ -4439,18 +4463,20 @@ var init_info = __esm({
4439
4463
  init_router();
4440
4464
  init_internal();
4441
4465
  init_response();
4466
+ init_key();
4467
+ init_env();
4442
4468
  wsOneBotSet = /* @__PURE__ */ new Set();
4443
4469
  wsPuppeteerSet = /* @__PURE__ */ new Set();
4444
- listeners.on("ws:connection:onebot", (socket) => {
4470
+ listeners.on(WS_CONNECTION_ONEBOT, (socket) => {
4445
4471
  wsOneBotSet.add(socket);
4446
4472
  });
4447
- listeners.on("ws:connection:puppeteer", (socket) => {
4473
+ listeners.on(WS_CONNECTION_PUPPETEER, (socket) => {
4448
4474
  wsPuppeteerSet.add(socket);
4449
4475
  });
4450
- listeners.on("ws:close:onebot", (socket) => {
4476
+ listeners.on(WS_CLOSE_ONEBOT, (socket) => {
4451
4477
  wsOneBotSet.delete(socket);
4452
4478
  });
4453
- listeners.on("ws:close:puppeteer", (socket) => {
4479
+ listeners.on(WS_CLOSE_PUPPETEER, (socket) => {
4454
4480
  wsPuppeteerSet.delete(socket);
4455
4481
  });
4456
4482
  pingRouter = (_req, res) => {
@@ -4469,7 +4495,7 @@ var init_info = __esm({
4469
4495
  pm2_id: process.env.pm_id || "",
4470
4496
  uptime: process.uptime(),
4471
4497
  version: process.env.KARIN_VERSION,
4472
- karin_dev: process.env.NODE_ENV === "development",
4498
+ karin_dev: isDev(),
4473
4499
  karin_lang: process.env.RUNTIME === "tsx" ? "ts" : "js",
4474
4500
  karin_runtime: process.env.RUNTIME
4475
4501
  };
@@ -10243,9 +10269,10 @@ var init_sandbox = __esm({
10243
10269
  init_bot();
10244
10270
  init_adapter2();
10245
10271
  init_response();
10246
- init_db();
10247
10272
  init_create();
10248
10273
  init_avatar();
10274
+ init_db();
10275
+ init_key();
10249
10276
  getSelfInfoRouter = async (req, res) => {
10250
10277
  try {
10251
10278
  const info = await getAccountInfo();
@@ -10578,8 +10605,9 @@ var init_sandbox = __esm({
10578
10605
  }
10579
10606
  };
10580
10607
  main2 = () => {
10581
- listeners.on("ws:connection:sandbox", async (socket, request3) => {
10608
+ listeners.on(WS_CONNECTION_SANDBOX, async (socket, request3, call2) => {
10582
10609
  var _a;
10610
+ call2();
10583
10611
  try {
10584
10612
  const url = new URL(request3.url || "", `http://${request3.headers.host}`);
10585
10613
  const authFromUrl = url.searchParams.get("authorization");
@@ -11395,26 +11423,32 @@ var init_update = __esm({
11395
11423
  }
11396
11424
  };
11397
11425
  getPkgVersion = async (name) => {
11398
- var _a, _b, _c, _d;
11399
- const { status, stdout, error } = await exec(`npm list ${name} --depth=0`);
11400
- if (status) {
11401
- if ((_a = error == null ? void 0 : error.stack) == null ? void 0 : _a.toString().includes("empty")) {
11426
+ var _a, _b, _c, _d, _e;
11427
+ const { stdout, error } = await exec(`npm list ${name} --depth=0`);
11428
+ if (stdout) {
11429
+ const data = stdout.toString();
11430
+ if (data.includes("empty") || data.includes("extraneous")) {
11431
+ throw new Error(`\u83B7\u53D6\u5931\u8D25\uFF0C${name} \u672A\u5B89\u88C5`);
11432
+ }
11433
+ const reg = new RegExp(`${name}@(\\d+\\.\\d+\\.\\d+)`, "gm");
11434
+ const result = reg.exec(data);
11435
+ if (result == null ? void 0 : result[1]) return result[1];
11436
+ }
11437
+ if (error) {
11438
+ if (((_a = error == null ? void 0 : error.stack) == null ? void 0 : _a.toString().includes("empty")) || ((_b = error == null ? void 0 : error.stack) == null ? void 0 : _b.toString().includes("extraneous"))) {
11402
11439
  throw new Error(`\u83B7\u53D6\u5931\u8D25\uFF0C${name} \u672A\u5B89\u88C5`);
11403
11440
  }
11404
11441
  throw error;
11405
11442
  }
11406
- const reg = new RegExp(`${name}@(\\d+\\.\\d+\\.\\d+)`, "gm");
11407
- const result = reg.exec(stdout.toString());
11408
- if (result == null ? void 0 : result[1]) return result[1];
11409
11443
  const pkg2 = await getPkg();
11410
- return ((_b = pkg2 == null ? void 0 : pkg2.dependencies) == null ? void 0 : _b[name]) || ((_c = pkg2 == null ? void 0 : pkg2.devDependencies) == null ? void 0 : _c[name]) || ((_d = pkg2 == null ? void 0 : pkg2.peerDependencies) == null ? void 0 : _d[name]);
11444
+ return ((_c = pkg2 == null ? void 0 : pkg2.dependencies) == null ? void 0 : _c[name]) || ((_d = pkg2 == null ? void 0 : pkg2.devDependencies) == null ? void 0 : _d[name]) || ((_e = pkg2 == null ? void 0 : pkg2.peerDependencies) == null ? void 0 : _e[name]);
11411
11445
  };
11412
11446
  getRemotePkgVersion = async (name, tag = "latest") => {
11413
- var _a;
11447
+ var _a, _b;
11414
11448
  const cmd = tag === "latest" ? `npm show ${name} version` : `npm show ${name} dist-tags.${tag}`;
11415
11449
  const { status, stdout, error } = await exec(cmd);
11416
11450
  if (!status) {
11417
- if ((_a = error == null ? void 0 : error.stack) == null ? void 0 : _a.toString().includes("empty")) {
11451
+ if (((_a = error == null ? void 0 : error.stack) == null ? void 0 : _a.toString().includes("empty")) || ((_b = error == null ? void 0 : error.stack) == null ? void 0 : _b.toString().includes("extraneous"))) {
11418
11452
  throw new Error(`\u83B7\u53D6\u5931\u8D25\uFF0C${name} \u672A\u5B89\u88C5`);
11419
11453
  }
11420
11454
  throw error;
@@ -12144,7 +12178,7 @@ var init_utils = __esm({
12144
12178
  });
12145
12179
 
12146
12180
  // src/server/api/auth/login.ts
12147
- var loginRouter;
12181
+ var IP_LIMIT_CONFIG, ipRecords, cleanupIPRecords, checkIPBlocked, handleLoginFailure, handleLoginSuccess, validateCredentials, loginRouter;
12148
12182
  var init_login = __esm({
12149
12183
  "src/server/api/auth/login.ts"() {
12150
12184
  "use strict";
@@ -12152,15 +12186,89 @@ var init_login = __esm({
12152
12186
  init_router();
12153
12187
  init_response();
12154
12188
  init_jwt();
12189
+ IP_LIMIT_CONFIG = {
12190
+ /** 最大尝试次数 */
12191
+ maxAttempts: 5,
12192
+ /** 时间窗口 */
12193
+ timeWindow: 5 * 60 * 1e3,
12194
+ /** 封禁时长 */
12195
+ blockDuration: 30 * 60 * 1e3
12196
+ };
12197
+ ipRecords = /* @__PURE__ */ new Map();
12198
+ cleanupIPRecords = () => {
12199
+ const now = Date.now();
12200
+ for (const [ip, record2] of ipRecords.entries()) {
12201
+ if (record2.blockedUntil && record2.blockedUntil < now || now - record2.firstAttempt > IP_LIMIT_CONFIG.timeWindow) {
12202
+ ipRecords.delete(ip);
12203
+ }
12204
+ }
12205
+ };
12206
+ setInterval(cleanupIPRecords, 10 * 60 * 1e3);
12207
+ checkIPBlocked = (clientIP, res) => {
12208
+ const now = Date.now();
12209
+ const ipRecord = ipRecords.get(clientIP) || { attempts: 0, firstAttempt: now };
12210
+ if (ipRecord.blockedUntil && ipRecord.blockedUntil > now) {
12211
+ const additionalAttempts = ipRecord.attempts + 1 - IP_LIMIT_CONFIG.maxAttempts;
12212
+ const extraBlockTime = Math.min(
12213
+ IP_LIMIT_CONFIG.blockDuration * additionalAttempts,
12214
+ 24 * 60 * 60 * 1e3
12215
+ // 最长封禁24小时
12216
+ );
12217
+ ipRecord.blockedUntil = now + extraBlockTime;
12218
+ ipRecord.attempts++;
12219
+ ipRecords.set(clientIP, ipRecord);
12220
+ const remainingTime = Math.ceil((ipRecord.blockedUntil - now) / 1e3 / 60);
12221
+ const tips3 = `\u767B\u5F55\u5C1D\u8BD5\u6B21\u6570\u8FC7\u591A,\u8BF7\u5728${remainingTime}\u5206\u949F\u540E\u91CD\u8BD5`;
12222
+ createForbiddenResponse(res, tips3);
12223
+ logger.warn(`${logger.red("login")}: ${clientIP} \u7EE7\u7EED\u5C1D\u8BD5\u767B\u5F55, \u5F53\u524D\u5C1D\u8BD5\u6B21\u6570:${ipRecord.attempts}, \u5C01\u7981\u65F6\u95F4\u5EF6\u957F\u81F3${remainingTime}\u5206\u949F`);
12224
+ return {
12225
+ isBlocked: true,
12226
+ ipRecord
12227
+ };
12228
+ }
12229
+ if (now - ipRecord.firstAttempt > IP_LIMIT_CONFIG.timeWindow) {
12230
+ ipRecord.attempts = 0;
12231
+ ipRecord.firstAttempt = now;
12232
+ }
12233
+ return { isBlocked: false, ipRecord };
12234
+ };
12235
+ handleLoginFailure = (clientIP, ipRecord, res) => {
12236
+ const now = Date.now();
12237
+ ipRecord.attempts++;
12238
+ if (ipRecord.attempts >= IP_LIMIT_CONFIG.maxAttempts) {
12239
+ ipRecord.blockedUntil = now + IP_LIMIT_CONFIG.blockDuration;
12240
+ ipRecords.set(clientIP, ipRecord);
12241
+ const remainingTime = Math.ceil(IP_LIMIT_CONFIG.blockDuration / 1e3 / 60);
12242
+ const tips3 = `\u767B\u5F55\u5C1D\u8BD5\u6B21\u6570\u8FC7\u591A,\u8BF7\u5728${remainingTime}\u5206\u949F\u540E\u91CD\u8BD5`;
12243
+ logger.warn(`${logger.red("login")}: ${clientIP} ${tips3}`);
12244
+ return createForbiddenResponse(res, tips3);
12245
+ }
12246
+ ipRecords.set(clientIP, ipRecord);
12247
+ logger.warn(`${logger.red("login")}: ${clientIP} \u5BC6\u7801\u9519\u8BEF`);
12248
+ return createBadRequestResponse(res, "\u5BC6\u7801\u9519\u8BEF");
12249
+ };
12250
+ handleLoginSuccess = (clientIP, res) => {
12251
+ ipRecords.delete(clientIP);
12252
+ const { userId, accessToken, refreshToken } = createJwt();
12253
+ return createSuccessResponse(res, { userId, accessToken, refreshToken }, "\u767B\u5F55\u6210\u529F");
12254
+ };
12255
+ validateCredentials = (authorization) => {
12256
+ const token = authorization == null ? void 0 : authorization.replace("Bearer ", "");
12257
+ return token && token === getSecretOrPrivateKey();
12258
+ };
12155
12259
  loginRouter = async (req, res) => {
12156
12260
  try {
12261
+ const clientIP = req.ip || req.socket.remoteAddress || "unknown";
12262
+ logger.info(`${logger.green("login")}: ${clientIP} ${JSON.stringify(req.body)}`);
12263
+ const { isBlocked, ipRecord } = checkIPBlocked(clientIP, res);
12264
+ if (isBlocked) return;
12157
12265
  const { authorization } = req.body || {};
12158
- const tips3 = "\u5BC6\u7801\u9519\u8BEF";
12159
- if (!authorization) return createBadRequestResponse(res, tips3);
12160
- const token = authorization == null ? void 0 : authorization.replace("Bearer ", "");
12161
- if (!token || token !== getSecretOrPrivateKey()) return createBadRequestResponse(res, tips3);
12162
- const { userId, accessToken, refreshToken } = createJwt();
12163
- createSuccessResponse(res, { userId, accessToken, refreshToken }, "\u767B\u5F55\u6210\u529F");
12266
+ const isValid = validateCredentials(authorization);
12267
+ if (!isValid) {
12268
+ handleLoginFailure(clientIP, ipRecord, res);
12269
+ return;
12270
+ }
12271
+ handleLoginSuccess(clientIP, res);
12164
12272
  } catch (error) {
12165
12273
  logger.error(error);
12166
12274
  createServerErrorResponse(res, error instanceof Error ? error.message : "\u670D\u52A1\u5668\u9519\u8BEF");
@@ -12233,17 +12341,36 @@ var init_api = __esm({
12233
12341
  // src/server/ws.ts
12234
12342
  var ws_exports = {};
12235
12343
  __export(ws_exports, {
12344
+ emitEvent: () => emitEvent,
12236
12345
  wss: () => wss
12237
12346
  });
12238
12347
  import { WebSocketServer } from "ws";
12239
- var wss;
12348
+ var wss, emitEvent;
12240
12349
  var init_ws = __esm({
12241
12350
  "src/server/ws.ts"() {
12242
12351
  "use strict";
12243
12352
  init_esm_shims();
12244
12353
  init_app();
12245
12354
  init_internal();
12355
+ init_key();
12246
12356
  wss = new WebSocketServer({ server });
12357
+ emitEvent = (key, socket, request3) => {
12358
+ let isClose = true;
12359
+ const call2 = () => {
12360
+ isClose = false;
12361
+ timer && clearTimeout(timer);
12362
+ };
12363
+ const timer = setTimeout(() => {
12364
+ if (!isClose) return;
12365
+ socket.close();
12366
+ logger.warn(
12367
+ `[WebSocket] \u94FE\u63A5\u65E0\u51FD\u6570\u63A5\u7BA1 \u5DF2\u81EA\u52A8\u65AD\u5F00ip: ${request3.socket.remoteAddress}
12368
+ host: ${request3.headers.host}${request3.url}
12369
+ headers: ${JSON.stringify(request3.headers, null, 2)}`
12370
+ );
12371
+ }, 3e3);
12372
+ listeners.emit(key, socket, request3, call2);
12373
+ };
12247
12374
  wss.on("error", (error) => {
12248
12375
  if (error.code === "EADDRINUSE") {
12249
12376
  logger.fatal(`[server] \u7AEF\u53E3 ${process.env.HTTP_PORT} \u5DF2\u88AB\u5360\u7528\uFF0C\u65E0\u6CD5\u542F\u52A8 http WebSocket \u670D\u52A1`);
@@ -12254,32 +12381,33 @@ var init_ws = __esm({
12254
12381
  });
12255
12382
  wss.on("connection", (socket, request3) => {
12256
12383
  var _a;
12257
- debug(`wss:connection host: ${request3.headers.host} url: ${request3.url}`);
12258
- logger.debug(`[WebSocketServer] host: ${request3.headers.host} url: ${request3.url}`);
12384
+ logger.mark(
12385
+ `[WebSocket] ${logger.green("connection")}:
12386
+ ip: ${request3.socket.remoteAddress}
12387
+ host: ${request3.headers.host}${request3.url}
12388
+ headers: ${JSON.stringify(request3.headers, null, 2)}`
12389
+ );
12259
12390
  if (request3.url === "/" || request3.url === "/onebot/v11/ws" || request3.url === "/onebot/v11/ws/") {
12260
- listeners.emit("ws:connection:onebot", socket, request3);
12391
+ emitEvent(WS_CONNECTION_ONEBOT, socket, request3);
12261
12392
  socket.on("close", (code, reason) => {
12262
- listeners.emit("ws:close:onebot", socket, request3, code, reason);
12393
+ listeners.emit(WS_CLOSE_ONEBOT, socket, request3, code, reason);
12263
12394
  });
12264
12395
  return;
12265
12396
  }
12266
12397
  if (request3.url === "/puppeteer") {
12267
- listeners.emit("ws:connection:puppeteer", socket, request3);
12398
+ emitEvent(WS_CONNECTION_PUPPETEER, socket, request3);
12268
12399
  socket.once("close", (code, reason) => {
12269
- listeners.emit("ws:close:puppeteer", socket, request3, code, reason);
12400
+ listeners.emit(WS_CLOSE_PUPPETEER, socket, request3, code, reason);
12270
12401
  });
12271
12402
  return;
12272
12403
  }
12273
12404
  if ((_a = request3.url) == null ? void 0 : _a.startsWith("/sandbox")) {
12274
- listeners.emit("ws:connection:sandbox", socket, request3);
12275
- socket.once("close", (code, reason) => {
12276
- listeners.emit("ws:close:sandbox", socket, request3, code, reason);
12277
- });
12405
+ emitEvent(WS_CONNECTION_SANDBOX, socket, request3);
12278
12406
  return;
12279
12407
  }
12280
- listeners.emit("ws:connection", socket, request3);
12408
+ emitEvent(WS_CONNECTION, socket, request3);
12281
12409
  socket.on("close", (code, reason) => {
12282
- listeners.emit("ws:close", socket, request3, code, reason);
12410
+ listeners.emit(WS_CLOSE, socket, request3, code, reason);
12283
12411
  });
12284
12412
  });
12285
12413
  }
@@ -14247,6 +14375,7 @@ var init_server = __esm({
14247
14375
  init_ws2();
14248
14376
  init_render();
14249
14377
  init_internal();
14378
+ init_key();
14250
14379
  WebSocketServerRenderer = class extends WebSocketRender {
14251
14380
  /** 请求实例 */
14252
14381
  request;
@@ -14274,7 +14403,8 @@ var init_server = __esm({
14274
14403
  return true;
14275
14404
  }
14276
14405
  };
14277
- listeners.on("ws:connection:puppeteer", (socket, request3) => {
14406
+ listeners.on(WS_CONNECTION_PUPPETEER, (socket, request3, call2) => {
14407
+ call2();
14278
14408
  const server2 = new WebSocketServerRenderer(socket, request3);
14279
14409
  if (!server2.connection()) return;
14280
14410
  server2.init();
@@ -16994,13 +17124,15 @@ var init_onebot = __esm({
16994
17124
  "use strict";
16995
17125
  init_esm_shims();
16996
17126
  init_internal();
16997
- init_adapter();
16998
17127
  init_register();
17128
+ init_key();
17129
+ init_adapter();
16999
17130
  init_connect();
17000
17131
  init_client2();
17001
17132
  init_types();
17002
17133
  createServer2 = async () => {
17003
- listeners.on("ws:connection:onebot", (socket, request3) => {
17134
+ listeners.on(WS_CONNECTION_ONEBOT, (socket, request3, call2) => {
17135
+ call2();
17004
17136
  new AdapterServerOneBot11(socket, request3).init();
17005
17137
  });
17006
17138
  listeners.once("online", () => {
@@ -17321,6 +17453,7 @@ var init_other2 = __esm({
17321
17453
  "use strict";
17322
17454
  init_esm_shims();
17323
17455
  init_internal();
17456
+ init_key();
17324
17457
  init_bot();
17325
17458
  Other = class extends EventEmitter4 {
17326
17459
  /** 框架名称 */
@@ -17440,15 +17573,8 @@ var init_other2 = __esm({
17440
17573
  }
17441
17574
  };
17442
17575
  events = () => {
17443
- listeners.on("ws:connection", (socket, request3) => {
17444
- const key = `ws:connection:${request3.url || "/"}`;
17445
- debug(`on ws:connection host: ${request3.headers.host} url: ${request3.url}`);
17446
- if (!other.listenerCount(key)) {
17447
- socket.close();
17448
- logger.warn(`[server][webSocket] \u8FDE\u63A5\u65AD\u5F00 \u672A\u627E\u5230\u7ED1\u5B9A\u7684\u8DEF\u7531: ${request3.url || "/"}`);
17449
- return;
17450
- }
17451
- other.emit(key, socket, request3);
17576
+ listeners.on(WS_CONNECTION, (socket, request3, call2) => {
17577
+ other.emit(WS_CONNECTION, socket, request3, call2);
17452
17578
  });
17453
17579
  listeners.on("file:change", (type, old, data) => {
17454
17580
  other.emit("file:change", type, old, data);
@@ -18547,6 +18673,14 @@ __export(index_exports, {
18547
18673
  Renderer: () => Renderer,
18548
18674
  RequestBase: () => RequestBase,
18549
18675
  SEND_MSG: () => SEND_MSG,
18676
+ WS_CLOSE: () => WS_CLOSE,
18677
+ WS_CLOSE_ONEBOT: () => WS_CLOSE_ONEBOT,
18678
+ WS_CLOSE_PUPPETEER: () => WS_CLOSE_PUPPETEER,
18679
+ WS_CLOSE_SANDBOX: () => WS_CLOSE_SANDBOX,
18680
+ WS_CONNECTION: () => WS_CONNECTION,
18681
+ WS_CONNECTION_ONEBOT: () => WS_CONNECTION_ONEBOT,
18682
+ WS_CONNECTION_PUPPETEER: () => WS_CONNECTION_PUPPETEER,
18683
+ WS_CONNECTION_SANDBOX: () => WS_CONNECTION_SANDBOX,
18550
18684
  Watch: () => Watch,
18551
18685
  Watcher: () => Watcher,
18552
18686
  YamlEditor: () => YamlEditor,
@@ -18860,6 +18994,14 @@ export {
18860
18994
  Renderer,
18861
18995
  RequestBase,
18862
18996
  SEND_MSG,
18997
+ WS_CLOSE,
18998
+ WS_CLOSE_ONEBOT,
18999
+ WS_CLOSE_PUPPETEER,
19000
+ WS_CLOSE_SANDBOX,
19001
+ WS_CONNECTION,
19002
+ WS_CONNECTION_ONEBOT,
19003
+ WS_CONNECTION_PUPPETEER,
19004
+ WS_CONNECTION_SANDBOX,
18863
19005
  Watch,
18864
19006
  Watcher,
18865
19007
  YamlEditor,
@@ -0,0 +1 @@
1
+ import{d as a}from"./index-QlhSWQs5.js";var o=a;export{o as default};
@@ -0,0 +1 @@
1
+ import{d as a}from"./index-QlhSWQs5.js";var r=a;export{r as default};
@@ -14,8 +14,8 @@
14
14
  content="viewport-fit=cover, width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"
15
15
  name="viewport" />
16
16
  <link href="/web/assets/favicon-BoqZd694.ico" rel="icon" />
17
- <script type="module" crossorigin src="/web/assets/index-Bku4ZGCh.js"></script>
18
- <link rel="stylesheet" crossorigin href="/web/assets/index-DIGplvke.css">
17
+ <script type="module" crossorigin src="/web/assets/index-QlhSWQs5.js"></script>
18
+ <link rel="stylesheet" crossorigin href="/web/assets/index-Cesl7tCG.css">
19
19
  </head>
20
20
 
21
21
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-karin",
3
- "version": "1.4.2-pr.289.c5ac700",
3
+ "version": "1.4.2",
4
4
  "description": "Lightweight, efficient, concise, and stable robot framework.",
5
5
  "keywords": [
6
6
  "node",
@@ -86,6 +86,9 @@
86
86
  "ws": "8.18.0",
87
87
  "yaml": "2.7.0"
88
88
  },
89
+ "devDependencies": {
90
+ "@types/jsonwebtoken": "^9.0.9"
91
+ },
89
92
  "engines": {
90
93
  "node": ">=18"
91
94
  },
Binary file
@@ -1 +0,0 @@
1
- import{d as a}from"./index-Bku4ZGCh.js";var o=a;export{o as default};
@@ -1 +0,0 @@
1
- import{d as a}from"./index-Bku4ZGCh.js";var r=a;export{r as default};
Binary file
Binary file
Binary file