oidc-client-ts icon indicating copy to clipboard operation
oidc-client-ts copied to clipboard

Is it possible to use oidc-client-ts in service worker?

Open kostia-lev opened this issue 2 years ago • 7 comments

I would like to use oic-client-ts in service worker in chrome extension. Be these things throw errors(window is not existent in service worker): async signinPopupCallback(url = window.location.href, keepOpen = false) { How to fix such things?

kostia-lev avatar Feb 28 '22 20:02 kostia-lev

This library only supports SSR (without a window), but to actually authenticate a window is required. See https://github.com/authts/oidc-client-ts/issues/256#issuecomment-992080256.

pamapa avatar Mar 01 '22 16:03 pamapa

i am now closing this, if you do not agree please comment here...

pamapa avatar Mar 07 '22 16:03 pamapa

I would like to see this working in service workers and chrome extensions using manifest v3 as well. Can you reopen the issue? Anything speaking against supporting this?

angelo-v avatar Jun 29 '22 18:06 angelo-v

I am struggling with the auth in manifest v3 service worker since it was released. It would be really nice if this was supported.

We would also probably want to have a new cache option. To cache inside chrome.storage and not window.localStorage

Alino avatar Jul 15 '22 17:07 Alino

I am willing to work on this, but only if https://github.com/inrupt/solid-client-authn-js/issues/2202 gets resolved, otherwise it won't help my cause

angelo-v avatar Aug 17 '22 18:08 angelo-v

For anyone wondering about MSAL, it has similar problems supporting the service worker and manifest v3 https://github.com/AzureAD/microsoft-authentication-library-for-js/issues/3923

you can also have a look at my example repo and perhaps reuse some polyfills for window object even with this OIDC lib. https://github.com/Alino/MSAL_ChromiumExtensionSampleManifestV3

Alino avatar Aug 17 '22 19:08 Alino

I have created a sample repo of a chrome extension using this oidc-client-ts library https://github.com/Alino/OIDC-client-ts-chromium-sample

feedback is welcome, as I would like to make this work perfectly. I think right now it does not handle token expiration. So PR are welcome.

Update: Handling token expiration fixed with https://github.com/Alino/OIDC-client-ts-chromium-sample/commit/da8525450a0ee8b6c9789f5f279f1ad944cb4889

Alino avatar Sep 05 '22 12:09 Alino