OIDC and service worker

451 views Asked by At

Recently I was reading OIDC documentation for browser based aplications and I found that one of the recomendation is to use service worker (you can see it here). I'm quite fresh to service workers but I know that it is possible to intercept fetch, so it is possible to add access token to each external api request. The problem is how should I safely store token? Can I just cache it caling const cache = await caches.open("my-cahce"); and then just add token to the cache?

1

There are 1 answers

0
MiF On

The service worker is isolated from the page and you can store a token inside it in a variable or in a closure - this is safe.