@sassoftware/viya-serverjs 0.3.0 → 0.5.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/.babelrc +6 -6
- package/.dockerignore +2 -2
- package/.env +42 -28
- package/.env.server +32 -30
- package/.eslintignore +3 -3
- package/.eslintrc.json +42 -42
- package/Dockerfile +44 -44
- package/README.md +67 -99
- package/cli.js +9 -9
- package/lib/config.js +16 -16
- package/lib/handlers/appCallback.js +23 -24
- package/lib/handlers/codeAuth.js +17 -18
- package/lib/handlers/decodeJwt.js +3 -3
- package/lib/handlers/favicon.js +22 -25
- package/lib/handlers/getApp.js +20 -21
- package/lib/handlers/getApp2.js +22 -25
- package/lib/handlers/getUser.js +14 -17
- package/lib/handlers/index.js +3 -3
- package/lib/handlers/keepAlive.js +28 -31
- package/lib/handlers/keepAlive2.js +9 -12
- package/lib/handlers/logon.js +12 -15
- package/lib/handlers/logout.js +24 -28
- package/lib/handlers/proxyMapUri.js +6 -11
- package/lib/handlers/proxyOnResponse.js +6 -7
- package/lib/handlers/reactDev.js +22 -25
- package/lib/handlers/setCookies.js +51 -53
- package/lib/iService.js +105 -103
- package/lib/index.js +25 -30
- package/lib/parseDocker.js +3 -3
- package/lib/plugins/SASauth.js +34 -34
- package/lib/plugins/appCookie.js +35 -38
- package/lib/plugins/setContext.js +22 -25
- package/lib/plugins/setDefaultRoutes.js +71 -59
- package/lib/plugins/setupAuth.js +35 -38
- package/lib/plugins/setupUserRoutes.js +17 -16
- package/lib/plugins/token.js +9 -10
- package/lib/schemes/SASTokenScheme.js +24 -27
- package/mcpServer.js +364 -0
- package/package.json +85 -79
- package/public/data/Cluster_SDOH1.sas +181 -181
- package/public/data/Cluster_SDOH6.sas +179 -179
- package/public/data/NeuralNetwork_High_med.sas +2408 -2408
- package/public/data/NeuralNetwork_high_med1.sas +2408 -2408
- package/public/data/cars.csv +429 -429
- package/public/data/cmdList.txt +15 -15
- package/public/data/iris.csv +151 -151
- package/public/index.html +360 -350
- package/public/indexProxy.html +351 -351
- package/public/simplesubmit.html +233 -0
- package/server.js +363 -362
- package/src/config.js +90 -90
- package/src/handlers/appCallback.js +40 -40
- package/src/handlers/codeAuth.js +31 -31
- package/src/handlers/decodeJwt.js +10 -10
- package/src/handlers/favicon.js +23 -23
- package/src/handlers/getApp.js +52 -52
- package/src/handlers/getApp2.js +25 -25
- package/src/handlers/getUser.js +20 -20
- package/src/handlers/index.js +36 -36
- package/src/handlers/keepAlive.js +53 -53
- package/src/handlers/keepAlive2.js +12 -12
- package/src/handlers/logon.js +23 -23
- package/src/handlers/logout.js +42 -42
- package/src/handlers/proxyMapUri.js +25 -25
- package/src/handlers/proxyOnResponse.js +11 -11
- package/src/handlers/reactDev.js +29 -29
- package/src/handlers/setCookies.js +80 -79
- package/src/iService.js +360 -345
- package/src/index.js +247 -249
- package/src/parseDocker.js +32 -32
- package/src/plugins/SASauth.js +82 -78
- package/src/plugins/appCookie.js +50 -49
- package/src/plugins/setContext.js +33 -33
- package/src/plugins/setDefaultRoutes.js +261 -253
- package/src/plugins/setupAuth.js +49 -49
- package/src/plugins/setupUserRoutes.js +48 -47
- package/src/plugins/token.js +10 -10
- package/src/schemes/SASTokenScheme.js +43 -43
- package/src/visionIndex.html +23 -23
- package/start.sh +14 -14
- package/.env.proxy +0 -32
- package/tls/viyatls.sh +0 -3
|
@@ -2,29 +2,32 @@
|
|
|
2
2
|
|
|
3
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
4
|
var _handlers = require("../handlers");
|
|
5
|
+
var _setContext = _interopRequireDefault(require("./setContext"));
|
|
6
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
5
7
|
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
8
|
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
9
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
8
10
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
9
11
|
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
|
|
12
|
+
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
13
|
+
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
11
14
|
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
12
|
-
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; } /*
|
|
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
|
-
*
|
|
15
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; } /*
|
|
16
|
+
* ------------------------------------------------------------------------------------
|
|
17
|
+
* * Copyright (c) SAS Institute Inc.
|
|
18
|
+
* * Licensed under the Apache License, Version 2.0 (the "License");
|
|
19
|
+
* * you may not use this file except in compliance with the License.
|
|
20
|
+
* * You may obtain a copy of the License at
|
|
21
|
+
* *
|
|
22
|
+
* * http://www.apache.org/licenses/LICENSE-2.0
|
|
23
|
+
* *
|
|
24
|
+
* * Unless required by applicable law or agreed to in writing, software
|
|
25
|
+
* * distributed under the License is distributed on an "AS IS" BASIS,
|
|
26
|
+
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
27
|
+
* * See the License for the specific language governing permissions and
|
|
28
|
+
* limitations under the License.
|
|
29
|
+
* ----------------------------------------------------------------------------------------
|
|
30
|
+
*
|
|
28
31
|
*/
|
|
29
32
|
var debug = require("debug")("routes");
|
|
30
33
|
module.exports = function setDefaultRoutes(server, options) {
|
|
@@ -42,7 +45,7 @@ module.exports = function setDefaultRoutes(server, options) {
|
|
|
42
45
|
strategy: "sas"
|
|
43
46
|
};
|
|
44
47
|
}
|
|
45
|
-
var getAppb = _handlers.getApp.bind(null, process.env.USETOKEN === "
|
|
48
|
+
var getAppb = _handlers.getApp.bind(null, process.env.USETOKEN != null && process.env.USETOKEN.toUpperCase() === "TRUE" ? options : null);
|
|
46
49
|
console.log("Default strategy", authDefault);
|
|
47
50
|
console.log("Logon strategy", authLogon);
|
|
48
51
|
options.authDefault = authDefault;
|
|
@@ -65,18 +68,15 @@ module.exports = function setDefaultRoutes(server, options) {
|
|
|
65
68
|
}
|
|
66
69
|
},
|
|
67
70
|
handler: function () {
|
|
68
|
-
var _handler = _asyncToGenerator(/*#__PURE__*/
|
|
69
|
-
return
|
|
70
|
-
while (1) switch (_context.
|
|
71
|
+
var _handler = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(req, h) {
|
|
72
|
+
return _regenerator().w(function (_context) {
|
|
73
|
+
while (1) switch (_context.n) {
|
|
71
74
|
case 0:
|
|
72
75
|
debug('logonhandler', req.auth.credentials);
|
|
73
|
-
_context.
|
|
76
|
+
_context.n = 1;
|
|
74
77
|
return (0, _handlers.logon)(req, h);
|
|
75
|
-
case
|
|
76
|
-
return _context.
|
|
77
|
-
case 4:
|
|
78
|
-
case "end":
|
|
79
|
-
return _context.stop();
|
|
78
|
+
case 1:
|
|
79
|
+
return _context.a(2, _context.v);
|
|
80
80
|
}
|
|
81
81
|
}, _callee);
|
|
82
82
|
}));
|
|
@@ -99,14 +99,11 @@ module.exports = function setDefaultRoutes(server, options) {
|
|
|
99
99
|
options: {
|
|
100
100
|
auth: authDefault,
|
|
101
101
|
handler: function () {
|
|
102
|
-
var _handler2 = _asyncToGenerator(/*#__PURE__*/
|
|
103
|
-
return
|
|
104
|
-
while (1) switch (_context2.
|
|
102
|
+
var _handler2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(req, h) {
|
|
103
|
+
return _regenerator().w(function (_context2) {
|
|
104
|
+
while (1) switch (_context2.n) {
|
|
105
105
|
case 0:
|
|
106
|
-
return _context2.
|
|
107
|
-
case 1:
|
|
108
|
-
case "end":
|
|
109
|
-
return _context2.stop();
|
|
106
|
+
return _context2.a(2, h.redirect("".concat(appName, "/documentation")));
|
|
110
107
|
}
|
|
111
108
|
}, _callee2);
|
|
112
109
|
}));
|
|
@@ -151,10 +148,10 @@ module.exports = function setDefaultRoutes(server, options) {
|
|
|
151
148
|
options: {
|
|
152
149
|
auth: /*authDefault*/false,
|
|
153
150
|
handler: function () {
|
|
154
|
-
var _handler3 = _asyncToGenerator(/*#__PURE__*/
|
|
151
|
+
var _handler3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(req, h) {
|
|
155
152
|
var allAppEnv, uappenv, s;
|
|
156
|
-
return
|
|
157
|
-
while (1) switch (_context3.
|
|
153
|
+
return _regenerator().w(function (_context3) {
|
|
154
|
+
while (1) switch (_context3.n) {
|
|
158
155
|
case 0:
|
|
159
156
|
allAppEnv = options.allAppEnv;
|
|
160
157
|
if (options.userInfo != null) {
|
|
@@ -169,10 +166,7 @@ module.exports = function setDefaultRoutes(server, options) {
|
|
|
169
166
|
console.log(s);
|
|
170
167
|
}
|
|
171
168
|
debug(s);
|
|
172
|
-
return _context3.
|
|
173
|
-
case 7:
|
|
174
|
-
case "end":
|
|
175
|
-
return _context3.stop();
|
|
169
|
+
return _context3.a(2, s);
|
|
176
170
|
}
|
|
177
171
|
}, _callee3);
|
|
178
172
|
}));
|
|
@@ -188,10 +182,10 @@ module.exports = function setDefaultRoutes(server, options) {
|
|
|
188
182
|
options: {
|
|
189
183
|
auth: /*authDefault*/false,
|
|
190
184
|
handler: function () {
|
|
191
|
-
var _handler4 = _asyncToGenerator(/*#__PURE__*/
|
|
185
|
+
var _handler4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(req, h) {
|
|
192
186
|
var allAppEnv, uappenv, s;
|
|
193
|
-
return
|
|
194
|
-
while (1) switch (_context4.
|
|
187
|
+
return _regenerator().w(function (_context4) {
|
|
188
|
+
while (1) switch (_context4.n) {
|
|
195
189
|
case 0:
|
|
196
190
|
allAppEnv = options.allAppEnv;
|
|
197
191
|
if (options.userInfo != null) {
|
|
@@ -206,10 +200,7 @@ module.exports = function setDefaultRoutes(server, options) {
|
|
|
206
200
|
debug(options.allAppEnv);
|
|
207
201
|
}
|
|
208
202
|
debug(s);
|
|
209
|
-
return _context4.
|
|
210
|
-
case 7:
|
|
211
|
-
case "end":
|
|
212
|
-
return _context4.stop();
|
|
203
|
+
return _context4.a(2, s);
|
|
213
204
|
}
|
|
214
205
|
}, _callee4);
|
|
215
206
|
}));
|
|
@@ -220,23 +211,37 @@ module.exports = function setDefaultRoutes(server, options) {
|
|
|
220
211
|
}()
|
|
221
212
|
}
|
|
222
213
|
},
|
|
223
|
-
/*
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
214
|
+
/*
|
|
215
|
+
{
|
|
216
|
+
method: ["GET"],
|
|
217
|
+
path: `${appName}/{param*}`,
|
|
218
|
+
options: {
|
|
219
|
+
auth: authDefault,
|
|
220
|
+
handler: getApp2,
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
|
+
*/
|
|
233
224
|
|
|
234
225
|
{
|
|
235
226
|
method: ["GET"],
|
|
236
227
|
path: "/{param*}",
|
|
237
228
|
options: {
|
|
238
229
|
auth: authDefault,
|
|
239
|
-
handler:
|
|
230
|
+
handler: function () {
|
|
231
|
+
var _handler5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(req, h) {
|
|
232
|
+
return _regenerator().w(function (_context5) {
|
|
233
|
+
while (1) switch (_context5.n) {
|
|
234
|
+
case 0:
|
|
235
|
+
console.log('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>in param');
|
|
236
|
+
return _context5.a(2, (0, _handlers.getApp2)(req, h));
|
|
237
|
+
}
|
|
238
|
+
}, _callee5);
|
|
239
|
+
}));
|
|
240
|
+
function handler(_x9, _x0) {
|
|
241
|
+
return _handler5.apply(this, arguments);
|
|
242
|
+
}
|
|
243
|
+
return handler;
|
|
244
|
+
}()
|
|
240
245
|
}
|
|
241
246
|
}, {
|
|
242
247
|
method: ["GET"],
|
|
@@ -268,6 +273,13 @@ module.exports = function setDefaultRoutes(server, options) {
|
|
|
268
273
|
};
|
|
269
274
|
debug(pr);
|
|
270
275
|
defaultTable.push(pr);
|
|
276
|
+
// now set pre for all default routes
|
|
277
|
+
defaultTable.forEach(function (r) {
|
|
278
|
+
r.options.pre = [{
|
|
279
|
+
method: _setContext["default"],
|
|
280
|
+
assign: 'context'
|
|
281
|
+
}];
|
|
282
|
+
});
|
|
271
283
|
var routeTables = uTable !== null ? defaultTable.concat(uTable) : defaultTable;
|
|
272
284
|
server.route(routeTables);
|
|
273
285
|
};
|
package/lib/plugins/setupAuth.js
CHANGED
|
@@ -4,26 +4,26 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
function
|
|
8
|
-
function
|
|
7
|
+
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
8
|
+
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
9
9
|
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
10
10
|
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
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
|
-
*
|
|
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
27
|
*/
|
|
28
28
|
|
|
29
29
|
var SASauth = require('./SASauth');
|
|
@@ -32,53 +32,50 @@ var token = require('./token');
|
|
|
32
32
|
var setDefaultRoutes = require('./setDefaultRoutes');
|
|
33
33
|
var log = require('debug')('auth');
|
|
34
34
|
|
|
35
|
-
/** Notes:
|
|
36
|
-
* If api then register sasAuth and token - no cookies
|
|
37
|
-
* If app, then register sasAuth and cookie(session) but no token
|
|
35
|
+
/** Notes:
|
|
36
|
+
* If api then register sasAuth and token - no cookies
|
|
37
|
+
* If app, then register sasAuth and cookie(session) but no token
|
|
38
38
|
*/
|
|
39
39
|
function setupAuth(_x, _x2) {
|
|
40
40
|
return _setupAuth.apply(this, arguments);
|
|
41
41
|
}
|
|
42
42
|
function _setupAuth() {
|
|
43
|
-
_setupAuth = _asyncToGenerator(/*#__PURE__*/
|
|
43
|
+
_setupAuth = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(server, options) {
|
|
44
44
|
var def;
|
|
45
|
-
return
|
|
46
|
-
while (1) switch (_context.
|
|
45
|
+
return _regenerator().w(function (_context) {
|
|
46
|
+
while (1) switch (_context.n) {
|
|
47
47
|
case 0:
|
|
48
48
|
if (!(options.authFlow === 'server')) {
|
|
49
|
-
_context.
|
|
49
|
+
_context.n = 5;
|
|
50
50
|
break;
|
|
51
51
|
}
|
|
52
|
-
_context.
|
|
52
|
+
_context.n = 1;
|
|
53
53
|
return server.register({
|
|
54
54
|
plugin: SASauth,
|
|
55
55
|
options: options
|
|
56
56
|
});
|
|
57
|
-
case
|
|
58
|
-
_context.
|
|
57
|
+
case 1:
|
|
58
|
+
_context.n = 2;
|
|
59
59
|
return appCookie(server, options);
|
|
60
|
-
case
|
|
60
|
+
case 2:
|
|
61
61
|
def = 'session';
|
|
62
62
|
if (!(options.serverMode === 'api')) {
|
|
63
|
-
_context.
|
|
63
|
+
_context.n = 4;
|
|
64
64
|
break;
|
|
65
65
|
}
|
|
66
|
-
_context.
|
|
66
|
+
_context.n = 3;
|
|
67
67
|
return server.register({
|
|
68
68
|
plugin: token
|
|
69
69
|
});
|
|
70
|
-
case
|
|
70
|
+
case 3:
|
|
71
71
|
def = 'token';
|
|
72
|
-
case
|
|
72
|
+
case 4:
|
|
73
73
|
log('***********************Default auth', def);
|
|
74
74
|
server.auth["default"](def);
|
|
75
75
|
// console.log(server.registerations);
|
|
76
|
-
case
|
|
76
|
+
case 5:
|
|
77
77
|
setDefaultRoutes(server, options);
|
|
78
|
-
return _context.
|
|
79
|
-
case 14:
|
|
80
|
-
case "end":
|
|
81
|
-
return _context.stop();
|
|
78
|
+
return _context.a(2, true);
|
|
82
79
|
}
|
|
83
80
|
}, _callee);
|
|
84
81
|
}));
|
|
@@ -11,22 +11,22 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
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(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
13
13
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : 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
|
-
* ------------------------------------------------------------------------------------
|
|
16
|
-
* Copyright (c) SAS Institute Inc.
|
|
17
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
18
|
-
* you may not use this file except in compliance with the License.
|
|
19
|
-
* You may obtain a copy of the License at
|
|
20
|
-
*
|
|
21
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
22
|
-
*
|
|
23
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
24
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
25
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
26
|
-
* See the License for the specific language governing permissions and
|
|
27
|
-
* limitations under the License.
|
|
28
|
-
* ---------------------------------------------------------------------------------------
|
|
29
|
-
*
|
|
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
|
+
* ------------------------------------------------------------------------------------
|
|
16
|
+
* Copyright (c) SAS Institute Inc.
|
|
17
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
18
|
+
* you may not use this file except in compliance with the License.
|
|
19
|
+
* You may obtain a copy of the License at
|
|
20
|
+
*
|
|
21
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
22
|
+
*
|
|
23
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
24
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
25
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
26
|
+
* See the License for the specific language governing permissions and
|
|
27
|
+
* limitations under the License.
|
|
28
|
+
* ---------------------------------------------------------------------------------------
|
|
29
|
+
*
|
|
30
30
|
*/
|
|
31
31
|
function setupUserRoutes(u, options) {
|
|
32
32
|
if (u == null) {
|
|
@@ -51,6 +51,7 @@ function setupUserRoutes(u, options) {
|
|
|
51
51
|
assign: 'context'
|
|
52
52
|
}]);
|
|
53
53
|
}
|
|
54
|
+
console.log(rx.options.pre);
|
|
54
55
|
if (rx.options.auth === true) {
|
|
55
56
|
rx.options.auth = options.authDefault;
|
|
56
57
|
} else if (rx.options.auth === 'logon') {
|
package/lib/plugins/token.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function
|
|
4
|
-
function
|
|
3
|
+
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
4
|
+
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
5
5
|
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
6
6
|
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
7
7
|
exports.plugin = {
|
|
@@ -13,17 +13,16 @@ function itoken(_x) {
|
|
|
13
13
|
return _itoken.apply(this, arguments);
|
|
14
14
|
}
|
|
15
15
|
function _itoken() {
|
|
16
|
-
_itoken = _asyncToGenerator(/*#__PURE__*/
|
|
17
|
-
return
|
|
18
|
-
while (1) switch (_context.
|
|
16
|
+
_itoken = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(server) {
|
|
17
|
+
return _regenerator().w(function (_context) {
|
|
18
|
+
while (1) switch (_context.n) {
|
|
19
19
|
case 0:
|
|
20
|
-
_context.
|
|
20
|
+
_context.n = 1;
|
|
21
21
|
return server.auth.scheme('SAStoken', require('../schemes/SASTokenScheme'));
|
|
22
|
-
case
|
|
22
|
+
case 1:
|
|
23
23
|
server.auth.strategy('token', 'SAStoken');
|
|
24
|
-
case
|
|
25
|
-
|
|
26
|
-
return _context.stop();
|
|
24
|
+
case 2:
|
|
25
|
+
return _context.a(2);
|
|
27
26
|
}
|
|
28
27
|
}, _callee);
|
|
29
28
|
}));
|