You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
WebWorker is the only technology that can offer XSS safe storage of secrets and offer some token data information to the client.
We should investigate/test if it's possible to migrate this library to use that.
Basic Example
constworker=newWorker("worker.js");letuserData;letuserId='5f8d7bd2418fef006838d504'// send data, e.g. userID to a workeruserData=worker.postMessage(userId)-----------------------------------------// object in which the secret will be storedconstsecretCache={}consttokenUrl='https://backend.example.com/token/'onmessage=async(userId)=>{if(!secretCache.userId)// fetch a token for the usertry{response=awaitfetch(tokenUrl+userId);}catch(error){return;}json=awaitresponse.json();// store the secret token in the secretCache with the userId as a keysecretCache.userId=json.token// retrieve data based on tokenconstuserUrl='https://backend.example.com/user/'constdata={userId: userId,token: secretCache.userId}try{letresponse=awaitfetch(userUrl,{method: 'POST',headers: {'Content-Type': 'application/json'},body: JSON.stringify(data)});}catch(error){return;}json=awaitresponse.json();// return the retrieved data to the main applicationpostmessage(data)}
Drawbacks
Possible that some current features will not be supported.
Unresolved questions
No response
Implementation PR
No response
Reference Issues
No response
The text was updated successfully, but these errors were encountered:
You referred to this page as a source for the claim that "WebWorker is the only technology that can offer XSS safe storage of secrets". While that might be true, I don't think it can work for our use-case, since the secret is only safe as long as it never escapes the WebWorker. In the case of this library, we want/need to expose the secret in some way to the developer (in React), and as such it is actually no longer safe. If the developer can reach it (which they must to use it in their application), then an attacker may also reach it.
So I think the article describes a process of moving all API-interfacing logic into the WebWorker environment, which I'm sure is a very efficient and super-secure solution, but I don't think we can assume that all library users will be doing that.
And it would for sure be the most breaking'est change we'll ever have if we transition to this 😅 .
Agree, think you're right. This is my feeling as well that WebWorker is not a good fit for what we are trying to do.
Still, would like to get more familiar with the technology, and figure out what it can, and cannot provide 🙂
Summary
WebWorker is the only technology that can offer XSS safe storage of secrets and offer some token data information to the client.
We should investigate/test if it's possible to migrate this library to use that.
Basic Example
Drawbacks
Possible that some current features will not be supported.
Unresolved questions
No response
Implementation PR
No response
Reference Issues
No response
The text was updated successfully, but these errors were encountered: