Some checks are pending
Build, Lint & Test Lib / Built, Lint and Test Library (push) Waiting to run
Build, Lint & Test Lib / Angular latest (push) Blocked by required conditions
Build, Lint & Test Lib / Angular latest & Schematics Job (push) Blocked by required conditions
Build, Lint & Test Lib / Angular latest Standalone & Schematics Job (push) Blocked by required conditions
Build, Lint & Test Lib / Angular 16 & RxJs 6 (push) Blocked by required conditions
Build, Lint & Test Lib / Angular V16 (push) Blocked by required conditions
Docs / Build and Deploy Docs Job (push) Waiting to run
Docs / Close Pull Request Job (push) Waiting to run
54 lines
1.4 KiB
TypeScript
54 lines
1.4 KiB
TypeScript
import { Provider } from 'injection-js';
|
|
import { forkJoin, Observable, of } from 'rxjs';
|
|
import { map } from 'rxjs/operators';
|
|
import { OpenIdConfiguration } from '../openid-configuration';
|
|
|
|
export class OpenIdConfigLoader {
|
|
loader?: Provider;
|
|
}
|
|
|
|
export abstract class StsConfigLoader {
|
|
abstract loadConfigs(): Observable<OpenIdConfiguration[]>;
|
|
}
|
|
|
|
export class StsConfigStaticLoader implements StsConfigLoader {
|
|
constructor(
|
|
private readonly passedConfigs: OpenIdConfiguration | OpenIdConfiguration[]
|
|
) {}
|
|
|
|
loadConfigs(): Observable<OpenIdConfiguration[]> {
|
|
if (Array.isArray(this.passedConfigs)) {
|
|
return of(this.passedConfigs);
|
|
}
|
|
|
|
return of([this.passedConfigs]);
|
|
}
|
|
}
|
|
|
|
export class StsConfigHttpLoader implements StsConfigLoader {
|
|
constructor(
|
|
private readonly configs$:
|
|
| Observable<OpenIdConfiguration>
|
|
| Observable<OpenIdConfiguration>[]
|
|
| Observable<OpenIdConfiguration[]>
|
|
) {}
|
|
|
|
loadConfigs(): Observable<OpenIdConfiguration[]> {
|
|
if (Array.isArray(this.configs$)) {
|
|
return forkJoin(this.configs$);
|
|
}
|
|
|
|
const singleConfigOrArray = this.configs$ as Observable<unknown>;
|
|
|
|
return singleConfigOrArray.pipe(
|
|
map((value: unknown) => {
|
|
if (Array.isArray(value)) {
|
|
return value as OpenIdConfiguration[];
|
|
}
|
|
|
|
return [value] as OpenIdConfiguration[];
|
|
})
|
|
);
|
|
}
|
|
}
|