refactor(packages): rename @snowluma/bridge → @snowluma/protocol
The package previously named "bridge" houses the protocol-byte layer (OIDB cmds, msg-push decoders, highway uploaders, element-builder, event bus). The name "bridge" suggested transport/lifecycle, which it isn't — that role lives in core/hook and core/bridge/manager. Rename to match what's actually inside. This is a pure rename: zero logic changes, all 73 import sites updated mechanically and TS-verified. core/onebot dependencies key updated. ESLint override path adjusted for the moved oidb-services directory. Rename detection threshold: git log --find-renames=20% recommended when following history across this commit — content-replacement (@snowluma/bridge → @snowluma/protocol) dropped per-file similarity below git's default 50% on import-heavy files.
This commit is contained in:
238 files changed
+247
-284
No files matched your search
@@ -0,0 +1,43 @@
|
||||
// 0x102A_1 — fetch a fresh `clientKey` (consumed by the ptlogin2 jump
|
||||
// URL flow that swaps it for cookie-jar entries on qq.com subdomains).
|
||||
//
|
||||
// The server's `keyIndex` field is occasionally empty in the wild;
|
||||
// every NapCat-derived implementation falls back to the literal "19"
|
||||
// in that case — origin unknown but the value works.
|
||||
|
||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
||||
import type { OidbClientKeyReq, OidbClientKeyResp } from '@snowluma/proto-defs/oidb-actions/base';
|
||||
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
||||
|
||||
export interface ClientKeyInfo {
|
||||
clientKey: string;
|
||||
keyIndex: string;
|
||||
expireTime: string;
|
||||
}
|
||||
|
||||
export namespace ForceFetchClientKey {
|
||||
export const command = 0x102A;
|
||||
export const subCommand = 1;
|
||||
|
||||
export interface Params {}
|
||||
|
||||
export type Deps = OidbSender;
|
||||
|
||||
export const serialize = (_ctx: Deps, _: Params): OidbClientKeyReq => ({});
|
||||
|
||||
export const deserialize = (_ctx: Deps, body: OidbClientKeyResp): ClientKeyInfo => ({
|
||||
clientKey: body.clientKey || '',
|
||||
keyIndex: String(body.keyIndex || '19'),
|
||||
expireTime: String(body.expireTime || '1800'),
|
||||
});
|
||||
|
||||
export const encode = (env: OidbBase<OidbClientKeyReq>): Uint8Array =>
|
||||
protobuf_encode<OidbBase<OidbClientKeyReq>>(env);
|
||||
|
||||
export const decode = (bytes: Uint8Array): OidbBase<OidbClientKeyResp> =>
|
||||
protobuf_decode<OidbBase<OidbClientKeyResp>>(bytes);
|
||||
|
||||
export const invoke = (deps: Deps): Promise<ClientKeyInfo> =>
|
||||
invokeOidb(deps, ForceFetchClientKey, {});
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
// 0x102A_0 — request p_skey cookies for a list of qq.com subdomains.
|
||||
// Used as the fallback when ptlogin2 jump doesn't emit a p_skey on
|
||||
// the cookie set (intermittent server behaviour).
|
||||
|
||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
||||
import type { OidbGetPskeyReq, OidbGetPskeyResp } from '@snowluma/proto-defs/oidb-actions/base';
|
||||
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
||||
|
||||
export namespace GetPskey {
|
||||
export const command = 0x102A;
|
||||
export const subCommand = 0;
|
||||
|
||||
export interface Params {
|
||||
domainList: string[];
|
||||
}
|
||||
|
||||
export interface Result {
|
||||
domainPskeyMap: Map<string, string>;
|
||||
}
|
||||
|
||||
export type Deps = OidbSender;
|
||||
|
||||
export const serialize = (_ctx: Deps, p: Params): OidbGetPskeyReq => ({
|
||||
domainList: p.domainList,
|
||||
});
|
||||
|
||||
export const deserialize = (_ctx: Deps, body: OidbGetPskeyResp): Result => {
|
||||
const domainPskeyMap = new Map<string, string>();
|
||||
if (body.pskeyItems && Array.isArray(body.pskeyItems)) {
|
||||
for (const item of body.pskeyItems) {
|
||||
if (item.domain && item.pskey) {
|
||||
domainPskeyMap.set(item.domain, item.pskey);
|
||||
}
|
||||
}
|
||||
}
|
||||
return { domainPskeyMap };
|
||||
};
|
||||
|
||||
export const encode = (env: OidbBase<OidbGetPskeyReq>): Uint8Array =>
|
||||
protobuf_encode<OidbBase<OidbGetPskeyReq>>(env);
|
||||
|
||||
export const decode = (bytes: Uint8Array): OidbBase<OidbGetPskeyResp> =>
|
||||
protobuf_decode<OidbBase<OidbGetPskeyResp>>(bytes);
|
||||
|
||||
export const invoke = (deps: Deps, params: Params): Promise<Result> =>
|
||||
invokeOidb(deps, GetPskey, params);
|
||||
}
|
||||
Reference in new issue
Block a user