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 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
11 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
12 | };
|
13 | Object.defineProperty(exports, "__esModule", { value: true });
|
14 | const UnAuthenticated_1 = __importDefault(require("./UnAuthenticated"));
|
15 | const index_1 = require("./index");
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 | class Gateway {
|
22 | |
23 |
|
24 |
|
25 |
|
26 | constructor(protocol) {
|
27 | this.protocol = protocol;
|
28 | |
29 |
|
30 |
|
31 |
|
32 | this.provider = new index_1.IdentityProviderChain();
|
33 | }
|
34 | |
35 |
|
36 |
|
37 |
|
38 | authenticate(context) {
|
39 | return __awaiter(this, void 0, void 0, function* () {
|
40 | const credential = yield this.protocol.resolve(context);
|
41 | const identity = yield this.provider.provide(credential);
|
42 | if (!identity) {
|
43 | throw new UnAuthenticated_1.default("Identity not found");
|
44 | }
|
45 | return identity;
|
46 | });
|
47 | }
|
48 | }
|
49 | exports.default = Gateway;
|
50 |
|
\ | No newline at end of file |