@sassoftware/viya-serverjs 0.0.1 → 0.0.3
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/lib/cli.js +2 -3
- package/lib/core/config.js +17 -5
- package/lib/core/handlers/codeAuth.js +16 -12
- package/lib/core/handlers/getApp.js +65 -35
- package/lib/core/handlers/getApp2.js +2 -1
- package/lib/core/handlers/getUser.js +6 -5
- package/lib/core/handlers/keepAlive.js +13 -12
- package/lib/core/handlers/proxyMapUri.js +2 -1
- package/lib/core/handlers/reactDev.js +1 -1
- package/lib/core/handlers/setCookies.js +23 -19
- package/lib/core/iService.js +5 -4
- package/lib/core/index.js +35 -40
- package/lib/core/plugins/SASauth.js +10 -1
- package/lib/core/plugins/appCookie.js +16 -10
- package/lib/core/plugins/setContext.js +2 -1
- package/lib/core/plugins/setDefaultRoutes.js +41 -6
- package/lib/core/plugins/setupAuth.js +12 -11
- package/lib/core/plugins/setupUserRoutes.js +2 -2
- package/lib/core/plugins/token.js +4 -3
- package/lib/core/schemes/SASTokenScheme.js +4 -3
- package/lib/index.js +0 -1
- package/package.json +4 -80
package/lib/cli.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
2
3
|
/*
|
|
3
4
|
* Copyright © 2019, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
|
|
4
5
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
6
|
*/
|
|
6
|
-
"use strict";
|
|
7
|
-
|
|
8
7
|
var rafServer = require('./index.js');
|
|
9
8
|
rafServer.icli(null, true, null);
|
package/lib/core/config.js
CHANGED
|
@@ -25,6 +25,12 @@ exports["default"] = void 0;
|
|
|
25
25
|
var _parseDocker = _interopRequireDefault(require("./parseDocker"));
|
|
26
26
|
var _debug = _interopRequireDefault(require("debug"));
|
|
27
27
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
28
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
29
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
30
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
31
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
32
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
33
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
28
34
|
var fs = require('fs');
|
|
29
35
|
var configDebug = (0, _debug["default"])('config');
|
|
30
36
|
function config(appEnv, dockerFile) {
|
|
@@ -82,12 +88,18 @@ function iconfig(appEnv) {
|
|
|
82
88
|
var d = data.split(/\r?\n/);
|
|
83
89
|
d.forEach(function (l) {
|
|
84
90
|
if (l.length > 0 && l.indexOf('#') === -1) {
|
|
85
|
-
var
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
91
|
+
var _l$split = l.split('='),
|
|
92
|
+
_l$split2 = _slicedToArray(_l$split, 2),
|
|
93
|
+
envName = _l$split2[0],
|
|
94
|
+
value = _l$split2[1];
|
|
95
|
+
if (value.trim().length > 0) {
|
|
96
|
+
if (value.startsWith('$')) {
|
|
97
|
+
var envVar = value.substring(1);
|
|
98
|
+
value = process.env[envVar];
|
|
99
|
+
}
|
|
100
|
+
process.env[envName] = value;
|
|
89
101
|
}
|
|
90
|
-
configDebug(
|
|
102
|
+
configDebug(envName, '=', value);
|
|
91
103
|
}
|
|
92
104
|
});
|
|
93
105
|
} catch (err) {
|
|
@@ -20,7 +20,7 @@ function codeAuth(_x, _x2, _x3) {
|
|
|
20
20
|
}
|
|
21
21
|
function _codeAuth() {
|
|
22
22
|
_codeAuth = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(req, h, options) {
|
|
23
|
-
var indexHTML;
|
|
23
|
+
var cookieResult, indexHTML;
|
|
24
24
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
25
25
|
while (1) switch (_context.prev = _context.next) {
|
|
26
26
|
case 0:
|
|
@@ -28,29 +28,33 @@ function _codeAuth() {
|
|
|
28
28
|
_context.next = 3;
|
|
29
29
|
return (0, _setCookies["default"])(req, h, options);
|
|
30
30
|
case 3:
|
|
31
|
-
|
|
31
|
+
cookieResult = _context.sent;
|
|
32
|
+
console.log('cookieResult:', cookieResult);
|
|
33
|
+
debug('options', options);
|
|
32
34
|
indexHTML = process.env.APPENTRY == null ? 'index.html' : process.env.APPENTRY;
|
|
33
|
-
|
|
35
|
+
debug('indexHTML', indexHTML);
|
|
36
|
+
if (process.env.REDIRECT !== undefined) {
|
|
37
|
+
debug('..redirect', process.env.REDIRECT);
|
|
34
38
|
debug('using REDIRECT env variable', process.env.REDIRECT);
|
|
35
39
|
indexHTML = process.env.REDIRECT;
|
|
36
40
|
}
|
|
37
|
-
|
|
41
|
+
debug('..................', indexHTML);
|
|
42
|
+
debugger;
|
|
38
43
|
if (!(indexHTML.indexOf('/') === 0)) {
|
|
39
|
-
_context.next =
|
|
44
|
+
_context.next = 16;
|
|
40
45
|
break;
|
|
41
46
|
}
|
|
42
47
|
// added to support create-react-restaf-viya-app cli
|
|
43
48
|
if (indexHTML !== '/develop') {
|
|
44
|
-
|
|
49
|
+
/* hmr support */
|
|
50
|
+
indexHTML = "/".concat(process.env.APPNAME, "/").concat(indexHTML);
|
|
45
51
|
}
|
|
46
|
-
console.log("Redirecting to ".concat(indexHTML));
|
|
47
52
|
return _context.abrupt("return", h.redirect(indexHTML));
|
|
48
|
-
case 13:
|
|
49
|
-
console.log("Redirecting to ".concat(indexHTML));
|
|
50
|
-
return _context.abrupt("return", h.file(indexHTML));
|
|
51
|
-
case 15:
|
|
52
|
-
;
|
|
53
53
|
case 16:
|
|
54
|
+
// return h.file(indexHTML);
|
|
55
|
+
console.log('redirecting to :', "/".concat(indexHTML));
|
|
56
|
+
return _context.abrupt("return", h.file(indexHTML));
|
|
57
|
+
case 18:
|
|
54
58
|
case "end":
|
|
55
59
|
return _context.stop();
|
|
56
60
|
}
|
|
@@ -13,54 +13,84 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
|
|
|
13
13
|
* Copyright © 2019, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
|
|
14
14
|
* SPDX-License-Identifier: Apache-2.0
|
|
15
15
|
*/
|
|
16
|
-
var debug = require(
|
|
16
|
+
var debug = require("debug")("getapp");
|
|
17
17
|
function getApp(_x, _x2, _x3) {
|
|
18
18
|
return _getApp.apply(this, arguments);
|
|
19
19
|
}
|
|
20
20
|
function _getApp() {
|
|
21
|
-
_getApp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
22
|
-
var
|
|
23
|
-
return _regeneratorRuntime().wrap(function
|
|
24
|
-
while (1) switch (
|
|
21
|
+
_getApp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options, req, h) {
|
|
22
|
+
var authType, indexHTML, handleImplicit, _handleImplicit;
|
|
23
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
24
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
25
25
|
case 0:
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
_handleImplicit = function _handleImplicit3() {
|
|
27
|
+
_handleImplicit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options, req, h) {
|
|
28
|
+
var x, redirect, redirectUri, protocol, url;
|
|
29
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
30
|
+
while (1) switch (_context.prev = _context.next) {
|
|
31
|
+
case 0:
|
|
32
|
+
if (!(process.env.AUTHFLOW === "implicit")) {
|
|
33
|
+
_context.next = 8;
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
x = "".concat(process.env.VIYA_SERVER, "/SASLogon/oauth/authorize?response_type=token&client_id=").concat(process.env.CLIENTID);
|
|
37
|
+
redirect = "".concat(process.env.APPNAME, "/callback");
|
|
38
|
+
if (process.env.REDIRECT != null) {
|
|
39
|
+
redirect = process.env.REDIRECT.trim();
|
|
40
|
+
if (redirect.indexOf("http") === -1) {
|
|
41
|
+
redirect = "".concat(process.env.APPNAME, "/").concat(redirect);
|
|
42
|
+
protocol = process.env.HTTPS === "true" ? "https://" : "http://";
|
|
43
|
+
redirectUri = "".concat(protocol).concat(process.env.APPHOST, ":").concat(process.env.APPPORT, "/").concat(redirect, "?host=").concat(process.env.VIYA_SERVER);
|
|
44
|
+
} else {
|
|
45
|
+
redirectUri = "".concat(redirect, "?host=").concat(process.env.VIYA_SERVER);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
debug(process.env.REDIRECT);
|
|
49
|
+
url = "".concat(x, "&redirect_uri=").concat(redirectUri);
|
|
50
|
+
debug(url);
|
|
51
|
+
return _context.abrupt("return", h.redirect(url));
|
|
52
|
+
case 8:
|
|
53
|
+
case "end":
|
|
54
|
+
return _context.stop();
|
|
55
|
+
}
|
|
56
|
+
}, _callee);
|
|
57
|
+
}));
|
|
58
|
+
return _handleImplicit.apply(this, arguments);
|
|
59
|
+
};
|
|
60
|
+
handleImplicit = function _handleImplicit2(_x4, _x5, _x6) {
|
|
61
|
+
return _handleImplicit.apply(this, arguments);
|
|
62
|
+
};
|
|
63
|
+
debugger;
|
|
64
|
+
;
|
|
65
|
+
authType = process.env.AUTHFLOW.trim();
|
|
66
|
+
if (!(authType === "implicit")) {
|
|
67
|
+
_context2.next = 9;
|
|
28
68
|
break;
|
|
29
69
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
protocol = process.env.HTTPS === 'true' ? 'https://' : 'http://';
|
|
37
|
-
redirectUri = "".concat(protocol).concat(process.env.APPHOST, ":").concat(process.env.APPPORT, "/").concat(redirect, "?host=").concat(process.env.VIYA_SERVER);
|
|
38
|
-
} else {
|
|
39
|
-
redirectUri = "".concat(redirect, "?host=").concat(process.env.VIYA_SERVER);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
debug(process.env.REDIRECT);
|
|
43
|
-
url = "".concat(x, "&redirect_uri=").concat(redirectUri);
|
|
44
|
-
debug(url);
|
|
45
|
-
return _context.abrupt("return", h.redirect(url));
|
|
46
|
-
case 10:
|
|
47
|
-
if (!(process.env.AUTHFLOW === 'server')) {
|
|
48
|
-
_context.next = 16;
|
|
70
|
+
debugger;
|
|
71
|
+
debug("calling handleImplicit");
|
|
72
|
+
return _context2.abrupt("return", handleImplicit(options, req, h));
|
|
73
|
+
case 9:
|
|
74
|
+
if (!(authType === "server")) {
|
|
75
|
+
_context2.next = 14;
|
|
49
76
|
break;
|
|
50
77
|
}
|
|
51
78
|
debugger;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
79
|
+
return _context2.abrupt("return", (0, _codeAuth["default"])(req, h, options));
|
|
80
|
+
case 14:
|
|
81
|
+
if (!(authType === null)) {
|
|
82
|
+
_context2.next = 18;
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
/* case of no auth */
|
|
86
|
+
indexHTML = process.env.APPENTRY == null ? "index.html" : process.env.APPENTRY;
|
|
57
87
|
console.log("Redirecting to default ".concat(indexHTML));
|
|
58
|
-
return
|
|
59
|
-
case
|
|
88
|
+
return _context2.abrupt("return", h.file(indexHTML));
|
|
89
|
+
case 18:
|
|
60
90
|
case "end":
|
|
61
|
-
return
|
|
91
|
+
return _context2.stop();
|
|
62
92
|
}
|
|
63
|
-
},
|
|
93
|
+
}, _callee2);
|
|
64
94
|
}));
|
|
65
95
|
return _getApp.apply(this, arguments);
|
|
66
96
|
}
|
|
@@ -22,23 +22,24 @@ function _getUser() {
|
|
|
22
22
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
23
23
|
while (1) switch (_context.prev = _context.next) {
|
|
24
24
|
case 0:
|
|
25
|
+
debugger;
|
|
25
26
|
debug(req.state);
|
|
26
27
|
name = 'SAS User';
|
|
27
28
|
if (!(req.state.ocookie != null)) {
|
|
28
|
-
_context.next =
|
|
29
|
+
_context.next = 10;
|
|
29
30
|
break;
|
|
30
31
|
}
|
|
31
32
|
sid = req.state.ocookie.sid;
|
|
32
33
|
debug(sid);
|
|
33
|
-
_context.next =
|
|
34
|
+
_context.next = 8;
|
|
34
35
|
return req.server.app.cache.get(sid);
|
|
35
|
-
case
|
|
36
|
+
case 8:
|
|
36
37
|
credentials = _context.sent;
|
|
37
38
|
name = credentials.user_name;
|
|
38
|
-
case
|
|
39
|
+
case 10:
|
|
39
40
|
debug(name);
|
|
40
41
|
return _context.abrupt("return", "let USER_NAME='".concat(name, "'"));
|
|
41
|
-
case
|
|
42
|
+
case 12:
|
|
42
43
|
case "end":
|
|
43
44
|
return _context.stop();
|
|
44
45
|
}
|
|
@@ -14,8 +14,8 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
14
14
|
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; }
|
|
15
15
|
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; }
|
|
16
16
|
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; }
|
|
17
|
-
function _toPropertyKey(
|
|
18
|
-
function _toPrimitive(
|
|
17
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
18
|
+
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); }
|
|
19
19
|
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; }
|
|
20
20
|
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); } }
|
|
21
21
|
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); }); }; }
|
|
@@ -52,6 +52,7 @@ function _refreshToken() {
|
|
|
52
52
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
53
53
|
while (1) switch (_context2.prev = _context2.next) {
|
|
54
54
|
case 0:
|
|
55
|
+
debugger;
|
|
55
56
|
credentials = req.auth.credentials;
|
|
56
57
|
sid = credentials.sid;
|
|
57
58
|
config = {
|
|
@@ -68,28 +69,28 @@ function _refreshToken() {
|
|
|
68
69
|
client_secret: process.env.CLIENTSECRET
|
|
69
70
|
})
|
|
70
71
|
};
|
|
71
|
-
_context2.prev =
|
|
72
|
-
_context2.next =
|
|
72
|
+
_context2.prev = 4;
|
|
73
|
+
_context2.next = 7;
|
|
73
74
|
return (0, _axios["default"])(config);
|
|
74
|
-
case
|
|
75
|
+
case 7:
|
|
75
76
|
r = _context2.sent;
|
|
76
77
|
newcred = _objectSpread({}, credentials);
|
|
77
78
|
newcred.token = r.data.access_token;
|
|
78
79
|
newcred.refreshToken = r.data.refresh_token;
|
|
79
|
-
_context2.next =
|
|
80
|
+
_context2.next = 13;
|
|
80
81
|
return req.server.app.cache.set(sid, credentials);
|
|
81
|
-
case
|
|
82
|
+
case 13:
|
|
82
83
|
return _context2.abrupt("return", credentials);
|
|
83
|
-
case
|
|
84
|
-
_context2.prev =
|
|
85
|
-
_context2.t0 = _context2["catch"](
|
|
84
|
+
case 16:
|
|
85
|
+
_context2.prev = 16;
|
|
86
|
+
_context2.t0 = _context2["catch"](4);
|
|
86
87
|
error = Boom.badRequest('Unable to refresh tokens in KeepAlive', JSON.stringify(_context2.t0, null, 4));
|
|
87
88
|
throw error;
|
|
88
|
-
case
|
|
89
|
+
case 20:
|
|
89
90
|
case "end":
|
|
90
91
|
return _context2.stop();
|
|
91
92
|
}
|
|
92
|
-
}, _callee2, null, [[
|
|
93
|
+
}, _callee2, null, [[4, 16]]);
|
|
93
94
|
}));
|
|
94
95
|
return _refreshToken.apply(this, arguments);
|
|
95
96
|
}
|
|
@@ -17,6 +17,7 @@ function _proxyMapUri() {
|
|
|
17
17
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
18
18
|
while (1) switch (_context.prev = _context.next) {
|
|
19
19
|
case 0:
|
|
20
|
+
debugger;
|
|
20
21
|
credentials = req.auth.credentials;
|
|
21
22
|
console.log('------------------------------------------');
|
|
22
23
|
if (credentials != null) {
|
|
@@ -37,7 +38,7 @@ function _proxyMapUri() {
|
|
|
37
38
|
return _context.abrupt("return", {
|
|
38
39
|
uri: uri
|
|
39
40
|
});
|
|
40
|
-
case
|
|
41
|
+
case 14:
|
|
41
42
|
case "end":
|
|
42
43
|
return _context.stop();
|
|
43
44
|
}
|
|
@@ -36,7 +36,7 @@ function _reactDev() {
|
|
|
36
36
|
while (1) switch (_context.prev = _context.next) {
|
|
37
37
|
case 0:
|
|
38
38
|
console.log('Spawning the dev server');
|
|
39
|
-
spawn('
|
|
39
|
+
spawn('npm', ['start:appjs'], {
|
|
40
40
|
stdio: 'inherit'
|
|
41
41
|
});
|
|
42
42
|
h2 = '<h2>Viya Server: ' + process.env.VIYA_SERVER + '<h2>';
|
|
@@ -19,14 +19,14 @@ function setCookies(_x, _x2, _x3) {
|
|
|
19
19
|
}
|
|
20
20
|
function _setCookies() {
|
|
21
21
|
_setCookies = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(req, h, options) {
|
|
22
|
-
var
|
|
22
|
+
var authCred, sid, credentials, redirect;
|
|
23
23
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
24
24
|
while (1) switch (_context.prev = _context.next) {
|
|
25
25
|
case 0:
|
|
26
|
-
|
|
26
|
+
authCred = req.auth.credentials;
|
|
27
27
|
debugger;
|
|
28
|
-
req.log('setcookie',
|
|
29
|
-
if (!(
|
|
28
|
+
req.log('setcookie', authCred);
|
|
29
|
+
if (!(authCred != null && req.auth.error != null)) {
|
|
30
30
|
_context.next = 6;
|
|
31
31
|
break;
|
|
32
32
|
}
|
|
@@ -38,33 +38,37 @@ function _setCookies() {
|
|
|
38
38
|
case 6:
|
|
39
39
|
// create a cookie(sid) and save credentials in cache
|
|
40
40
|
sid = uuid.v4();
|
|
41
|
-
credentials
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
credentials = {
|
|
42
|
+
token: authCred.token,
|
|
43
|
+
refreshToken: authCred.refreshToken,
|
|
44
|
+
sid: sid,
|
|
45
|
+
user_name: ''
|
|
46
|
+
};
|
|
47
|
+
if (process.env.USETOKEN === 'YES') {
|
|
48
|
+
options.allAppEnv.LOGONPAYLOAD.token = authCred.token;
|
|
44
49
|
options.allAppEnv.LOGONPAYLOAD.tokenType = 'bearer';
|
|
45
50
|
debug(options.allAppEnv.LOGONPAYLOAD);
|
|
46
51
|
}
|
|
47
52
|
_context.next = 11;
|
|
48
53
|
return req.server.app.cache.set(sid, credentials, 0);
|
|
49
54
|
case 11:
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
redirect = credentials.query != null && credentials.query.next != null ? credentials.query.next : null;
|
|
55
|
+
debugger;
|
|
56
|
+
console.log(h.request.auth);
|
|
57
|
+
debugger;
|
|
58
|
+
//req.cookieAuth.set({ sid });
|
|
59
|
+
|
|
60
|
+
debugger;
|
|
61
|
+
// await req.server.app.cache.set(sid, credentials);
|
|
62
|
+
debugger;
|
|
63
|
+
debug('authcred query:', authCred.query);
|
|
64
|
+
redirect = authCred.query != null && authCred.query.next != null ? credentials.query.next : null;
|
|
61
65
|
req.server.log('setcookie-redirect', redirect);
|
|
62
66
|
return _context.abrupt("return", {
|
|
63
67
|
status: true,
|
|
64
68
|
error: null,
|
|
65
69
|
redirect: redirect
|
|
66
70
|
});
|
|
67
|
-
case
|
|
71
|
+
case 20:
|
|
68
72
|
case "end":
|
|
69
73
|
return _context.stop();
|
|
70
74
|
}
|
package/lib/core/iService.js
CHANGED
|
@@ -11,8 +11,8 @@ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyri
|
|
|
11
11
|
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; }
|
|
12
12
|
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; }
|
|
13
13
|
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; }
|
|
14
|
-
function _toPropertyKey(
|
|
15
|
-
function _toPrimitive(
|
|
14
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
15
|
+
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); }
|
|
16
16
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
17
17
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
18
18
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
@@ -103,10 +103,11 @@ function iService(userRouteTable, useDefault, asset, allAppEnv, serverMode, user
|
|
|
103
103
|
};
|
|
104
104
|
if (process.env.HAPIDEBUG === 'YES') {
|
|
105
105
|
sConfig.debug = {
|
|
106
|
-
|
|
106
|
+
log: ['hapi'],
|
|
107
|
+
request: ['hapi']
|
|
107
108
|
};
|
|
108
109
|
}
|
|
109
|
-
debug(JSON.stringify(sConfig, null, 4));
|
|
110
|
+
debug('sConfig:', JSON.stringify(sConfig, null, 4));
|
|
110
111
|
if (!(process.env.HTTPS === 'true')) {
|
|
111
112
|
_context.next = 16;
|
|
112
113
|
break;
|
package/lib/core/index.js
CHANGED
|
@@ -27,10 +27,11 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
|
|
|
27
27
|
var debug = require("debug")("startup");
|
|
28
28
|
module.exports = function core(uTable, useDefault, serverMode, customize, swaggerfcn) {
|
|
29
29
|
var argv = require("yargs").argv;
|
|
30
|
+
debug(argv);
|
|
30
31
|
var env = argv.env == null ? null : argv.env;
|
|
31
32
|
var appenv = argv.appenv == null ? null : argv.appenv;
|
|
32
33
|
var docker = argv.docker == null ? null : argv.docker;
|
|
33
|
-
process.env.SERVERMODE = serverMode !== null ?
|
|
34
|
+
process.env.SERVERMODE = serverMode !== null ? process.env.SERVERMODE : "app";
|
|
34
35
|
if (useDefault == null) {
|
|
35
36
|
useDefault = true;
|
|
36
37
|
}
|
|
@@ -86,6 +87,7 @@ function createPayload(srcName, cb) {
|
|
|
86
87
|
function getAllEnv(userData) {
|
|
87
88
|
var env;
|
|
88
89
|
var l = null;
|
|
90
|
+
debugger;
|
|
89
91
|
if (process.env.AUTHTYPE != null) {
|
|
90
92
|
process.env.AUTHFLOW = process.env.AUTHTYPE;
|
|
91
93
|
}
|
|
@@ -94,7 +96,6 @@ function getAllEnv(userData) {
|
|
|
94
96
|
authflow = "server";
|
|
95
97
|
}
|
|
96
98
|
process.env.AUTHFLOW = authflow;
|
|
97
|
-
// let redirect = (process.env.REDIRECT != null) ? process.env.REDIRECT : null;
|
|
98
99
|
var redirect = trimit("REDIRECT");
|
|
99
100
|
var host = trimit("VIYA_SERVER");
|
|
100
101
|
var clientID = trimit("CLIENTID");
|
|
@@ -104,65 +105,59 @@ function getAllEnv(userData) {
|
|
|
104
105
|
var appName = trimit("APPNAME");
|
|
105
106
|
var ns = trimit("NAMESPACE");
|
|
106
107
|
var nsHost = trimit("NSHOST");
|
|
108
|
+
var appEntry = trimit("APPENTRY");
|
|
109
|
+
if (appEntry === null) {
|
|
110
|
+
appEntry = "index.html";
|
|
111
|
+
process.env.APPENTRY = appEntry;
|
|
112
|
+
}
|
|
113
|
+
;
|
|
107
114
|
l = {
|
|
108
115
|
authType: authflow,
|
|
109
116
|
redirect: redirect,
|
|
110
117
|
host: host,
|
|
111
118
|
clientID: clientID,
|
|
119
|
+
clientSecret: clientSecret,
|
|
112
120
|
appName: appName,
|
|
121
|
+
appEntry: appEntry,
|
|
113
122
|
keepAlive: null,
|
|
114
123
|
useToken: process.env.USETOKEN,
|
|
115
124
|
ns: ns,
|
|
116
125
|
nsHost: nsHost
|
|
117
126
|
};
|
|
118
|
-
if (authflow
|
|
127
|
+
if (authflow !== null) {
|
|
119
128
|
if (authflow === "implicit") {
|
|
120
129
|
if (redirect === null) {
|
|
121
130
|
redirect = "".concat(appName, "/callback");
|
|
122
|
-
|
|
123
|
-
} else {
|
|
124
|
-
if (redirect !== null && redirect.indexOf("/") !== 0) {
|
|
125
|
-
redirect = redirect.indexOf("http") != -1 ? redirect : "".concat(process.env.APPNAME, "/").concat(redirect);
|
|
126
|
-
}
|
|
131
|
+
;
|
|
127
132
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
clientID: clientID,
|
|
133
|
-
appName: appName,
|
|
134
|
-
keepAlive: null,
|
|
135
|
-
useToken: process.env.USETOKEN,
|
|
136
|
-
ns: ns,
|
|
137
|
-
nsHost: nsHost
|
|
138
|
-
};
|
|
139
|
-
if (authflow === "server" && keepAlive === "YES") {
|
|
140
|
-
var protocol = process.env.HTTPS === "true" ? "https://" : "http://";
|
|
141
|
-
l.keepAlive = "".concat(protocol).concat(process.env.APPHOST, ":").concat(process.env.APPPORT, "/").concat(appName, "/keepAlive");
|
|
142
|
-
l.keepAlive = l.keepAlive.replace(/0.0.0.0/, "localhost");
|
|
143
|
-
}
|
|
144
|
-
if (process.env.TIMERS != null) {
|
|
145
|
-
l.timers = process.env.TIMERS;
|
|
133
|
+
}
|
|
134
|
+
if (redirect !== null && redirect.indexOf("/") !== 0) {
|
|
135
|
+
if (redirect.indexOf("/") !== 0) {
|
|
136
|
+
redirect = redirect.indexOf("http") != -1 ? redirect : "".concat(process.env.APPNAME, "/").concat(redirect);
|
|
146
137
|
}
|
|
147
138
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
139
|
+
/*
|
|
140
|
+
if (redirect === null) {
|
|
141
|
+
redirect = `${appName}`;
|
|
142
|
+
}*/
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// process.env.REDIRECT = redirect;
|
|
146
|
+
console.log("Redirect: ".concat(redirect));
|
|
147
|
+
console.log(process.env.REDIRECT);
|
|
148
|
+
l.redirect = redirect;
|
|
149
|
+
if (authflow === "server" && keepAlive === "YES") {
|
|
150
|
+
var protocol = process.env.HTTPS === "true" ? "https://" : "http://";
|
|
151
|
+
l.keepAlive = "".concat(protocol).concat(process.env.APPHOST, ":").concat(process.env.APPPORT, "/").concat(appName, "/keepAlive");
|
|
152
|
+
l.keepAlive = l.keepAlive.replace(/0.0.0.0/, "localhost");
|
|
153
|
+
}
|
|
154
|
+
if (process.env.TIMERS != null) {
|
|
155
|
+
l.timers = process.env.TIMERS;
|
|
160
156
|
}
|
|
161
157
|
|
|
162
158
|
// pick up the app env's - replacement for appenv.js
|
|
163
159
|
// appenv.js still supported for backward compatibility
|
|
164
160
|
for (var key in process.env) {
|
|
165
|
-
debug(key);
|
|
166
161
|
if (key.indexOf("APPENV_") === 0) {
|
|
167
162
|
var k = key.substring(7);
|
|
168
163
|
var v = process.env[key];
|
|
@@ -181,7 +176,7 @@ function getAllEnv(userData) {
|
|
|
181
176
|
}
|
|
182
177
|
function trimit(e) {
|
|
183
178
|
var a = process.env[e];
|
|
184
|
-
if (a
|
|
179
|
+
if (a === undefined) {
|
|
185
180
|
return null;
|
|
186
181
|
}
|
|
187
182
|
a = a.trim();
|
|
@@ -62,8 +62,17 @@ function _iSASauth() {
|
|
|
62
62
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
63
63
|
while (1) switch (_context.prev = _context.next) {
|
|
64
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;
|
|
65
74
|
server.log('SASAuth profile', credentials);
|
|
66
|
-
case
|
|
75
|
+
case 7:
|
|
67
76
|
case "end":
|
|
68
77
|
return _context.stop();
|
|
69
78
|
}
|
|
@@ -5,6 +5,7 @@ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyri
|
|
|
5
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
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
7
|
var uuid = require('uuid');
|
|
8
|
+
var debug = require('debug')('appcookie');
|
|
8
9
|
module.exports = /*#__PURE__*/function () {
|
|
9
10
|
var _appCookie = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(server, options) {
|
|
10
11
|
var cookieOptions;
|
|
@@ -31,16 +32,19 @@ module.exports = /*#__PURE__*/function () {
|
|
|
31
32
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
32
33
|
while (1) switch (_context.prev = _context.next) {
|
|
33
34
|
case 0:
|
|
35
|
+
debugger;
|
|
36
|
+
debug('in validateFunc');
|
|
37
|
+
debug(req.path);
|
|
34
38
|
server.log('Cookie validateFunc', "path - ".concat(req.path));
|
|
35
39
|
if (!(session == null)) {
|
|
36
|
-
_context.next =
|
|
40
|
+
_context.next = 7;
|
|
37
41
|
break;
|
|
38
42
|
}
|
|
39
43
|
console.log('session is null');
|
|
40
44
|
return _context.abrupt("return", {
|
|
41
45
|
valid: false
|
|
42
46
|
});
|
|
43
|
-
case
|
|
47
|
+
case 7:
|
|
44
48
|
credentials = null;
|
|
45
49
|
if (Array.isArray(session) === true && session.length > 0) {
|
|
46
50
|
sid = session[0].sid;
|
|
@@ -48,28 +52,29 @@ module.exports = /*#__PURE__*/function () {
|
|
|
48
52
|
sid = session.sid;
|
|
49
53
|
}
|
|
50
54
|
if (!(sid != null)) {
|
|
51
|
-
_context.next =
|
|
55
|
+
_context.next = 13;
|
|
52
56
|
break;
|
|
53
57
|
}
|
|
54
|
-
_context.next =
|
|
58
|
+
_context.next = 12;
|
|
55
59
|
return req.server.app.cache.get(sid);
|
|
56
|
-
case
|
|
60
|
+
case 12:
|
|
57
61
|
credentials = _context.sent;
|
|
58
|
-
case
|
|
62
|
+
case 13:
|
|
59
63
|
if (!(credentials == null)) {
|
|
60
|
-
_context.next =
|
|
64
|
+
_context.next = 15;
|
|
61
65
|
break;
|
|
62
66
|
}
|
|
63
67
|
return _context.abrupt("return", {
|
|
64
68
|
valid: false
|
|
65
69
|
});
|
|
66
|
-
case
|
|
70
|
+
case 15:
|
|
67
71
|
server.log('Cookie validateFunc', sid);
|
|
72
|
+
debug(sid);
|
|
68
73
|
return _context.abrupt("return", {
|
|
69
74
|
valid: true,
|
|
70
75
|
credentials: credentials
|
|
71
76
|
});
|
|
72
|
-
case
|
|
77
|
+
case 18:
|
|
73
78
|
case "end":
|
|
74
79
|
return _context.stop();
|
|
75
80
|
}
|
|
@@ -82,8 +87,9 @@ module.exports = /*#__PURE__*/function () {
|
|
|
82
87
|
}()
|
|
83
88
|
}; // console.log('cookie options', cookieOptions);
|
|
84
89
|
server.log('Cookie Options', cookieOptions);
|
|
90
|
+
debug('Cookie Options', cookieOptions);
|
|
85
91
|
server.auth.strategy('session', 'cookie', cookieOptions);
|
|
86
|
-
case
|
|
92
|
+
case 6:
|
|
87
93
|
case "end":
|
|
88
94
|
return _context2.stop();
|
|
89
95
|
}
|
|
@@ -35,6 +35,7 @@ function _setContext() {
|
|
|
35
35
|
while (1) switch (_context.prev = _context.next) {
|
|
36
36
|
case 0:
|
|
37
37
|
credentials = req.auth.credentials;
|
|
38
|
+
debugger;
|
|
38
39
|
context = {
|
|
39
40
|
path: req.path,
|
|
40
41
|
params: req.params,
|
|
@@ -44,7 +45,7 @@ function _setContext() {
|
|
|
44
45
|
host: process.env.VIYA_SERVER
|
|
45
46
|
};
|
|
46
47
|
return _context.abrupt("return", context);
|
|
47
|
-
case
|
|
48
|
+
case 4:
|
|
48
49
|
case "end":
|
|
49
50
|
return _context.stop();
|
|
50
51
|
}
|
|
@@ -5,8 +5,8 @@ var _handlers = require("../handlers");
|
|
|
5
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
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
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(
|
|
9
|
-
function _toPrimitive(
|
|
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
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
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
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); }); }; } /*
|
|
@@ -42,7 +42,11 @@ module.exports = function setDefaultRoutes(server, options) {
|
|
|
42
42
|
strategy: 'sas'
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
|
-
|
|
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);
|
|
46
50
|
server.log('Default strategy', authDefault);
|
|
47
51
|
server.log('Logon strategy', authLogon);
|
|
48
52
|
options.authDefault = authDefault;
|
|
@@ -111,6 +115,14 @@ module.exports = function setDefaultRoutes(server, options) {
|
|
|
111
115
|
cors: true,
|
|
112
116
|
handler: _handlers.reactDev
|
|
113
117
|
}
|
|
118
|
+
}, {
|
|
119
|
+
method: ['GET'],
|
|
120
|
+
path: "".concat(appName, "/develop"),
|
|
121
|
+
options: {
|
|
122
|
+
auth: false,
|
|
123
|
+
cors: true,
|
|
124
|
+
handler: _handlers.reactDev
|
|
125
|
+
}
|
|
114
126
|
}, {
|
|
115
127
|
method: ['GET'],
|
|
116
128
|
path: "".concat(appName, "/logon"),
|
|
@@ -185,15 +197,38 @@ module.exports = function setDefaultRoutes(server, options) {
|
|
|
185
197
|
method: ['GET'],
|
|
186
198
|
path: "".concat(appName, "/{param*}"),
|
|
187
199
|
options: {
|
|
188
|
-
auth:
|
|
189
|
-
|
|
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
|
+
}
|
|
190
213
|
}
|
|
191
214
|
}, {
|
|
192
215
|
method: ['GET'],
|
|
193
216
|
path: "/{param*}",
|
|
194
217
|
options: {
|
|
195
|
-
auth:
|
|
218
|
+
auth: authLogon,
|
|
196
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
|
+
*/
|
|
197
232
|
}
|
|
198
233
|
}, {
|
|
199
234
|
method: ['GET'],
|
|
@@ -44,37 +44,38 @@ function _setupAuth() {
|
|
|
44
44
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
45
45
|
while (1) switch (_context.prev = _context.next) {
|
|
46
46
|
case 0:
|
|
47
|
+
debugger;
|
|
47
48
|
if (!(options.authFlow === 'server')) {
|
|
48
|
-
_context.next =
|
|
49
|
+
_context.next = 13;
|
|
49
50
|
break;
|
|
50
51
|
}
|
|
51
|
-
_context.next =
|
|
52
|
+
_context.next = 4;
|
|
52
53
|
return server.register({
|
|
53
54
|
plugin: SASauth,
|
|
54
55
|
options: options
|
|
55
56
|
});
|
|
56
|
-
case
|
|
57
|
-
_context.next =
|
|
57
|
+
case 4:
|
|
58
|
+
_context.next = 6;
|
|
58
59
|
return appCookie(server, options);
|
|
59
|
-
case
|
|
60
|
+
case 6:
|
|
60
61
|
def = 'session';
|
|
61
62
|
if (!(options.serverMode === 'api')) {
|
|
62
|
-
_context.next =
|
|
63
|
+
_context.next = 11;
|
|
63
64
|
break;
|
|
64
65
|
}
|
|
65
|
-
_context.next =
|
|
66
|
+
_context.next = 10;
|
|
66
67
|
return server.register({
|
|
67
68
|
plugin: token
|
|
68
69
|
});
|
|
69
|
-
case 9:
|
|
70
|
-
def = 'token';
|
|
71
70
|
case 10:
|
|
71
|
+
def = 'token';
|
|
72
|
+
case 11:
|
|
72
73
|
server.log('***********************Default auth', def);
|
|
73
74
|
server.auth["default"](def);
|
|
74
75
|
// console.log(server.registerations);
|
|
75
|
-
case 12:
|
|
76
|
-
setDefaultRoutes(server, options);
|
|
77
76
|
case 13:
|
|
77
|
+
setDefaultRoutes(server, options);
|
|
78
|
+
case 14:
|
|
78
79
|
case "end":
|
|
79
80
|
return _context.stop();
|
|
80
81
|
}
|
|
@@ -10,8 +10,8 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
|
|
|
10
10
|
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; }
|
|
11
11
|
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; }
|
|
12
12
|
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; }
|
|
13
|
-
function _toPropertyKey(
|
|
14
|
-
function _toPrimitive(
|
|
13
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
14
|
+
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); } /*
|
|
15
15
|
* ------------------------------------------------------------------------------------
|
|
16
16
|
* Copyright (c) SAS Institute Inc.
|
|
17
17
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -17,11 +17,12 @@ function _itoken() {
|
|
|
17
17
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
18
18
|
while (1) switch (_context.prev = _context.next) {
|
|
19
19
|
case 0:
|
|
20
|
-
|
|
20
|
+
debugger;
|
|
21
|
+
_context.next = 3;
|
|
21
22
|
return server.auth.scheme('SAStoken', require('../schemes/SASTokenScheme'));
|
|
22
|
-
case 2:
|
|
23
|
-
server.auth.strategy('token', 'SAStoken');
|
|
24
23
|
case 3:
|
|
24
|
+
server.auth.strategy('token', 'SAStoken');
|
|
25
|
+
case 4:
|
|
25
26
|
case "end":
|
|
26
27
|
return _context.stop();
|
|
27
28
|
}
|
|
@@ -39,14 +39,15 @@ module.exports = function SASTokenScheme(server, options) {
|
|
|
39
39
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
40
40
|
while (1) switch (_context.prev = _context.next) {
|
|
41
41
|
case 0:
|
|
42
|
+
debugger;
|
|
42
43
|
authorization = request.headers.authorization;
|
|
43
44
|
server.log('SASToken', authorization);
|
|
44
45
|
if (authorization) {
|
|
45
|
-
_context.next =
|
|
46
|
+
_context.next = 5;
|
|
46
47
|
break;
|
|
47
48
|
}
|
|
48
49
|
throw Boom.unauthorized(null, 'session');
|
|
49
|
-
case
|
|
50
|
+
case 5:
|
|
50
51
|
_authorization$split = authorization.split(' '), _authorization$split2 = _slicedToArray(_authorization$split, 2), tokenType = _authorization$split2[0], token = _authorization$split2[1];
|
|
51
52
|
credentials = {
|
|
52
53
|
token: token,
|
|
@@ -55,7 +56,7 @@ module.exports = function SASTokenScheme(server, options) {
|
|
|
55
56
|
return _context.abrupt("return", h.authenticated({
|
|
56
57
|
credentials: credentials
|
|
57
58
|
}));
|
|
58
|
-
case
|
|
59
|
+
case 8:
|
|
59
60
|
case "end":
|
|
60
61
|
return _context.stop();
|
|
61
62
|
}
|
package/lib/index.js
CHANGED
|
@@ -23,7 +23,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
23
23
|
});
|
|
24
24
|
exports.icli = icli;
|
|
25
25
|
var core = require('./core');
|
|
26
|
-
|
|
27
26
|
// silly but a jump point to keep backward compatibility
|
|
28
27
|
function icli(uTable, useDefault, customize) {
|
|
29
28
|
core(uTable, useDefault, null, customize);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sassoftware/viya-serverjs",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "App server for Custom Viya Applications",
|
|
5
5
|
"author": "Deva Kumaraswamy <deva.kumar@sas.com>",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -26,87 +26,11 @@
|
|
|
26
26
|
"bugs": {
|
|
27
27
|
"url": "https://github.com/sassoftware/viya-servers/issues"
|
|
28
28
|
},
|
|
29
|
-
"bin": {
|
|
30
|
-
"@sassoftware/viya-appserverjs": "./lib/cli.js"
|
|
31
|
-
},
|
|
32
29
|
"unpkg": "./lib/index.js",
|
|
33
30
|
"scripts": {
|
|
34
31
|
"build": "rimraf -rf lib && babel src --out-dir lib",
|
|
35
|
-
"pub": "npm publish --tag
|
|
36
|
-
"lint": "npx eslint --fix src/*.js"
|
|
37
|
-
"start:appjs": "cd packages/examples/apptest && npm run start",
|
|
38
|
-
"start:appjsi": "cd packages/examples/apptesti && npm run start",
|
|
39
|
-
"start:proxy": "cd packages/examples/proxytest && npm run start",
|
|
40
|
-
"start:apijs": "cd packages/examples/apitest && npm run start",
|
|
41
|
-
"debug:appjs": "cd packages/examples/apptest && npm run debug",
|
|
42
|
-
"puball": "npm publish --tag next --access public",
|
|
43
|
-
"format": "prettier-eslint --eslint-config-path ./.eslintrc.json --write '**/*.js'"
|
|
44
|
-
},
|
|
45
|
-
"dependencies": {
|
|
46
|
-
"@hapi/bell": "^12.3.0",
|
|
47
|
-
"@hapi/boom": "^9.1.4",
|
|
48
|
-
"@hapi/cookie": "^11.0.2",
|
|
49
|
-
"@hapi/h2o2": "^9.1.0",
|
|
50
|
-
"@hapi/hapi": "^21.3.2",
|
|
51
|
-
"@hapi/inert": "^6.0.5",
|
|
52
|
-
"@hapi/vision": "^6.1.0",
|
|
53
|
-
"axios": "^0.26.1",
|
|
54
|
-
"core-js": "^3.22.2",
|
|
55
|
-
"cross-spawn": "^7.0.3",
|
|
56
|
-
"debug": "^4.3.4",
|
|
57
|
-
"docker-file-parser": "^1.0.7",
|
|
58
|
-
"eslint-config-prettier": "^8.5.0",
|
|
59
|
-
"handlebars": "^4.7.7",
|
|
60
|
-
"hapi-require-https": "^5.0.0",
|
|
61
|
-
"joi": "^17.6.0",
|
|
62
|
-
"jwt-decode": "^3.1.2",
|
|
63
|
-
"node-cache-promise": "^1.0.2",
|
|
64
|
-
"only": "0.0.2",
|
|
65
|
-
"qs": "^6.10.3",
|
|
66
|
-
"regenerator-runtime": "^0.13.9",
|
|
67
|
-
"request-debug": "^0.2.0",
|
|
68
|
-
"selfsigned": "^2.0.1",
|
|
69
|
-
"uuid": "^8.3.2",
|
|
70
|
-
"yargs": "17.4.1"
|
|
71
|
-
},
|
|
72
|
-
"devDependencies": {
|
|
73
|
-
"@babel/cli": "^7.17.6",
|
|
74
|
-
"@babel/core": "^7.17.9",
|
|
75
|
-
"@babel/eslint-parser": "7.17.0",
|
|
76
|
-
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
77
|
-
"@babel/plugin-proposal-decorators": "^7.17.9",
|
|
78
|
-
"@babel/plugin-proposal-do-expressions": "^7.16.7",
|
|
79
|
-
"@babel/plugin-proposal-export-default-from": "^7.16.7",
|
|
80
|
-
"@babel/plugin-proposal-export-namespace-from": "^7.16.7",
|
|
81
|
-
"@babel/plugin-proposal-function-bind": "^7.16.7",
|
|
82
|
-
"@babel/plugin-proposal-function-sent": "^7.16.7",
|
|
83
|
-
"@babel/plugin-proposal-json-strings": "^7.16.7",
|
|
84
|
-
"@babel/plugin-proposal-logical-assignment-operators": "^7.16.7",
|
|
85
|
-
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.7",
|
|
86
|
-
"@babel/plugin-proposal-numeric-separator": "^7.16.7",
|
|
87
|
-
"@babel/plugin-proposal-object-rest-spread": "^7.17.3",
|
|
88
|
-
"@babel/plugin-proposal-optional-chaining": "^7.16.7",
|
|
89
|
-
"@babel/plugin-proposal-pipeline-operator": "^7.17.6",
|
|
90
|
-
"@babel/plugin-proposal-throw-expressions": "^7.16.7",
|
|
91
|
-
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
92
|
-
"@babel/plugin-syntax-import-meta": "^7.10.4",
|
|
93
|
-
"@babel/plugin-transform-regenerator": "^7.17.9",
|
|
94
|
-
"@babel/plugin-transform-runtime": "^7.17.0",
|
|
95
|
-
"@babel/plugin-transform-spread": "^7.16.7",
|
|
96
|
-
"@babel/plugin-transform-strict-mode": "^7.16.7",
|
|
97
|
-
"@babel/preset-env": "^7.16.11",
|
|
98
|
-
"cross-env": "^7.0.3",
|
|
99
|
-
"eslint": "^8.14.0",
|
|
100
|
-
"prettier": "^2.6.2",
|
|
101
|
-
"rimraf": "^3.0.2",
|
|
102
|
-
"shx": "^0.3.4"
|
|
103
|
-
},
|
|
104
|
-
"resolutions": {
|
|
105
|
-
"core-js": "3.21.1",
|
|
106
|
-
"node-forge": ">=1.0.0",
|
|
107
|
-
"underscore": "1.13.1",
|
|
108
|
-
"trim-newlines": "3.0.1",
|
|
109
|
-
"glob-parent": ">=5.1.2",
|
|
110
|
-
"@braintree/sanitize-url": ">=6.0.0"
|
|
32
|
+
"pub": "npm publish --tag dev --access public",
|
|
33
|
+
"lint": "npx eslint --fix src/*.js"
|
|
111
34
|
}
|
|
35
|
+
|
|
112
36
|
}
|