@sassoftware/viya-serverjs 0.0.2 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -3
- package/package.json +78 -5
- package/lib/cli.js +0 -8
- package/lib/core/config.js +0 -98
- package/lib/core/handlers/appCallback.js +0 -51
- package/lib/core/handlers/codeAuth.js +0 -75
- package/lib/core/handlers/decodeJwt.js +0 -18
- package/lib/core/handlers/favicon.js +0 -45
- package/lib/core/handlers/getApp.js +0 -112
- package/lib/core/handlers/getApp2.js +0 -49
- package/lib/core/handlers/getUser.js +0 -50
- package/lib/core/handlers/index.js +0 -101
- package/lib/core/handlers/keepAlive.js +0 -97
- package/lib/core/handlers/keepAlive2.js +0 -33
- package/lib/core/handlers/logon.js +0 -44
- package/lib/core/handlers/logout.js +0 -88
- package/lib/core/handlers/proxyMapUri.js +0 -76
- package/lib/core/handlers/proxyOnResponse.js +0 -26
- package/lib/core/handlers/reactDev.js +0 -52
- package/lib/core/handlers/setCookies.js +0 -116
- package/lib/core/iService.js +0 -468
- package/lib/core/index.js +0 -184
- package/lib/core/parseDocker.js +0 -33
- package/lib/core/plugins/SASauth.js +0 -109
- package/lib/core/plugins/appCookie.js +0 -102
- package/lib/core/plugins/setContext.js +0 -56
- package/lib/core/plugins/setDefaultRoutes.js +0 -274
- package/lib/core/plugins/setupAuth.js +0 -87
- package/lib/core/plugins/setupUserRoutes.js +0 -54
- package/lib/core/plugins/token.js +0 -32
- package/lib/core/schemes/SASTokenScheme.js +0 -72
- package/lib/index.js +0 -29
package/lib/core/parseDocker.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright © 2019, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
|
|
3
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
*/
|
|
5
|
-
'use strict';
|
|
6
|
-
|
|
7
|
-
Object.defineProperty(exports, "__esModule", {
|
|
8
|
-
value: true
|
|
9
|
-
});
|
|
10
|
-
exports["default"] = void 0;
|
|
11
|
-
var parser = require('docker-file-parser');
|
|
12
|
-
var fs = require('fs');
|
|
13
|
-
function parseDocker(dockerFile) {
|
|
14
|
-
;
|
|
15
|
-
var d = fs.readFileSync(dockerFile, 'utf8');
|
|
16
|
-
var data = parser.parse(d);
|
|
17
|
-
data.forEach(function (d) {
|
|
18
|
-
if (d.name === 'EXPOSE') {
|
|
19
|
-
process.env.EXPOSEDPORT = d.args[0];
|
|
20
|
-
console.log("Exposed port: ".concat(process.env.EXPOSEDPORT));
|
|
21
|
-
} else if (d.name === 'ENV') {
|
|
22
|
-
for (var key in d.args) {
|
|
23
|
-
var v = d.args[key];
|
|
24
|
-
if (v.length === 0) {
|
|
25
|
-
console.log("Value for ".concat(key, " inherited as ").concat(process.env[key]));
|
|
26
|
-
} else {
|
|
27
|
-
process.env[key] = v;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
var _default = exports["default"] = parseDocker;
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
5
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
6
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
7
|
-
/*
|
|
8
|
-
* ------------------------------------------------------------------------------------
|
|
9
|
-
* * Copyright (c) SAS Institute Inc.
|
|
10
|
-
* * Licensed under the Apache License, Version 2.0 (the "License");
|
|
11
|
-
* * you may not use this file except in compliance with the License.
|
|
12
|
-
* * You may obtain a copy of the License at
|
|
13
|
-
* *
|
|
14
|
-
* * http://www.apache.org/licenses/LICENSE-2.0
|
|
15
|
-
* *
|
|
16
|
-
* * Unless required by applicable law or agreed to in writing, software
|
|
17
|
-
* * distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
-
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19
|
-
* * See the License for the specific language governing permissions and
|
|
20
|
-
* limitations under the License.
|
|
21
|
-
* ----------------------------------------------------------------------------------------
|
|
22
|
-
*
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
var bell = require('@hapi/bell');
|
|
26
|
-
var uuid = require('uuid');
|
|
27
|
-
var debug = require('debug')('sasauth');
|
|
28
|
-
exports.plugin = {
|
|
29
|
-
name: 'SASauth',
|
|
30
|
-
version: '1.0.0',
|
|
31
|
-
register: iSASauth
|
|
32
|
-
};
|
|
33
|
-
function iSASauth(_x, _x2) {
|
|
34
|
-
return _iSASauth.apply(this, arguments);
|
|
35
|
-
}
|
|
36
|
-
function _iSASauth() {
|
|
37
|
-
_iSASauth = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(server, options) {
|
|
38
|
-
var bellAuthOptions, provider, host;
|
|
39
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
40
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
41
|
-
case 0:
|
|
42
|
-
debug('in iSASauth');
|
|
43
|
-
debug(options);
|
|
44
|
-
// test for k8s deployment
|
|
45
|
-
host = options.host + '/SASLogon';
|
|
46
|
-
if (options.ns != null) {
|
|
47
|
-
host = "https://sas-logon-app.".concat(options.ns, ".svc.cluster.local");
|
|
48
|
-
} else if (options.nsHost != null) {
|
|
49
|
-
host = options.nsHost;
|
|
50
|
-
}
|
|
51
|
-
// ...
|
|
52
|
-
debug(host);
|
|
53
|
-
provider = {
|
|
54
|
-
name: 'sas',
|
|
55
|
-
protocol: 'oauth2',
|
|
56
|
-
useParamsAuth: false,
|
|
57
|
-
auth: host + '/oauth/authorize',
|
|
58
|
-
token: host + '/oauth/token',
|
|
59
|
-
profileMethod: 'get',
|
|
60
|
-
profile: function () {
|
|
61
|
-
var _profile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(credentials, params, get) {
|
|
62
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
63
|
-
while (1) switch (_context.prev = _context.next) {
|
|
64
|
-
case 0:
|
|
65
|
-
debugger;
|
|
66
|
-
console.log('in profile', credentials);
|
|
67
|
-
debug(credentials);
|
|
68
|
-
debug(params);
|
|
69
|
-
debugger;
|
|
70
|
-
|
|
71
|
-
//let r = await get();
|
|
72
|
-
//debug(r);
|
|
73
|
-
debugger;
|
|
74
|
-
server.log('SASAuth profile', credentials);
|
|
75
|
-
case 7:
|
|
76
|
-
case "end":
|
|
77
|
-
return _context.stop();
|
|
78
|
-
}
|
|
79
|
-
}, _callee);
|
|
80
|
-
}));
|
|
81
|
-
function profile(_x3, _x4, _x5) {
|
|
82
|
-
return _profile.apply(this, arguments);
|
|
83
|
-
}
|
|
84
|
-
return profile;
|
|
85
|
-
}()
|
|
86
|
-
};
|
|
87
|
-
bellAuthOptions = {
|
|
88
|
-
provider: provider,
|
|
89
|
-
password: uuid.v4(),
|
|
90
|
-
clientId: options.clientId,
|
|
91
|
-
clientSecret: options.clientSecret,
|
|
92
|
-
// isSameSite : options.isSameSite,
|
|
93
|
-
isSecure: options.isSecure
|
|
94
|
-
};
|
|
95
|
-
// console.log('SASAuth options', bellAuthOptions);
|
|
96
|
-
debug(bellAuthOptions);
|
|
97
|
-
server.log('SASAuth', bellAuthOptions);
|
|
98
|
-
_context2.next = 11;
|
|
99
|
-
return server.register(bell);
|
|
100
|
-
case 11:
|
|
101
|
-
server.auth.strategy('sas', 'bell', bellAuthOptions);
|
|
102
|
-
case 12:
|
|
103
|
-
case "end":
|
|
104
|
-
return _context2.stop();
|
|
105
|
-
}
|
|
106
|
-
}, _callee2);
|
|
107
|
-
}));
|
|
108
|
-
return _iSASauth.apply(this, arguments);
|
|
109
|
-
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
5
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
6
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
7
|
-
var uuid = require('uuid');
|
|
8
|
-
var debug = require('debug')('appcookie');
|
|
9
|
-
module.exports = /*#__PURE__*/function () {
|
|
10
|
-
var _appCookie = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(server, options) {
|
|
11
|
-
var cookieOptions;
|
|
12
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
13
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
14
|
-
case 0:
|
|
15
|
-
_context2.next = 2;
|
|
16
|
-
return server.register(require('@hapi/cookie'));
|
|
17
|
-
case 2:
|
|
18
|
-
cookieOptions = {
|
|
19
|
-
cookie: {
|
|
20
|
-
name: 'cookie',
|
|
21
|
-
password: uuid.v4(),
|
|
22
|
-
isSecure: options.isSecure,
|
|
23
|
-
isSameSite: options.isSameSite
|
|
24
|
-
},
|
|
25
|
-
redirectTo: options.redirectTo,
|
|
26
|
-
appendNext: {
|
|
27
|
-
name: 'next'
|
|
28
|
-
},
|
|
29
|
-
validateFunc: function () {
|
|
30
|
-
var _validateFunc = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(req, session) {
|
|
31
|
-
var credentials, sid;
|
|
32
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
33
|
-
while (1) switch (_context.prev = _context.next) {
|
|
34
|
-
case 0:
|
|
35
|
-
debugger;
|
|
36
|
-
debug('in validateFunc');
|
|
37
|
-
debug(req.path);
|
|
38
|
-
server.log('Cookie validateFunc', "path - ".concat(req.path));
|
|
39
|
-
if (!(session == null)) {
|
|
40
|
-
_context.next = 7;
|
|
41
|
-
break;
|
|
42
|
-
}
|
|
43
|
-
console.log('session is null');
|
|
44
|
-
return _context.abrupt("return", {
|
|
45
|
-
valid: false
|
|
46
|
-
});
|
|
47
|
-
case 7:
|
|
48
|
-
credentials = null;
|
|
49
|
-
if (Array.isArray(session) === true && session.length > 0) {
|
|
50
|
-
sid = session[0].sid;
|
|
51
|
-
} else {
|
|
52
|
-
sid = session.sid;
|
|
53
|
-
}
|
|
54
|
-
if (!(sid != null)) {
|
|
55
|
-
_context.next = 13;
|
|
56
|
-
break;
|
|
57
|
-
}
|
|
58
|
-
_context.next = 12;
|
|
59
|
-
return req.server.app.cache.get(sid);
|
|
60
|
-
case 12:
|
|
61
|
-
credentials = _context.sent;
|
|
62
|
-
case 13:
|
|
63
|
-
if (!(credentials == null)) {
|
|
64
|
-
_context.next = 15;
|
|
65
|
-
break;
|
|
66
|
-
}
|
|
67
|
-
return _context.abrupt("return", {
|
|
68
|
-
valid: false
|
|
69
|
-
});
|
|
70
|
-
case 15:
|
|
71
|
-
server.log('Cookie validateFunc', sid);
|
|
72
|
-
debug(sid);
|
|
73
|
-
return _context.abrupt("return", {
|
|
74
|
-
valid: true,
|
|
75
|
-
credentials: credentials
|
|
76
|
-
});
|
|
77
|
-
case 18:
|
|
78
|
-
case "end":
|
|
79
|
-
return _context.stop();
|
|
80
|
-
}
|
|
81
|
-
}, _callee);
|
|
82
|
-
}));
|
|
83
|
-
function validateFunc(_x3, _x4) {
|
|
84
|
-
return _validateFunc.apply(this, arguments);
|
|
85
|
-
}
|
|
86
|
-
return validateFunc;
|
|
87
|
-
}()
|
|
88
|
-
}; // console.log('cookie options', cookieOptions);
|
|
89
|
-
server.log('Cookie Options', cookieOptions);
|
|
90
|
-
debug('Cookie Options', cookieOptions);
|
|
91
|
-
server.auth.strategy('session', 'cookie', cookieOptions);
|
|
92
|
-
case 6:
|
|
93
|
-
case "end":
|
|
94
|
-
return _context2.stop();
|
|
95
|
-
}
|
|
96
|
-
}, _callee2);
|
|
97
|
-
}));
|
|
98
|
-
function appCookie(_x, _x2) {
|
|
99
|
-
return _appCookie.apply(this, arguments);
|
|
100
|
-
}
|
|
101
|
-
return appCookie;
|
|
102
|
-
}();
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
8
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
9
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
10
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
11
|
-
/*
|
|
12
|
-
* ------------------------------------------------------------------------------------
|
|
13
|
-
* Copyright (c) SAS Institute Inc.
|
|
14
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
15
|
-
* you may not use this file except in compliance with the License.
|
|
16
|
-
* You may obtain a copy of the License at
|
|
17
|
-
*
|
|
18
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
19
|
-
*
|
|
20
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
21
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
22
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
23
|
-
* See the License for the specific language governing permissions and
|
|
24
|
-
* limitations under the License.
|
|
25
|
-
* ---------------------------------------------------------------------------------------
|
|
26
|
-
*
|
|
27
|
-
*/
|
|
28
|
-
function setContext(_x, _x2) {
|
|
29
|
-
return _setContext.apply(this, arguments);
|
|
30
|
-
}
|
|
31
|
-
function _setContext() {
|
|
32
|
-
_setContext = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(req, h) {
|
|
33
|
-
var credentials, context;
|
|
34
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
35
|
-
while (1) switch (_context.prev = _context.next) {
|
|
36
|
-
case 0:
|
|
37
|
-
credentials = req.auth.credentials;
|
|
38
|
-
debugger;
|
|
39
|
-
context = {
|
|
40
|
-
path: req.path,
|
|
41
|
-
params: req.params,
|
|
42
|
-
query: req.query,
|
|
43
|
-
payload: req.payload,
|
|
44
|
-
token: credentials != null ? "bearer ".concat(credentials.token) : null,
|
|
45
|
-
host: process.env.VIYA_SERVER
|
|
46
|
-
};
|
|
47
|
-
return _context.abrupt("return", context);
|
|
48
|
-
case 4:
|
|
49
|
-
case "end":
|
|
50
|
-
return _context.stop();
|
|
51
|
-
}
|
|
52
|
-
}, _callee);
|
|
53
|
-
}));
|
|
54
|
-
return _setContext.apply(this, arguments);
|
|
55
|
-
}
|
|
56
|
-
var _default = exports["default"] = setContext;
|
|
@@ -1,274 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
-
var _handlers = require("../handlers");
|
|
5
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
9
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
10
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
11
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
12
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } /*
|
|
13
|
-
* ------------------------------------------------------------------------------------
|
|
14
|
-
* * Copyright (c) SAS Institute Inc.
|
|
15
|
-
* * Licensed under the Apache License, Version 2.0 (the "License");
|
|
16
|
-
* * you may not use this file except in compliance with the License.
|
|
17
|
-
* * You may obtain a copy of the License at
|
|
18
|
-
* *
|
|
19
|
-
* * http://www.apache.org/licenses/LICENSE-2.0
|
|
20
|
-
* *
|
|
21
|
-
* * Unless required by applicable law or agreed to in writing, software
|
|
22
|
-
* * distributed under the License is distributed on an "AS IS" BASIS,
|
|
23
|
-
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
24
|
-
* * See the License for the specific language governing permissions and
|
|
25
|
-
* limitations under the License.
|
|
26
|
-
* ----------------------------------------------------------------------------------------
|
|
27
|
-
*
|
|
28
|
-
*/
|
|
29
|
-
var debug = require('debug')('routes');
|
|
30
|
-
module.exports = function setDefaultRoutes(server, options) {
|
|
31
|
-
debug('setDefaultRoutes');
|
|
32
|
-
var appName = '/' + options.appName;
|
|
33
|
-
var authDefault = false;
|
|
34
|
-
var authLogon = false;
|
|
35
|
-
if (options.authFlow === 'server') {
|
|
36
|
-
authDefault = options.serverMode === 'app' ? false : {
|
|
37
|
-
strategies: ['token', 'session'],
|
|
38
|
-
mode: 'required'
|
|
39
|
-
};
|
|
40
|
-
authLogon = {
|
|
41
|
-
mode: 'required',
|
|
42
|
-
strategy: 'sas'
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
debug('authDefault', authDefault);
|
|
46
|
-
debug('authLogon', authLogon);
|
|
47
|
-
|
|
48
|
-
//let getAppb = getApp.bind(null, (process.env.USETOKEN === 'YES' ? options : null));
|
|
49
|
-
var getAppb = _handlers.getApp.bind(null, options);
|
|
50
|
-
server.log('Default strategy', authDefault);
|
|
51
|
-
server.log('Logon strategy', authLogon);
|
|
52
|
-
options.authDefault = authDefault;
|
|
53
|
-
options.authLogon = authLogon;
|
|
54
|
-
var uTable = options.userRouteTable !== null ? (0, _handlers.setupUserRoutes)(options.userRouteTable, authDefault) : null;
|
|
55
|
-
var defaultTable = [{
|
|
56
|
-
method: ['GET'],
|
|
57
|
-
path: "/health",
|
|
58
|
-
options: {
|
|
59
|
-
auth: false,
|
|
60
|
-
handler: function () {
|
|
61
|
-
var _handler = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(req, h) {
|
|
62
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
63
|
-
while (1) switch (_context.prev = _context.next) {
|
|
64
|
-
case 0:
|
|
65
|
-
return _context.abrupt("return", h.response({
|
|
66
|
-
x: 1
|
|
67
|
-
}).code(200));
|
|
68
|
-
case 1:
|
|
69
|
-
case "end":
|
|
70
|
-
return _context.stop();
|
|
71
|
-
}
|
|
72
|
-
}, _callee);
|
|
73
|
-
}));
|
|
74
|
-
function handler(_x, _x2) {
|
|
75
|
-
return _handler.apply(this, arguments);
|
|
76
|
-
}
|
|
77
|
-
return handler;
|
|
78
|
-
}()
|
|
79
|
-
}
|
|
80
|
-
}, {
|
|
81
|
-
method: ['GET'],
|
|
82
|
-
path: "".concat(appName),
|
|
83
|
-
options: {
|
|
84
|
-
auth: options.serverMode === 'app' ? authLogon : authDefault,
|
|
85
|
-
handler: getAppb
|
|
86
|
-
}
|
|
87
|
-
}, {
|
|
88
|
-
method: ['GET'],
|
|
89
|
-
path: "".concat(appName, "/api"),
|
|
90
|
-
options: {
|
|
91
|
-
auth: authDefault,
|
|
92
|
-
handler: function () {
|
|
93
|
-
var _handler2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(req, h) {
|
|
94
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
95
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
96
|
-
case 0:
|
|
97
|
-
return _context2.abrupt("return", h.redirect("".concat(appName, "/documentation")));
|
|
98
|
-
case 1:
|
|
99
|
-
case "end":
|
|
100
|
-
return _context2.stop();
|
|
101
|
-
}
|
|
102
|
-
}, _callee2);
|
|
103
|
-
}));
|
|
104
|
-
function handler(_x3, _x4) {
|
|
105
|
-
return _handler2.apply(this, arguments);
|
|
106
|
-
}
|
|
107
|
-
return handler;
|
|
108
|
-
}()
|
|
109
|
-
}
|
|
110
|
-
}, {
|
|
111
|
-
method: ['GET'],
|
|
112
|
-
path: "/develop",
|
|
113
|
-
options: {
|
|
114
|
-
auth: false,
|
|
115
|
-
cors: true,
|
|
116
|
-
handler: _handlers.reactDev
|
|
117
|
-
}
|
|
118
|
-
}, {
|
|
119
|
-
method: ['GET'],
|
|
120
|
-
path: "".concat(appName, "/develop"),
|
|
121
|
-
options: {
|
|
122
|
-
auth: false,
|
|
123
|
-
cors: true,
|
|
124
|
-
handler: _handlers.reactDev
|
|
125
|
-
}
|
|
126
|
-
}, {
|
|
127
|
-
method: ['GET'],
|
|
128
|
-
path: "".concat(appName, "/logon"),
|
|
129
|
-
options: {
|
|
130
|
-
auth: authLogon,
|
|
131
|
-
//https://futurestud.io/tutorials/hapi-redirect-to-previous-page-after-login
|
|
132
|
-
plugins: {
|
|
133
|
-
'hapi-auth-cookie': {
|
|
134
|
-
redirectTo: false
|
|
135
|
-
}
|
|
136
|
-
},
|
|
137
|
-
handler: _handlers.logon
|
|
138
|
-
}
|
|
139
|
-
}, {
|
|
140
|
-
method: ['GET'],
|
|
141
|
-
path: "".concat(appName, "/callback"),
|
|
142
|
-
options: {
|
|
143
|
-
auth: authDefault,
|
|
144
|
-
handler: _handlers.appCallback
|
|
145
|
-
}
|
|
146
|
-
}, {
|
|
147
|
-
method: ['GET'],
|
|
148
|
-
path: "".concat(appName, "/logout"),
|
|
149
|
-
options: {
|
|
150
|
-
auth: authDefault,
|
|
151
|
-
handler: _handlers.logout
|
|
152
|
-
}
|
|
153
|
-
}, {
|
|
154
|
-
method: ['GET', 'POST'],
|
|
155
|
-
path: "".concat(appName, "/keepAlive"),
|
|
156
|
-
options: {
|
|
157
|
-
auth: authDefault,
|
|
158
|
-
handler: _handlers.keepAlive
|
|
159
|
-
}
|
|
160
|
-
}, {
|
|
161
|
-
method: ['GET'],
|
|
162
|
-
path: "".concat(appName, "/appenv"),
|
|
163
|
-
options: {
|
|
164
|
-
auth: /*authDefault*/false,
|
|
165
|
-
handler: function handler(req, h) {
|
|
166
|
-
var allAppEnv = options.allAppEnv;
|
|
167
|
-
if (options.userInfo != null) {
|
|
168
|
-
var uappenv = options.userInfo('APPENV', options);
|
|
169
|
-
if (uappenv != null) {
|
|
170
|
-
allAppEnv.APPENV = _objectSpread(_objectSpread({}, allAppEnv.APPENV), uappenv);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
allAppEnv.credentials = options.credentials;
|
|
174
|
-
var s = "let LOGONPAYLOAD = ".concat(JSON.stringify(allAppEnv.LOGONPAYLOAD), ";") + "let APPENV = ".concat(JSON.stringify(allAppEnv.APPENV), ";");
|
|
175
|
-
if (process.env.SHOWENV != null) {
|
|
176
|
-
console.log(options.allAppEnv);
|
|
177
|
-
console.log(s);
|
|
178
|
-
}
|
|
179
|
-
return s;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
}, {
|
|
183
|
-
method: ['GET'] /* nedd this when running under dev mode in react apps */,
|
|
184
|
-
path: "/appenv",
|
|
185
|
-
options: {
|
|
186
|
-
auth: /*authDefault*/false,
|
|
187
|
-
handler: function handler(req, h) {
|
|
188
|
-
var allAppEnv = options.allAppEnv;
|
|
189
|
-
if (options.userInfo != null) {
|
|
190
|
-
allAppEnv.APPENV = options.userInfo('APPENV', options);
|
|
191
|
-
}
|
|
192
|
-
var s = "let LOGONPAYLOAD = ".concat(JSON.stringify(allAppEnv.LOGONPAYLOAD), ";") + "let APPENV = ".concat(JSON.stringify(allAppEnv.APPENV), ";");
|
|
193
|
-
return s;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
}, {
|
|
197
|
-
method: ['GET'],
|
|
198
|
-
path: "".concat(appName, "/{param*}"),
|
|
199
|
-
options: {
|
|
200
|
-
auth: authLogon,
|
|
201
|
-
/*authDefault,*/
|
|
202
|
-
|
|
203
|
-
// handler: getApp2,
|
|
204
|
-
handler: {
|
|
205
|
-
file: function file(req, h) {
|
|
206
|
-
debugger;
|
|
207
|
-
console.log('in file1 handler');
|
|
208
|
-
console.log(req.auth);
|
|
209
|
-
console.log(req.params);
|
|
210
|
-
return req.params.param;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
}, {
|
|
215
|
-
method: ['GET'],
|
|
216
|
-
path: "/{param*}",
|
|
217
|
-
options: {
|
|
218
|
-
auth: authLogon,
|
|
219
|
-
handler: _handlers.getApp2
|
|
220
|
-
/*
|
|
221
|
-
handler: {
|
|
222
|
-
file: function (req,h) {
|
|
223
|
-
debugger;
|
|
224
|
-
console.log('in file2 handler');
|
|
225
|
-
console.log(req.auth);
|
|
226
|
-
console.log(req.params);
|
|
227
|
-
return req.params.param;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
},
|
|
231
|
-
*/
|
|
232
|
-
}
|
|
233
|
-
}, {
|
|
234
|
-
method: ['GET'],
|
|
235
|
-
path: "/favicon.ico",
|
|
236
|
-
options: {
|
|
237
|
-
auth: false,
|
|
238
|
-
handler: _handlers.favicon
|
|
239
|
-
}
|
|
240
|
-
}, {
|
|
241
|
-
method: ['GET', 'POST'],
|
|
242
|
-
path: "".concat(appName, "/keepAlive2"),
|
|
243
|
-
options: {
|
|
244
|
-
auth: authDefault,
|
|
245
|
-
handler: _handlers.keepAlive2
|
|
246
|
-
}
|
|
247
|
-
}];
|
|
248
|
-
if (process.env.PROXYSERVER != null) {
|
|
249
|
-
var pr = {
|
|
250
|
-
method: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS'],
|
|
251
|
-
path: "".concat(appName, "/proxy/{param*}"),
|
|
252
|
-
// vhost : [process.env.PROXYSERVER],
|
|
253
|
-
options: {
|
|
254
|
-
handler: {
|
|
255
|
-
proxy: {
|
|
256
|
-
mapUri: _handlers.proxyMapUri,
|
|
257
|
-
//uri: process.env.PROXYSERVER + '/' + '{param}',
|
|
258
|
-
|
|
259
|
-
xforward: true,
|
|
260
|
-
passThrough: true
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
};
|
|
265
|
-
console.log(pr);
|
|
266
|
-
defaultTable.push(pr);
|
|
267
|
-
}
|
|
268
|
-
var routeTables = uTable !== null ? defaultTable.concat(uTable) : defaultTable;
|
|
269
|
-
/*
|
|
270
|
-
server.log('routes', routeTables);
|
|
271
|
-
console.table(routeTables);
|
|
272
|
-
*/
|
|
273
|
-
server.route(routeTables);
|
|
274
|
-
};
|