UNPKG

oidc-client-rx

Version:

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

36 lines (35 loc) 1.73 kB
import { Injectable } from "injection-js"; function _ts_decorate(decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc); else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; } class FlowHelper { isCurrentFlowCodeFlow(configuration) { return this.currentFlowIs("code", configuration); } isCurrentFlowAnyImplicitFlow(configuration) { return this.isCurrentFlowImplicitFlowWithAccessToken(configuration) || this.isCurrentFlowImplicitFlowWithoutAccessToken(configuration); } isCurrentFlowCodeFlowWithRefreshTokens(configuration) { if (!configuration) return false; const { useRefreshToken } = configuration; return this.isCurrentFlowCodeFlow(configuration) && Boolean(useRefreshToken); } isCurrentFlowImplicitFlowWithAccessToken(configuration) { return this.currentFlowIs("id_token token", configuration); } currentFlowIs(flowTypes, configuration) { const { responseType } = configuration; if (Array.isArray(flowTypes)) return flowTypes.some((x)=>responseType === x); return responseType === flowTypes; } isCurrentFlowImplicitFlowWithoutAccessToken(configuration) { return this.currentFlowIs("id_token", configuration); } } FlowHelper = _ts_decorate([ Injectable() ], FlowHelper); export { FlowHelper };