dsh-im-ops/plugin-src/host/harness-host-context.mjs
oliver bf73b0c0af
Some checks are pending
CI / Test, build, and verify package (push) Waiting to run
fix: improve WhatsApp settings and isolate IM host authentication
2026-10-11 17:03:38 +08:00

10 lines
555 B
JavaScript

/** Run same-process IM operations without inheriting a browser's UDS identity. */
export function runHarnessHostOperation(ctx, operation) {
// Cordis property access requires inject even for an optional service.
// ctx.get() supports dynamic lookup without making UDS a startup dependency.
const auth = typeof ctx?.get === 'function' ? ctx.get('udsAuth') : ctx?.udsAuth;
// Resolve on every call: auth can become ready or reload after IM starts.
return typeof auth?.runAsHost === 'function'
? auth.runAsHost(operation)
: operation();
}