UNPKG

oidc-client-rx

Version:

ReactiveX enhanced OIDC and OAuth2 protocol support for browser-based JavaScript applications

23 lines (22 loc) 1.02 kB
import { InjectionToken, inject } from "@outposts/injection-js"; import { filter, shareReplay } from "rxjs"; import { EventTypes } from "../public-events/event-types.js"; import { PublicEventsService } from "../public-events/public-events.service.js"; const CHECK_AUTH_RESULT_EVENT = new InjectionToken('CHECK_AUTH_RESULT_EVENT'); function withCheckAuthResultEvent({ shareReplayCount = 1 } = {}) { return { ɵproviders: [ { provide: CHECK_AUTH_RESULT_EVENT, useFactory: ()=>{ const publishEventService = inject(PublicEventsService); return publishEventService.registerForEvents().pipe(filter((e)=>e.type === EventTypes.CheckingAuthFinishedWithError || e.type === EventTypes.CheckingAuthFinished), shareReplay(shareReplayCount)); }, deps: [ PublicEventsService ] } ] }; } export { CHECK_AUTH_RESULT_EVENT, withCheckAuthResultEvent };