inrupt / inrupt/solid-client-authn-js
Question: What is the best way to use this library within a Web Worker?
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 77
- Forks
- 49
- Avg merge
- 18h 20m
- Merged PRs (30d)
- 32
Description
I've been trying to use this library to fetch resources within the browser via a Web Worker, without much success.
I will describe below what I have tried up until now, and was wondering if someone could give me some pointers on what would be the best way to go forward.
My intended workflow:
- Authenticate the user within the browser itself.
- Serialize the session and send it to the Worker within a message.
- Deserialize the session within the Worker.
- Do
fetchrequests using the authenticated session.
Step 1 works without problems, but I'm unsure how to handle steps 2-3.
So far, I tried two approaches:
Serialization attempt 1
Main browser process:
// session is authenticated at this stage
const sessionInfoRaw = session.clientAuthentication.getSessionInfo(session.info.sessionId);
sendToWorker(sessionInfoRaw);
(I am aware that session.clientAuthentication is private, so this is probably not a good solution)
Worker:
const session = new Session({ sessionInfo: sessionInfoRaw });
await session.login({});
=> Throws a window is not defined error at BrowserStorage.js:5 (possibly caused by #308).
I can observe that the session already contains the correct webId value.
Serialization attempt 2
Main browser process:
// session is authenticated at this stage
const sessionInfoRaw = session.clientAuthentication.getSessionInfo(session.info.sessionId);
sendToWorker({
refreshToken: sessionInfoRaw.refreshToken,
clientId: sessionInfoRaw.clientAppId,
clientSecret: sessionInfoRaw.clientAppSecret,
oidcIssuer: sessionInfoRaw.issuer,
});
Worker:
const session = new Session();
await session.login(sessionInfoRaw);
=> Throws a window is not defined error at BrowserStorage.js:5 (possibly caused by #308).
In this case, the session contains an undefined webId value.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at BrowserStorage.js:5 and trace the Session constructor and login paths used by the worker examples. Compare both serialized-session approaches with the browser authentication flow and the Web Worker environment. Done means identifying a supported way to authenticate and issue fetch requests from a worker, or documenting the missing support.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- authentication, frontend
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100