Using crypto operations of blockstack.js in web workers


I have noticed that blockstack.js executes encryption in the foreground which is causing the UI to hang if you are passing it larger files. Is there any chance to use e.g. userSession.encryptContent from within a web worker?

I found a related issue on GitHub that is closed but does not seem to be resolved:


Seems to be resolved with 19.1, as you can now specify your own store and it’s not using localStorage anymore. (see discussion: )


Thanks for the hint. A minimal setup of a worker can look something like this:


const sessionStore = {
  data: {},
  getSessionData() { return },
  setSessionData(data) { = data },
  deleteSessionData() { = {} },

const userSession = new blockstack.UserSession({
  appConfig: new blockstack.AppConfig({ /* ... */ }),

// ... and then given that you have a buffer and a key available in your worker:
userSession.decryptContent(aBuffer, { privateKey })