wintercg / proposal-common-minimum-api

https://common-min-api.proposal.wintercg.org/
Other
216 stars 15 forks source link

Dual opt-in programmatically setting Client and WindowClient of ServiceWorker #36

Closed guest271314 closed 1 year ago

guest271314 commented 1 year ago

Explainer https://github.com/guest271314/requestClient

ljharb commented 1 year ago

Are ServiceWorkers even a reasonable thing for WinterCG to support? I don't believe they're supported now.

guest271314 commented 1 year ago

Sure.

Just look at how Deno emulates the ServiceWorker onfetch handler https://github.com/guest271314/native-messaging-espeak-ng/blob/deno-server/deno_server.js

requestEvent.respondWith(
      new Response(body, {
        headers: {
          'Content-Type': requestEvent.request.method === 'POST' ? 'audio/wav' : 'application/octet-stream',
          'Cross-Origin-Opener-Policy': 'unsafe-none',
          'Cross-Origin-Embedder-Policy': 'unsafe-none',
          'Access-Control-Allow-Origin': '*',
          'Content-Security-Policy': 'treat-as-public-address',
          //'Access-Control-Request-Private-Network': 'true',
          'Access-Control-Allow-Private-Network': 'true',
          'Access-Control-Allow-Headers':
            'Access-Control-Request-Private-Network',
          'Access-Control-Allow-Methods': 'OPTIONS,POST,GET,HEAD',
        },
      })
    );

The concept is to solve https://github.com/GoogleChrome/chrome-extensions-samples/issues/766.

Whereas I created several workarounds which are close to the requirement, yet each lacks completely fulfilling the requirement.

We should not have to create an HTML document or open a new Window just to transfer data from a ServiceWorker to an arbitrary Web page. We should be able to use Transferable objects and Transferable Streams.

jasnell commented 1 year ago

This is not currently in scope for wintercg.