feat: support base64 custom scripts

This commit is contained in:
CelloSerenity 2026-09-25 10:41:32 -06:00
parent ee457f2f40
commit 5d732f94b8
4 changed files with 26 additions and 5 deletions

View file

@ -262,7 +262,11 @@ try StikJIT.enableJIT(
)
```
Configure exactly one script in backend code: `.universal` or `.legacy` for the corresponding bundled script, or `.custom(URL)` for another established protocol. A custom script must be readable from the helper-extension process. For StikDebug requests, send the built-in filename for universal or legacy, or send the base64-encoded contents of the custom script. Do not expose this configuration to the user. The user-facing `forceScript` toggle only bypasses TXM detection and runs the configured script regardless.
Configure exactly one script in backend code: `.universal` or `.legacy` for the corresponding bundled script, `.custom(URL)` for a script readable from the helper-extension process, or `.customBase64(String)` for base64-encoded UTF-8 script data held elsewhere. For StikDebug requests, send the built-in filename for universal or legacy, or send the base64-encoded contents of the custom script. Do not expose this configuration to the user. The user-facing `forceScript` toggle only bypasses TXM detection and runs the configured script regardless.
```swift
let selectedScript: StikJIT.Script = .customBase64(storedScriptBase64)
```
### When the user resets the cache
@ -272,7 +276,7 @@ Provide a **Reset Developer Disk Image** action that calls:
try StikJIT.resetCachedDDI(at: paths)
```
This removes only the three cached DDI files. The next preparation downloads them again if mounting is necessary.
This removes only the five cached DDI files. The next preparation downloads them again if mounting is necessary.
## Configure the JIT methods

View file

@ -3,7 +3,8 @@ import Foundation
enum BundledScript {
static func source(for script: StikJIT.Script) throws -> String {
if case .custom(let url) = script {
switch script {
case .custom(let url):
guard url.isFileURL else {
throw StikJITError.customScript("expected a file URL")
}
@ -18,6 +19,19 @@ enum BundledScript {
} catch {
throw StikJITError.customScript("could not read \(url.path): \(error.localizedDescription)")
}
case .customBase64(let encodedSource):
guard let data = Data(base64Encoded: encodedSource) else {
throw StikJITError.customScript("the provided script data is not valid base64")
}
guard let source = String(data: data, encoding: .utf8) else {
throw StikJITError.customScript("the decoded script data is not valid UTF-8")
}
guard !source.isEmpty else {
throw StikJITError.customScript("the decoded script is empty")
}
return source
case .universal, .legacy:
break
}
let bundle = Bundle(for: BundleToken.self)

View file

@ -10,11 +10,14 @@ public enum StikJIT {
case custom(URL)
case customBase64(String)
var name: String {
switch self {
case .universal: return "universal"
case .legacy: return "legacy"
case .custom(let url): return url.lastPathComponent
case .customBase64: return "custom"
}
}
}

View file

@ -8,8 +8,8 @@ options:
settings:
base:
SWIFT_VERSION: "5.0"
MARKETING_VERSION: "1.7.0"
CURRENT_PROJECT_VERSION: "8"
MARKETING_VERSION: "1.8.0"
CURRENT_PROJECT_VERSION: "9"
CLANG_CXX_LIBRARY: "libc++"
targets: