mirror of
https://github.com/StikDebug/StikDebug.git
synced 2026-10-15 20:10:30 +00:00
* Heartbeat rework * remove some debug loggings * stik mini tool poc * Saperate JITEnableContext into extensions and put each feature into their own files. Fix local pairing file is removed after switched to external device by directly loading the remote device's pairing file in place. * custom origin & xmlhttprequest * Fix some memory leak * allow background script access idevice (codes are from the old JSSupport branch) Tests are not carried out but most of the js api should work. Do we need to obfuscate some functions' name? * Fix JITEnableContext singleton initializer race condition * Fix instprox callback --------- Co-authored-by: Stephen B <158498287+StephenDev0@users.noreply.github.com>
515 lines
13 KiB
JavaScript
515 lines
13 KiB
JavaScript
//
|
|
// idevice.js
|
|
// StikJIT
|
|
//
|
|
// Created by s s on 2025/4/24.
|
|
//
|
|
|
|
async function core_device_proxy_connect() {
|
|
return await __postIdeviceMessage({
|
|
"command": "core_device_proxy_connect"
|
|
});
|
|
}
|
|
|
|
async function core_device_proxy_get_server_rsd_port(core_device_handle) {
|
|
return await __postIdeviceMessage({
|
|
"command": "core_device_proxy_get_server_rsd_port",
|
|
"handle": core_device_handle
|
|
});
|
|
}
|
|
|
|
async function core_device_proxy_create_tcp_adapter(core_device_handle) {
|
|
return await __postIdeviceMessage({
|
|
"command": "core_device_proxy_create_tcp_adapter",
|
|
"handle": core_device_handle
|
|
});
|
|
}
|
|
|
|
async function adapter_connect(adapter, port) {
|
|
return await __postIdeviceMessage({
|
|
"command": "adapter_connect",
|
|
"adapter": adapter,
|
|
"port": port
|
|
});
|
|
}
|
|
|
|
async function rsd_handshake_new(socket) {
|
|
return await __postIdeviceMessage({
|
|
"command": "rsd_handshake_new",
|
|
"socket": socket
|
|
});
|
|
}
|
|
|
|
async function rsd_get_protocol_version(handle) {
|
|
return await __postIdeviceMessage({
|
|
"command": "rsd_get_protocol_version",
|
|
"handle": handle
|
|
});
|
|
}
|
|
|
|
async function rsd_get_uuid(handle) {
|
|
return await __postIdeviceMessage({
|
|
"command": "rsd_get_uuid",
|
|
"handle": handle
|
|
});
|
|
}
|
|
|
|
async function rsd_get_services(handle) {
|
|
return await __postIdeviceMessage({
|
|
"command": "rsd_get_services",
|
|
"handle": handle
|
|
});
|
|
}
|
|
|
|
async function rsd_service_available(handle, service_name) {
|
|
return await __postIdeviceMessage({
|
|
"command": "rsd_service_available",
|
|
"handle": handle,
|
|
"service_name": service_name
|
|
});
|
|
}
|
|
|
|
async function rsd_get_service_info(handle, service_name) {
|
|
return await __postIdeviceMessage({
|
|
"command": "rsd_get_service_info",
|
|
"handle": handle,
|
|
"service_name": service_name
|
|
});
|
|
}
|
|
|
|
async function remote_server_connect_rsd(adapter, handshake) {
|
|
return await __postIdeviceMessage({
|
|
"command": "remote_server_connect_rsd",
|
|
"adapter": adapter,
|
|
"handshake": handshake
|
|
});
|
|
}
|
|
|
|
async function process_control_new(server) {
|
|
return await __postIdeviceMessage({
|
|
"command": "process_control_new",
|
|
"server": server
|
|
});
|
|
}
|
|
|
|
async function process_control_launch_app(handle, bundle_id, env_vars, arguments, start_suspended, kill_existing) {
|
|
return await __postIdeviceMessage({
|
|
"command": "process_control_launch_app",
|
|
"handle": handle,
|
|
"bundle_id": bundle_id,
|
|
"env_vars": env_vars,
|
|
"arguments": arguments,
|
|
"start_suspended": start_suspended,
|
|
"kill_existing": kill_existing
|
|
});
|
|
}
|
|
|
|
async function process_control_disable_memory_limit(handle, pid) {
|
|
return await __postIdeviceMessage({
|
|
"command": "process_control_disable_memory_limit",
|
|
"handle": handle,
|
|
"pid": pid
|
|
});
|
|
}
|
|
|
|
async function process_control_kill_app(handle, pid) {
|
|
return await __postIdeviceMessage({
|
|
"command": "process_control_kill_app",
|
|
"handle": handle,
|
|
"pid": pid
|
|
});
|
|
}
|
|
|
|
async function debug_proxy_connect_rsd(adapter, handshake) {
|
|
return await __postIdeviceMessage({
|
|
"command": "debug_proxy_connect_rsd",
|
|
"adapter": adapter,
|
|
"handshake": handshake
|
|
});
|
|
}
|
|
|
|
async function debug_proxy_send_command(handle, command) {
|
|
return await __postIdeviceMessage({
|
|
"command": "debug_proxy_send_command",
|
|
"handle": handle,
|
|
"debug_command": command
|
|
});
|
|
}
|
|
|
|
async function springboard_services_connect() {
|
|
return await __postIdeviceMessage({
|
|
"command": "springboard_services_connect"
|
|
});
|
|
}
|
|
|
|
async function springboard_services_get_icon(client, bundle_id) {
|
|
return await __postIdeviceMessage({
|
|
"command": "springboard_services_get_icon",
|
|
"client": client,
|
|
"bundle_id": bundle_id
|
|
});
|
|
}
|
|
|
|
async function nsdata_read(handle) {
|
|
return await __postIdeviceMessage({
|
|
"command": "nsdata_read",
|
|
"handle": handle,
|
|
});
|
|
}
|
|
|
|
async function nsdata_read_range(handle, begin, end) {
|
|
return await __postIdeviceMessage({
|
|
"command": "nsdata_read_range",
|
|
"handle": handle,
|
|
"begin": begin,
|
|
"end": end
|
|
});
|
|
}
|
|
|
|
async function afc_client_connect() {
|
|
return await __postIdeviceMessage({
|
|
"command": "afc_client_connect"
|
|
});
|
|
}
|
|
|
|
async function afc_list_directory(handle, path) {
|
|
return await __postIdeviceMessage({
|
|
"command": "afc_list_directory",
|
|
"handle": handle,
|
|
"path": path
|
|
});
|
|
}
|
|
|
|
async function afc_make_directory(handle, path) {
|
|
return await __postIdeviceMessage({
|
|
"command": "afc_make_directory",
|
|
"handle": handle,
|
|
"path": path
|
|
});
|
|
}
|
|
|
|
async function afc_remove_path(handle, path) {
|
|
return await __postIdeviceMessage({
|
|
"command": "afc_remove_path",
|
|
"handle": handle,
|
|
"path": path
|
|
});
|
|
}
|
|
|
|
async function afc_remove_path_and_contents(handle, path) {
|
|
return await __postIdeviceMessage({
|
|
"command": "afc_remove_path_and_contents",
|
|
"handle": handle,
|
|
"path": path
|
|
});
|
|
}
|
|
|
|
async function afc_rename_path(handle, source, target) {
|
|
return await __postIdeviceMessage({
|
|
"command": "afc_rename_path",
|
|
"handle": handle,
|
|
"source": source,
|
|
"target": target
|
|
});
|
|
}
|
|
|
|
async function afc_get_file_info(handle, path) {
|
|
return await __postIdeviceMessage({
|
|
"command": "afc_get_file_info",
|
|
"handle": handle,
|
|
"path": path
|
|
});
|
|
}
|
|
|
|
async function afc_get_device_info(handle) {
|
|
return await __postIdeviceMessage({
|
|
"command": "afc_get_device_info",
|
|
"handle": handle,
|
|
});
|
|
}
|
|
|
|
async function afc_file_open(handle, path, mode) {
|
|
return await __postIdeviceMessage({
|
|
"command": "afc_file_open",
|
|
"handle": handle,
|
|
"path": path,
|
|
"mode": mode
|
|
});
|
|
}
|
|
|
|
async function afc_file_close(handle) {
|
|
return await __postIdeviceMessage({
|
|
"command": "afc_file_close",
|
|
"handle": handle
|
|
});
|
|
}
|
|
|
|
async function afc_file_read(handle) {
|
|
return await __postIdeviceMessage({
|
|
"command": "afc_file_read",
|
|
"handle": handle
|
|
});
|
|
}
|
|
|
|
async function afc_file_write(handle, data_handle) {
|
|
return await __postIdeviceMessage({
|
|
"command": "afc_file_write",
|
|
"handle": handle,
|
|
"data_handle": data_handle
|
|
});
|
|
}
|
|
|
|
// for installation_proxy_callback
|
|
|
|
var handle_installation_proxy_callback_dict = {"max": 0}
|
|
function handle_installation_proxy_js_callback(id, progress) {
|
|
let func = handle_installation_proxy_callback_dict[id];
|
|
if(func) {
|
|
func(progress)
|
|
}
|
|
}
|
|
|
|
function installation_proxy_js_callback_register(callback) {
|
|
let cur = handle_installation_proxy_callback_dict['max']
|
|
handle_installation_proxy_callback_dict['max']++
|
|
handle_installation_proxy_callback_dict[cur] = callback
|
|
return cur;
|
|
}
|
|
|
|
function installation_proxy_js_callback_unregister(id) {
|
|
delete handle_installation_proxy_callback_dict[id]
|
|
}
|
|
|
|
async function installation_proxy_connect() {
|
|
return await __postIdeviceMessage({
|
|
"command": "installation_proxy_connect"
|
|
});
|
|
}
|
|
|
|
async function installation_proxy_get_apps(client, applicationType, bundleIdentifiers) {
|
|
return await __postIdeviceMessage({
|
|
"command": "installation_proxy_get_apps",
|
|
"client": client,
|
|
"application_type": applicationType,
|
|
"bundle_identifiers": bundleIdentifiers
|
|
});
|
|
}
|
|
|
|
async function installation_proxy_browse(client, options) {
|
|
return await __postIdeviceMessage({
|
|
"command": "installation_proxy_browse",
|
|
"client": client,
|
|
"options": options
|
|
});
|
|
}
|
|
|
|
async function installation_proxy_install(client, package_path, options, callback) {
|
|
if(callback) {
|
|
let id = installation_proxy_js_callback_register(callback)
|
|
let ans = await __postIdeviceMessage({
|
|
"command": "installation_proxy_install",
|
|
"client": client,
|
|
"package_path": package_path,
|
|
"options": options,
|
|
"callback_id": id
|
|
});
|
|
installation_proxy_js_callback_unregister(id)
|
|
return ans;
|
|
} else {
|
|
return await __postIdeviceMessage({
|
|
"command": "installation_proxy_install",
|
|
"client": client,
|
|
"package_path": package_path,
|
|
"options": options,
|
|
"callback_id": -1
|
|
});
|
|
}
|
|
}
|
|
|
|
async function installation_proxy_upgrade(client, package_path, options, callback) {
|
|
if(callback) {
|
|
let id = installation_proxy_js_callback_register(callback)
|
|
let ans = await __postIdeviceMessage({
|
|
"command": "installation_proxy_upgrade",
|
|
"client": client,
|
|
"package_path": package_path,
|
|
"options": options,
|
|
"callback_id": id
|
|
});
|
|
installation_proxy_js_callback_unregister(id)
|
|
return ans;
|
|
} else {
|
|
return await __postIdeviceMessage({
|
|
"command": "installation_proxy_install",
|
|
"client": client,
|
|
"package_path": package_path,
|
|
"options": options,
|
|
"callback_id": -1
|
|
});
|
|
}
|
|
}
|
|
|
|
async function installation_proxy_uninstall(client, bundle_id, options, callback) {
|
|
if(callback) {
|
|
let id = installation_proxy_js_callback_register(callback)
|
|
let ans = await __postIdeviceMessage({
|
|
"command": "installation_proxy_uninstall",
|
|
"client": client,
|
|
"bundle_id": bundle_id,
|
|
"options": options,
|
|
"callback_id": id
|
|
});
|
|
installation_proxy_js_callback_unregister(id)
|
|
return ans;
|
|
} else {
|
|
return await __postIdeviceMessage({
|
|
"command": "installation_proxy_install",
|
|
"client": client,
|
|
"bundle_id": bundle_id,
|
|
"options": options,
|
|
"callback_id": -1
|
|
});
|
|
}
|
|
}
|
|
|
|
async function amfi_connect() {
|
|
return await __postIdeviceMessage({
|
|
"command": "amfi_connect"
|
|
});
|
|
}
|
|
|
|
async function amfi_reveal_developer_mode_option_in_ui(handle) {
|
|
return await __postIdeviceMessage({
|
|
"command": "amfi_reveal_developer_mode_option_in_ui",
|
|
"handle": handle
|
|
});
|
|
}
|
|
|
|
async function amfi_enable_developer_mode(handle) {
|
|
return await __postIdeviceMessage({
|
|
"command": "amfi_enable_developer_mode",
|
|
"handle": handle
|
|
});
|
|
}
|
|
|
|
async function amfi_accept_developer_mode(handle) {
|
|
return await __postIdeviceMessage({
|
|
"command": "amfi_accept_developer_mode",
|
|
"handle": handle
|
|
});
|
|
}
|
|
|
|
async function misagent_connect() {
|
|
return await __postIdeviceMessage({
|
|
"command": "misagent_connect"
|
|
});
|
|
}
|
|
|
|
async function misagent_install(handle, data_handle) {
|
|
return await __postIdeviceMessage({
|
|
"command": "misagent_install",
|
|
"handle": handle,
|
|
"data_handle": data_handle
|
|
});
|
|
}
|
|
|
|
async function misagent_remove(handle, profile_id) {
|
|
return await __postIdeviceMessage({
|
|
"command": "misagent_remove",
|
|
"handle": handle,
|
|
"profile_id": profile_id
|
|
});
|
|
}
|
|
|
|
async function misagent_copy_all(handle) {
|
|
return await __postIdeviceMessage({
|
|
"command": "misagent_copy_all",
|
|
"handle": handle,
|
|
});
|
|
}
|
|
|
|
async function location_simulation_new(server) {
|
|
return await __postIdeviceMessage({
|
|
"command": "location_simulation_new",
|
|
"server": server
|
|
});
|
|
}
|
|
|
|
async function location_simulation_clear(handle) {
|
|
return await __postIdeviceMessage({
|
|
"command": "location_simulation_clear",
|
|
"handle": handle
|
|
});
|
|
}
|
|
|
|
async function location_simulation_set(handle, latitude, longitude) {
|
|
return await __postIdeviceMessage({
|
|
"command": "location_simulation_set",
|
|
"handle": handle,
|
|
"latitude": latitude,
|
|
"longitude": longitude,
|
|
});
|
|
}
|
|
|
|
// data related, not idevice
|
|
|
|
async function nsdata_get_size(handle) {
|
|
return await __postIdeviceMessage({
|
|
"command": "nsdata_get_size",
|
|
"handle": handle,
|
|
});
|
|
}
|
|
|
|
async function nsdata_free(handle) {
|
|
return await __postIdeviceMessage({
|
|
"command": "nsdata_free",
|
|
"handle": handle,
|
|
});
|
|
}
|
|
|
|
async function nsdata_create(base64Data) {
|
|
return await __postIdeviceMessage({
|
|
"command": "nsdata_create",
|
|
"base64Data": base64Data,
|
|
});
|
|
}
|
|
|
|
async function local_file_open(path, mode) {
|
|
return await __postIdeviceMessage({
|
|
"command": "local_file_open",
|
|
"path": path,
|
|
"mode": mode
|
|
});
|
|
}
|
|
|
|
async function local_file_close(file) {
|
|
return await __postIdeviceMessage({
|
|
"command": "local_file_close",
|
|
"file": file,
|
|
});
|
|
}
|
|
|
|
async function local_file_get_size(file) {
|
|
return await __postIdeviceMessage({
|
|
"command": "local_file_get_size",
|
|
"file": file,
|
|
});
|
|
}
|
|
|
|
async function local_file_read_chunk(file, offset, length) {
|
|
return await __postIdeviceMessage({
|
|
"command": "local_file_read_chunk",
|
|
"file": file,
|
|
"offset": offset,
|
|
"length": length
|
|
});
|
|
}
|
|
|
|
async function local_file_write_chunk(file, data, offset) {
|
|
return await __postIdeviceMessage({
|
|
"command": "local_file_write_chunk",
|
|
"file": file,
|
|
"offset": offset,
|
|
"data": data
|
|
});
|
|
}
|