1 | "use strict";
|
2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3 | return new (P || (P = Promise))(function (resolve, reject) {
|
4 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
5 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
6 | function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
7 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8 | });
|
9 | };
|
10 | Object.defineProperty(exports, "__esModule", { value: true });
|
11 | class IdentityProviderChain {
|
12 | constructor(chains = []) {
|
13 | this.chains = chains;
|
14 | }
|
15 | push(provider) {
|
16 | this.chains.push(provider);
|
17 | return this;
|
18 | }
|
19 | provide(credential) {
|
20 | return __awaiter(this, void 0, void 0, function* () {
|
21 | let identityChain = credential;
|
22 | for (let index = 0; index < this.chains.length; index++) {
|
23 | const idp = this.chains[index];
|
24 | identityChain = yield idp.provide(identityChain);
|
25 | if (!identityChain) {
|
26 | return null;
|
27 | }
|
28 | }
|
29 | return identityChain;
|
30 | });
|
31 | }
|
32 | }
|
33 | exports.default = IdentityProviderChain;
|
34 |
|
\ | No newline at end of file |