mirror of
https://github.com/moonD4rk/HackBrowserData.git
synced 2026-07-04 21:37:47 +02:00
refactor(browser): publicize key-injection capability api (#597)
Promote keyRetrieversSetter to public KeyManager and lift keychainPasswordSetter from browser_darwin.go into browser.go as KeychainPasswordReceiver. Engines already implement these methods; only type-assertion sites switch to the public interface names.
This commit is contained in:
+7
-4
@@ -111,13 +111,16 @@ func pickFromConfigs(configs []types.BrowserConfig, opts PickOptions) ([]Browser
|
|||||||
return browsers, nil
|
return browsers, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// keyRetrieversSetter is an optional capability interface. Chromium variants implement it to
|
// KeyManager is implemented by engines that accept externally-provided master-key retrievers (Chromium family only).
|
||||||
// receive the per-tier master-key retrievers (V10 / V11 / V20) as a single Retrievers struct;
|
type KeyManager interface {
|
||||||
// Firefox and Safari do not.
|
|
||||||
type keyRetrieversSetter interface {
|
|
||||||
SetKeyRetrievers(keyretriever.Retrievers)
|
SetKeyRetrievers(keyretriever.Retrievers)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// KeychainPasswordReceiver is implemented by engines that need the macOS login password (Safari only).
|
||||||
|
type KeychainPasswordReceiver interface {
|
||||||
|
SetKeychainPassword(string)
|
||||||
|
}
|
||||||
|
|
||||||
// resolveGlobs expands glob patterns in browser configs' UserDataDir.
|
// resolveGlobs expands glob patterns in browser configs' UserDataDir.
|
||||||
// This supports MSIX/UWP browsers on Windows whose package directories
|
// This supports MSIX/UWP browsers on Windows whose package directories
|
||||||
// contain a dynamic publisher hash suffix (e.g., "TheBrowserCompany.Arc_*").
|
// contain a dynamic publisher hash suffix (e.g., "TheBrowserCompany.Arc_*").
|
||||||
|
|||||||
@@ -155,20 +155,8 @@ func resolveKeychainPassword(flagPassword string) string {
|
|||||||
return password
|
return password
|
||||||
}
|
}
|
||||||
|
|
||||||
// keychainPasswordSetter is an optional capability interface satisfied by
|
// newPlatformInjector lazily wires retrievers (and the macOS keychain password) into each Browser;
|
||||||
// Safari, which reads InternetPassword records directly from the login keychain.
|
// `-b firefox` never triggers a keychain prompt because lazy resolution skips browsers that need neither.
|
||||||
type keychainPasswordSetter interface {
|
|
||||||
SetKeychainPassword(string)
|
|
||||||
}
|
|
||||||
|
|
||||||
// newPlatformInjector returns a closure that injects the Chromium master-key
|
|
||||||
// retriever and the Safari Keychain password into each Browser.
|
|
||||||
//
|
|
||||||
// Resolution is lazy: the keychain password prompt and retriever construction
|
|
||||||
// are deferred until the first Browser that actually needs them passes through
|
|
||||||
// the closure. Browsers that satisfy neither setter interface (e.g. Firefox)
|
|
||||||
// short-circuit without ever touching the keychain, so `-b firefox` on macOS
|
|
||||||
// no longer triggers a password prompt.
|
|
||||||
func newPlatformInjector(opts PickOptions) func(Browser) {
|
func newPlatformInjector(opts PickOptions) func(Browser) {
|
||||||
var (
|
var (
|
||||||
password string
|
password string
|
||||||
@@ -176,8 +164,8 @@ func newPlatformInjector(opts PickOptions) func(Browser) {
|
|||||||
resolved bool
|
resolved bool
|
||||||
)
|
)
|
||||||
return func(b Browser) {
|
return func(b Browser) {
|
||||||
rs, needsRetrievers := b.(keyRetrieversSetter)
|
km, needsRetrievers := b.(KeyManager)
|
||||||
kps, needsKeychainPassword := b.(keychainPasswordSetter)
|
kps, needsKeychainPassword := b.(KeychainPasswordReceiver)
|
||||||
if !needsRetrievers && !needsKeychainPassword {
|
if !needsRetrievers && !needsKeychainPassword {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -187,7 +175,7 @@ func newPlatformInjector(opts PickOptions) func(Browser) {
|
|||||||
resolved = true
|
resolved = true
|
||||||
}
|
}
|
||||||
if needsRetrievers {
|
if needsRetrievers {
|
||||||
rs.SetKeyRetrievers(retrievers)
|
km.SetKeyRetrievers(retrievers)
|
||||||
}
|
}
|
||||||
if needsKeychainPassword {
|
if needsKeychainPassword {
|
||||||
kps.SetKeychainPassword(password)
|
kps.SetKeychainPassword(password)
|
||||||
|
|||||||
@@ -75,8 +75,8 @@ func platformBrowsers() []types.BrowserConfig {
|
|||||||
func newPlatformInjector(_ PickOptions) func(Browser) {
|
func newPlatformInjector(_ PickOptions) func(Browser) {
|
||||||
retrievers := keyretriever.DefaultRetrievers()
|
retrievers := keyretriever.DefaultRetrievers()
|
||||||
return func(b Browser) {
|
return func(b Browser) {
|
||||||
if s, ok := b.(keyRetrieversSetter); ok {
|
if km, ok := b.(KeyManager); ok {
|
||||||
s.SetKeyRetrievers(retrievers)
|
km.SetKeyRetrievers(retrievers)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -132,8 +132,8 @@ func platformBrowsers() []types.BrowserConfig {
|
|||||||
func newPlatformInjector(_ PickOptions) func(Browser) {
|
func newPlatformInjector(_ PickOptions) func(Browser) {
|
||||||
retrievers := keyretriever.DefaultRetrievers()
|
retrievers := keyretriever.DefaultRetrievers()
|
||||||
return func(b Browser) {
|
return func(b Browser) {
|
||||||
if s, ok := b.(keyRetrieversSetter); ok {
|
if km, ok := b.(KeyManager); ok {
|
||||||
s.SetKeyRetrievers(retrievers)
|
km.SetKeyRetrievers(retrievers)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user