-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
The new refresh worker does not work if the lib is used via CDN, since the worker has to be registered on the same origin. (see also this comment)
Minimal HTML to reproduce the issue:
<script type="module">
import {Session} from "https://unpkg.com/@uvdsl/solid-oidc-client-browser@0.2.0/dist/esm/web/index.min.js"
new Session()
</script>When served and opened in a browser this logs something like:
Uncaught SecurityError: Failed to construct 'SharedWorker': Script at 'https://unpkg.com/@uvdsl/solid-oidc-client-browser@0.2.0/dist/esm/web/RefreshWorker.js' cannot be accessed from origin 'http://localhost:63342'.
at new Me (Session.ts:36:23)
at index.html?_ijt=9864dcv3jn9ceshd0aa7oktlqi&_ij_reload=RELOAD_ON_SAVE:6:7
Possible solution
- Provide a
RefreshWorker.json the same origin as the app, that loads the actual worker from CDN:
// RefreshWorker.js
import "https://unpkg.com/@uvdsl/solid-oidc-client-browser@0.2.1/dist/esm/web/RefreshWorker.js"
- Then intantiate the SharedWorker in the app and pass it to the Session
const refreshWorker = new SharedWorker('./RefreshWorker.js', { type: 'module' });
new Session(refreshWorker)
For this to work the library needs to make it possible to pass the worker in the constructor as an alternative to instantiate it internally.
Metadata
Metadata
Assignees
Labels
No labels