Search code examples
spartacus-storefront

Overriding Spartacus interceptors not possible anymore?


Since upgrading @spartacus/core I've noticed that interceptors (among a few other injectables) have been aliased with prefixes of the Theta ɵ character.

I've noticed the Angular team typically does the same for internals that are not intended for override or extension. I presume that's what the spartacus team is going for too?

May I ask why these interceptors are regarded as internals?

We're currently integrating with our own separate OIDC server and in order to properly achieve this we've needed to override a few of the auth interceptors, namely UserTokenInterceptor and ClientTokenInterceptor.

Is there an alternative recommended approach or would we have to downgrade @spartacus/core?

We could make sure to check the Theta character alias token we're overriding each time we bump @spartacus/core too though this is kind of against the grain - I noticed the aliases change when we bumped spartacus to 2.x.

I've toyed with the idea of creating an overarching null interceptor to nullify other spartacus interceptors effects, though that's probably not possible for interceptors like the ClientTokenInterceptor that make their own network requests preflight.


Solution

  • We recently started to work on authorization module to support different OAuth flows and to make integration with external identity providers easier. With that changes we already thought about interceptors and there will be a couple of changes in them and they will be exported in the public @spartacus/core API. At the moment we target 3.0 release with the changes, but I can't promise any specific date.