fix(uds-auth): isolate trusted Host calls from browser identity
Some checks are pending
ci / test (push) Waiting to run
ci / test-postgresql (push) Waiting to run

This commit is contained in:
oliver 2026-10-11 17:03:40 +08:00
parent 3ba4461566
commit fa4d5d6d97
7 changed files with 83 additions and 3 deletions

View file

@ -33,6 +33,17 @@ export function runWithUserContext(userContext, fn) {
return userContextStorage.run(userContext, fn)
}
/**
* Run a trusted in-process Host operation without a browser identity.
* Only Host plugins receive this callback API; it is not a remote endpoint.
* @param {Function} fn
* @returns {*} The operation's result, preserving synchronous and async calls.
*/
export function runAsHost(fn) {
if (typeof fn !== 'function') throw new TypeError('Host operation must be a function')
return userContextStorage.run(undefined, fn)
}
/**
* Persist ALS for the rest of this async execution chain.
* Needed for Gateway Remote stream mux: message handlers are sync but start