mirror of
https://wget.la/https://github.com/Wxw-Gu/WechatExplorer
synced 2026-11-30 16:02:58 +08:00
124 lines
3.4 KiB
TypeScript
124 lines
3.4 KiB
TypeScript
/**
|
|
* Wire types for the built-in macOS native WeChat runtime
|
|
* (tm-wechat-host + libtmwechat.dylib), managed by MacWechatRuntimeManager.
|
|
*
|
|
* Binding lifecycle is "bind once per WeChat process": frida's unload/detach
|
|
* inside WeChat is unreliable, so rebind is NOT a product path. When the host
|
|
* dies while bound, the WeChat process keeps an orphaned agent and must be
|
|
* restarted before binding again — surfaced as wechatRestartRequired.
|
|
*/
|
|
|
|
export type MacWechatRuntimeLifecycle =
|
|
| 'stopped' // host not running (or never started)
|
|
| 'starting' // spawn issued, waiting for /healthz
|
|
| 'online' // host answering; WeChat NOT touched (lazy)
|
|
| 'crashed_unbound' // died while unbound — safe to auto-restart
|
|
| 'crashed_bound' // died while bound — WeChat keeps an orphan agent
|
|
|
|
export type MacWechatSendRuntimeAvailability = 'unavailable' | 'component_error' | 'available'
|
|
|
|
export interface MacWechatSendRuntimeAvailabilityResult {
|
|
state: MacWechatSendRuntimeAvailability
|
|
message: string
|
|
}
|
|
|
|
export interface MacWechatResidualProcess {
|
|
pid: number
|
|
name: string
|
|
targets: Array<'wechat' | 'host' | 'port_4290'>
|
|
confirmationToken: string
|
|
}
|
|
|
|
export interface MacWechatResidualCleanupResult {
|
|
stopped: MacWechatResidualProcess[]
|
|
remaining: MacWechatResidualProcess[]
|
|
runtimeStopped: boolean
|
|
}
|
|
|
|
export type MacWechatHostRuntimeState =
|
|
| 'not_initialized'
|
|
| 'wechat_not_running'
|
|
| 'not_logged_in'
|
|
| 'unsupported_version'
|
|
| 'initializing'
|
|
| 'ready'
|
|
| 'error'
|
|
| 'unknown'
|
|
|
|
export type MacWechatBindingState =
|
|
| 'unbound'
|
|
| 'binding'
|
|
| 'bound'
|
|
| 'ready'
|
|
| 'failed'
|
|
| 'stale'
|
|
| 'unknown'
|
|
|
|
export interface MacWechatRuntimeManifest {
|
|
runtime: 'tm-wechat-native'
|
|
version: string
|
|
platform: 'darwin-arm64'
|
|
architecture: 'arm64'
|
|
protocolVersion: number
|
|
buildCommit: string
|
|
tmSendSourceSha256: string
|
|
addressProfileSha256: string
|
|
supportedWechatVersions: string[]
|
|
capabilities: Array<'text' | 'image' | 'voice'>
|
|
capabilitiesByVersion?: Record<
|
|
string,
|
|
{
|
|
text?: 'verified' | 'addresses-only' | 'unsupported'
|
|
image?: 'verified' | 'addresses-only' | 'unsupported'
|
|
voice?: 'verified' | 'addresses-only' | 'unsupported'
|
|
downloadImage?: 'verified' | 'addresses-only' | 'unsupported'
|
|
textMechanism?: string
|
|
}
|
|
>
|
|
}
|
|
|
|
export interface MacWechatBindingStatus {
|
|
runtime: boolean
|
|
hostPid?: number
|
|
runtimeState: MacWechatHostRuntimeState
|
|
runtimeVersion?: string
|
|
embeddedAgentSha256?: string
|
|
embeddedAddressProfileSha256?: string
|
|
abiVersion?: number
|
|
dylibPath?: string
|
|
wechatRunning: boolean
|
|
wechatPid: number
|
|
wechatVersion?: string
|
|
supported: boolean
|
|
bindingState: MacWechatBindingState
|
|
bound: boolean
|
|
boundWechatPid: number
|
|
sessionAttached: boolean
|
|
scriptLoaded: boolean
|
|
sendContextReady: boolean
|
|
canSendText?: boolean
|
|
canSendImage?: boolean
|
|
canSendVoice?: boolean
|
|
attachCount: number
|
|
lastAttachAt?: string
|
|
lastDetachReason?: string
|
|
}
|
|
|
|
export interface MacWechatRuntimeSnapshot {
|
|
lifecycle: MacWechatRuntimeLifecycle
|
|
/** True when the last host death happened while bound: WeChat must be restarted. */
|
|
wechatRestartRequired: boolean
|
|
endpoint: string
|
|
port: number
|
|
runtimeDir?: string
|
|
error?: string
|
|
binding?: MacWechatBindingStatus
|
|
}
|
|
|
|
export interface MacWechatBindResult {
|
|
ok: boolean
|
|
attached: boolean
|
|
state?: 'wechat_restart_required' | 'runtime_offline' | 'host_error' | 'bad_response'
|
|
message: string
|
|
}
|