@sassoftware/viya-serverjs 0.2.4 → 0.3.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/.env +6 -7
- package/.env.proxy +3 -3
- package/.env.server +3 -3
- package/Dockerfile +4 -4
- package/lib/iService.js +31 -24
- package/package.json +2 -2
- package/public/index.html +288 -297
- package/public/indexProxy.html +2 -2
- package/src/iService.js +18 -20
package/.env
CHANGED
|
@@ -10,20 +10,19 @@ CLIENTID=viyaapp
|
|
|
10
10
|
CLIENTSECRET=jellico
|
|
11
11
|
REDIRECT=
|
|
12
12
|
# APPDIR=./appDir
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
HTTPS=true
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
USETOKEN=YES
|
|
17
|
+
SHOWENV=YES
|
|
15
18
|
|
|
16
|
-
USETOKEN=NO
|
|
17
|
-
# SHOWENV=YES
|
|
18
|
-
# APPENV=
|
|
19
19
|
APPENV_XYZ=AA
|
|
20
20
|
APPENV_BAD=
|
|
21
21
|
|
|
22
22
|
# APPENV_PUPID=NSHOST=https://sas-logon-app.viya.svc.cluster.local
|
|
23
23
|
|
|
24
24
|
# NAMESPACE=viya
|
|
25
|
-
|
|
26
|
-
# TLS_KEY=./certs/tls.key
|
|
25
|
+
|
|
27
26
|
|
|
28
27
|
|
|
29
28
|
|
package/.env.proxy
CHANGED
|
@@ -3,12 +3,12 @@ APPHOST=localhost
|
|
|
3
3
|
APPENTRY=indexProxy.html
|
|
4
4
|
APPLOC=./public
|
|
5
5
|
VIYA_SERVER=
|
|
6
|
-
APPENV_PROXYSERVER=https://localhost:8080/
|
|
6
|
+
APPENV_PROXYSERVER=https://localhost:8080/viyaapp/proxy
|
|
7
7
|
|
|
8
8
|
APPPORT=8080
|
|
9
|
-
APPNAME=
|
|
9
|
+
APPNAME=viyaapp
|
|
10
10
|
AUTHFLOW=server
|
|
11
|
-
CLIENTID=
|
|
11
|
+
CLIENTID=viyaapp
|
|
12
12
|
CLIENTSECRET=jellico
|
|
13
13
|
REDIRECT=
|
|
14
14
|
|
package/.env.server
CHANGED
|
@@ -2,11 +2,11 @@ APPHOST=localhost
|
|
|
2
2
|
APPENTRY=index.html
|
|
3
3
|
APPLOC=./public
|
|
4
4
|
VIYA_SERVER=
|
|
5
|
-
APPENV_PROXYSERVER=https://localhost:8080/
|
|
5
|
+
APPENV_PROXYSERVER=https://localhost:8080/viyaapp/proxy
|
|
6
6
|
APPPORT=8080
|
|
7
|
-
APPNAME=
|
|
7
|
+
APPNAME=viyaapp
|
|
8
8
|
AUTHFLOW=server
|
|
9
|
-
CLIENTID=
|
|
9
|
+
CLIENTID=viyaapp
|
|
10
10
|
CLIENTSECRET=jellico
|
|
11
11
|
REDIRECT=/new
|
|
12
12
|
# APPDIR=./appDir
|
package/Dockerfile
CHANGED
|
@@ -9,7 +9,7 @@ RUN npm install
|
|
|
9
9
|
# will auto change to localhost in non-docker environments
|
|
10
10
|
ENV APPHOST=0.0.0.0
|
|
11
11
|
ENV PORT=8080
|
|
12
|
-
EXPOSE
|
|
12
|
+
EXPOSE 8080
|
|
13
13
|
ENV HTTPS=true
|
|
14
14
|
# ENV APPSERVERLEVEL=v2
|
|
15
15
|
#######################################################################
|
|
@@ -19,9 +19,9 @@ ENV HTTPS=true
|
|
|
19
19
|
# set this the same as EXPOSE here and override in env or as -p option in dockerrun
|
|
20
20
|
# ENV APPPORT=8080
|
|
21
21
|
|
|
22
|
-
ENV APPNAME=
|
|
22
|
+
ENV APPNAME=viyaapp
|
|
23
23
|
# ENV AUTHFLOW=
|
|
24
|
-
ENV CLIENTID=
|
|
24
|
+
ENV CLIENTID=viyaapp
|
|
25
25
|
ENV CLIENTSECRET=jellico
|
|
26
26
|
ENV HAPIDEBUG=NO
|
|
27
27
|
# ENV LOGLEVEL=info
|
|
@@ -38,7 +38,7 @@ ENV TLS_CREATE="C:US,ST:NC,L:Cary,O:SAS Institute,OU:STO,CN:localhost"
|
|
|
38
38
|
ENV SAMESITE=None,secure
|
|
39
39
|
|
|
40
40
|
# If your Viya instance still has a unsigned certificate set this value prior to invoking the server
|
|
41
|
-
ENV NODE_TLS_REJECT_UNAUTHORIZED=0
|
|
41
|
+
# ENV NODE_TLS_REJECT_UNAUTHORIZED=0
|
|
42
42
|
|
|
43
43
|
#####################################################################
|
|
44
44
|
CMD ["npm", "run", "indocker"]
|
package/lib/iService.js
CHANGED
|
@@ -230,7 +230,7 @@ function iService(userRouteTable, useDefault, asset, allAppEnv, serverMode, user
|
|
|
230
230
|
});
|
|
231
231
|
}
|
|
232
232
|
case 40:
|
|
233
|
-
|
|
233
|
+
console.log('Plugin', process.env.PLUGIN);
|
|
234
234
|
if (!(process.env.PLUGIN === 'hapi-swagger' && serverMode === 'api')) {
|
|
235
235
|
_context.next = 49;
|
|
236
236
|
break;
|
|
@@ -309,37 +309,44 @@ function getCertificates() {
|
|
|
309
309
|
}
|
|
310
310
|
function _getCertificates() {
|
|
311
311
|
_getCertificates = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
312
|
-
var
|
|
312
|
+
var options, tlsdir;
|
|
313
313
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
314
314
|
while (1) switch (_context2.prev = _context2.next) {
|
|
315
315
|
case 0:
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
if (fs.existsSync(process.env.TLS_CRT) && fs.existsSync(process.env.TLS_KEY)) {
|
|
321
|
-
console.log('TLS_CRT and TLS_KEY exist');
|
|
322
|
-
tls.cert = fs.readFileSync(process.env.TLS_CRT);
|
|
323
|
-
tls.key = fs.readFileSync(process.env.TLS_KEY);
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
if (!(tls.cert == null && process.env.TLS_CREATE != null)) {
|
|
327
|
-
_context2.next = 10;
|
|
316
|
+
options = null;
|
|
317
|
+
tlsdir = process.env.SSLCERT;
|
|
318
|
+
if (!(tlsdir != null && tlsdir.trim().length > 0)) {
|
|
319
|
+
_context2.next = 7;
|
|
328
320
|
break;
|
|
329
321
|
}
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
322
|
+
console.log('ssl CERTIFICATES', tlsdir);
|
|
323
|
+
if (fs.existsSync("".concat(tlsdir, "/key.pem")) === true) {
|
|
324
|
+
options = {};
|
|
325
|
+
options.key = fs.readFileSync("".concat(tlsdir, "/key.pem"), {
|
|
326
|
+
encoding: 'utf8'
|
|
327
|
+
});
|
|
328
|
+
options.cert = fs.readFileSync("".concat(tlsdir, "/crt.pem"), {
|
|
329
|
+
encoding: 'utf8'
|
|
330
|
+
});
|
|
331
|
+
if (fs.existsSync("".concat(tlsdir, "/ca.pem")) === true) {
|
|
332
|
+
options.ca = fs.readFileSync("".concat(tlsdir, "/ca.pem"), {
|
|
333
|
+
encoding: 'utf8'
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
options.rejectUnauthorized = true;
|
|
337
|
+
}
|
|
338
|
+
_context2.next = 12;
|
|
339
|
+
break;
|
|
340
|
+
case 7:
|
|
341
|
+
console.log('No SSL certificates found, generating self-signed certificates');
|
|
342
|
+
_context2.next = 10;
|
|
334
343
|
return getTls();
|
|
335
|
-
case 9:
|
|
336
|
-
tls = _context2.sent;
|
|
337
344
|
case 10:
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
}
|
|
341
|
-
return _context2.abrupt("return", tls);
|
|
345
|
+
options = _context2.sent;
|
|
346
|
+
options.rejectUnauthorized = false;
|
|
342
347
|
case 12:
|
|
348
|
+
return _context2.abrupt("return", options);
|
|
349
|
+
case 13:
|
|
343
350
|
case "end":
|
|
344
351
|
return _context2.stop();
|
|
345
352
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sassoftware/viya-serverjs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Easy to use app server for SAS Viya applications",
|
|
5
5
|
"author": "Deva Kumaraswamy <deva.kumar@sas.com>",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"unpkg": "./lib/index.js",
|
|
30
30
|
"scripts": {
|
|
31
31
|
"build": "rimraf lib && babel src --out-dir lib",
|
|
32
|
-
"test": "cross-env
|
|
32
|
+
"test": "cross-env node cli --env=./.env --docker=./Dockerfile",
|
|
33
33
|
"server": "cross-env NODE_TLS_REJECT_UNAUTHORIZED=0 node server.js --env=./.env.server --docker=./Dockerfile",
|
|
34
34
|
"proxy": "cross-env NODE_TLS_REJECT_UNAUTHORIZED=0 node cli --env=./.env.proxy --docker=./Dockerfile",
|
|
35
35
|
"pub": "npm publish --tag dev --access public",
|
package/public/index.html
CHANGED
|
@@ -18,240 +18,229 @@
|
|
|
18
18
|
-->
|
|
19
19
|
|
|
20
20
|
<html lang="en">
|
|
21
|
-
<head>
|
|
22
|
-
<meta charset="UTF-8" />
|
|
23
|
-
<title>index.html</title>
|
|
24
21
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
></script>
|
|
29
|
-
<script
|
|
30
|
-
crossorigin
|
|
31
|
-
src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"
|
|
32
|
-
></script>
|
|
33
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.26.0/babel.min.js"></script>
|
|
34
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/6.26.0/polyfill.min.js"></script>
|
|
35
|
-
<script src="https://unpkg.com/@sassoftware/restaf@5.2.4/dist/restaf.js"></script>
|
|
36
|
-
<script src="https://unpkg.com/@sassoftware/restaflib@5.2.4/dist/restaflib.js"></script>
|
|
37
|
-
<script src="/appenv"></script>
|
|
38
|
-
|
|
39
|
-
<style>
|
|
40
|
-
.container {
|
|
41
|
-
display: flex;
|
|
42
|
-
flex-direction: column;
|
|
43
|
-
flex-wrap: nowrap;
|
|
44
|
-
min-height: 800px;
|
|
45
|
-
}
|
|
46
|
-
.elabel {
|
|
47
|
-
display: inline-block;
|
|
22
|
+
<head>
|
|
23
|
+
<meta charset="UTF-8" />
|
|
24
|
+
<title>index.html</title>
|
|
48
25
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
26
|
+
<script crossorigin src="https://unpkg.com/react@16/umd/react.production.min.js"></script>
|
|
27
|
+
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"></script>
|
|
28
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.26.0/babel.min.js"></script>
|
|
29
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/6.26.0/polyfill.min.js"></script>
|
|
30
|
+
<script src="https://unpkg.com/@sassoftware/restaf@5.2.4"></script>
|
|
31
|
+
<script src="https://unpkg.com/@sassoftware/restaflib@5.2.4"></script>
|
|
32
|
+
<script src="/appenv"></script>
|
|
33
|
+
|
|
34
|
+
<style>
|
|
35
|
+
.container {
|
|
36
|
+
display: flex;
|
|
37
|
+
flex-direction: column;
|
|
38
|
+
flex-wrap: nowrap;
|
|
39
|
+
min-height: 800px;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.elabel {
|
|
43
|
+
display: inline-block;
|
|
44
|
+
|
|
45
|
+
clear: left;
|
|
46
|
+
width: 250px;
|
|
47
|
+
text-align: right;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.einput {
|
|
51
|
+
display: inline-block;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.div1 {
|
|
55
|
+
border: 1px solid black;
|
|
56
|
+
background: lightskyblue;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.div2 {
|
|
60
|
+
border: 1px solid black;
|
|
61
|
+
background: lightskyblue;
|
|
62
|
+
height: 200px;
|
|
63
|
+
}
|
|
64
|
+
</style>
|
|
65
|
+
|
|
66
|
+
<script>
|
|
67
|
+
debugger;
|
|
68
|
+
console.log(JSON.stringify(APPENV, null, 4));
|
|
69
|
+
let store = restaf.initStore({
|
|
70
|
+
casProxy: true,
|
|
71
|
+
options: {
|
|
72
|
+
proxyServer: APPENV.PROXYSERVER,
|
|
73
|
+
httpOptions: null
|
|
64
74
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
75
|
+
});
|
|
76
|
+
debugger; console.log(store.config);
|
|
77
|
+
|
|
78
|
+
let session = null;
|
|
79
|
+
let servers = null;
|
|
80
|
+
let services = null;
|
|
81
|
+
let files = null;
|
|
82
|
+
let reports = null;
|
|
83
|
+
let compute = null;
|
|
84
|
+
|
|
85
|
+
function setup() {
|
|
68
86
|
debugger;
|
|
69
|
-
|
|
70
|
-
let store = restaf.initStore({
|
|
71
|
-
casProxy: true,
|
|
72
|
-
options: {
|
|
73
|
-
proxyServer: APPENV.PROXYSERVER,
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
debugger; console.log(store.config);
|
|
87
|
+
document.getElementById('output').innerHTML = '...initializing';
|
|
77
88
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
89
|
+
initSession()
|
|
90
|
+
.then(r => {
|
|
91
|
+
document.getElementById('output').innerHTML = 'ready';
|
|
92
|
+
keepAlive();
|
|
93
|
+
})
|
|
94
|
+
.catch(e => {
|
|
84
95
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
console.log(e);
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
function keepAlive() {
|
|
100
|
-
if (LOGONPAYLOAD.keepAlive != null) {
|
|
101
|
-
let interval = 120;
|
|
102
|
-
let timeout = 14400;
|
|
103
|
-
if (LOGONPAYLOAD.timers != null) {
|
|
104
|
-
let opts = LOGONPAYLOAD.timers.split(',');
|
|
105
|
-
interval = parseInt(opts[ 0 ]);
|
|
106
|
-
timeout = parseInt(opts[ 1 ]);
|
|
107
|
-
}
|
|
108
|
-
console.log(`Keepalive is active`);
|
|
109
|
-
store.keepViyaAlive(LOGONPAYLOAD.keepAlive, interval, timeout, () => {
|
|
110
|
-
console.log('timed out at', Date());
|
|
111
|
-
let params = `scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no,width=0,height=0,left=-1000,top=-1000`;
|
|
112
|
-
window.open(`${appOptions.logonPayload.host}/SASLogon/timedout`, 'Timed Out', params);
|
|
113
|
-
return true;
|
|
114
|
-
});
|
|
96
|
+
console.log(e);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
function keepAlive() {
|
|
100
|
+
if (LOGONPAYLOAD.keepAlive != null) {
|
|
101
|
+
let interval = 120;
|
|
102
|
+
let timeout = 14400;
|
|
103
|
+
if (LOGONPAYLOAD.timers != null) {
|
|
104
|
+
let opts = LOGONPAYLOAD.timers.split(',');
|
|
105
|
+
interval = parseInt(opts[0]);
|
|
106
|
+
timeout = parseInt(opts[1]);
|
|
115
107
|
}
|
|
116
|
-
|
|
108
|
+
console.log(`Keepalive is active`);
|
|
109
|
+
store.keepViyaAlive(LOGONPAYLOAD.keepAlive, interval, timeout, () => {
|
|
110
|
+
console.log('timed out at', Date());
|
|
111
|
+
let params = `scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no,width=0,height=0,left=-1000,top=-1000`;
|
|
112
|
+
window.open(`${appOptions.logonPayload.host}/SASLogon/timedout`, 'Timed Out', params);
|
|
113
|
+
return true;
|
|
114
|
+
});
|
|
117
115
|
}
|
|
118
|
-
function logoff() {
|
|
119
|
-
let url = `${window.location.protocol}//${window.location.host}/${LOGONPAYLOAD.appName}/logout?callbackUrl=onlogoff.html`;
|
|
120
|
-
window.location.replace(url);
|
|
121
116
|
|
|
122
|
-
|
|
117
|
+
}
|
|
118
|
+
function logoff() {
|
|
119
|
+
let url = `${window.location.protocol}//${window.location.host}/${LOGONPAYLOAD.appName}/logout?callbackUrl=onlogoff.html`;
|
|
120
|
+
window.location.replace(url);
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
}
|
|
124
|
+
async function initSession() {
|
|
125
|
+
debugger;
|
|
126
|
+
console.log(APPENV);
|
|
127
|
+
console.log(LOGONPAYLOAD);
|
|
128
|
+
debugger;
|
|
129
|
+
if (LOGONPAYLOAD.host == null) {
|
|
130
|
+
return 'done';
|
|
123
131
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
console.log(APPENV);
|
|
127
|
-
console.log(LOGONPAYLOAD);
|
|
128
|
-
debugger;
|
|
129
|
-
if (LOGONPAYLOAD.host == null) {
|
|
130
|
-
|
|
131
|
-
return 'done';
|
|
132
|
-
}
|
|
132
|
+
try {
|
|
133
133
|
let msg = await store.logon(LOGONPAYLOAD);
|
|
134
134
|
console.log(store.connection());
|
|
135
135
|
console.log(msg);
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
// if (identities.links('currentUser') != null) {
|
|
140
|
-
// let c = await store.apiCall(identities.links('currentUser'));
|
|
141
|
-
// name = c.items('id');
|
|
142
|
-
// }
|
|
143
|
-
console.log(name);
|
|
144
|
-
debugger;
|
|
145
|
-
/*
|
|
146
|
-
services = await store.addServices(
|
|
147
|
-
'files', 'compute', 'casManagement'
|
|
148
|
-
);
|
|
149
|
-
console.log(services.casManagement.links().toJS())
|
|
150
|
-
*/
|
|
151
|
-
debugger;
|
|
152
|
-
return 'done';
|
|
136
|
+
} catch (err) {
|
|
137
|
+
console.log('Error logging in', JSON.stringify(err, null, 4));
|
|
138
|
+
throw err;
|
|
153
139
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
break;
|
|
167
|
-
}
|
|
168
|
-
case 'cas': {
|
|
169
|
-
testcase = runCas;
|
|
170
|
-
break;
|
|
171
|
-
}
|
|
172
|
-
case 'timedout': {
|
|
173
|
-
testcase = timedout;
|
|
174
|
-
break;
|
|
175
|
-
}
|
|
176
|
-
case 'redir': {
|
|
177
|
-
testcase= noaction;
|
|
178
|
-
|
|
179
|
-
break;
|
|
180
|
-
}
|
|
181
|
-
case 'spre': {
|
|
182
|
-
testcase= spre;
|
|
183
|
-
|
|
184
|
-
break;
|
|
185
|
-
}
|
|
186
|
-
default: {
|
|
187
|
-
testcase = SASfileService;
|
|
188
|
-
break;
|
|
189
|
-
}
|
|
140
|
+
let name = 'user';
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
//document.getElementById('output').innerHTML = '...running';
|
|
144
|
+
return 'done';
|
|
145
|
+
}
|
|
146
|
+
function runit(type) {
|
|
147
|
+
let testcase;
|
|
148
|
+
switch (type) {
|
|
149
|
+
case 'files': {
|
|
150
|
+
testcase = SASfileService;
|
|
151
|
+
break;
|
|
190
152
|
}
|
|
153
|
+
case 'compute': {
|
|
154
|
+
testcase = dsCompute;
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
case 'cas': {
|
|
158
|
+
testcase = runCas;
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
case 'timedout': {
|
|
162
|
+
testcase = timedout;
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
case 'redir': {
|
|
166
|
+
testcase = noaction;
|
|
191
167
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
).innerHTML = JSON.stringify(err, null, 4);
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
async function noaction() {
|
|
206
|
-
r = {msg: 'redirects completed'};
|
|
207
|
-
return r;
|
|
208
|
-
}
|
|
209
|
-
async function spre(store) {
|
|
210
|
-
let p = {
|
|
211
|
-
method: 'GET',
|
|
212
|
-
url : 'http://localhost:3000/api/test',
|
|
213
|
-
withCredentials: true
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
case 'spre': {
|
|
171
|
+
testcase = spre;
|
|
172
|
+
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
default: {
|
|
176
|
+
testcase = SASfileService;
|
|
177
|
+
break;
|
|
214
178
|
}
|
|
215
|
-
let r = await store.request(p);
|
|
216
|
-
return r.data;
|
|
217
|
-
}
|
|
218
|
-
async function timedout(store) {
|
|
219
|
-
console.log('timed out at', Date() );
|
|
220
|
-
let params = `scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no,width=0,height=0,left=-1000,top=-1000`;
|
|
221
|
-
window.open(`${LOGONPAYLOAD.host}/SASLogon/timedout`,'Timed Out', params);
|
|
222
|
-
return true;
|
|
223
179
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
180
|
+
|
|
181
|
+
testcase(store)
|
|
182
|
+
.then(r => {
|
|
183
|
+
document.getElementById(
|
|
184
|
+
'output'
|
|
185
|
+
).innerHTML = JSON.stringify(r, null, 4);
|
|
186
|
+
})
|
|
187
|
+
.catch(err => {
|
|
188
|
+
|
|
189
|
+
document.getElementById(
|
|
190
|
+
'output'
|
|
191
|
+
).innerHTML = JSON.stringify(err, null, 4);
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
async function noaction() {
|
|
195
|
+
r = { msg: 'redirects completed' };
|
|
196
|
+
return r;
|
|
197
|
+
}
|
|
198
|
+
async function spre(store) {
|
|
199
|
+
let p = {
|
|
200
|
+
method: 'GET',
|
|
201
|
+
url: 'http://localhost:3000/api/test',
|
|
202
|
+
withCredentials: true
|
|
243
203
|
}
|
|
204
|
+
let r = await store.request(p);
|
|
205
|
+
return r.data;
|
|
206
|
+
}
|
|
207
|
+
async function timedout(store) {
|
|
208
|
+
console.log('timed out at', Date());
|
|
209
|
+
let params = `scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no,width=0,height=0,left=-1000,top=-1000`;
|
|
210
|
+
window.open(`${LOGONPAYLOAD.host}/SASLogon/timedout`, 'Timed Out', params);
|
|
211
|
+
return true;
|
|
212
|
+
}
|
|
213
|
+
async function runCas(store) {
|
|
214
|
+
debugger;
|
|
215
|
+
let { casManagement } = await store.addServices('casManagement');
|
|
216
|
+
let servers = await store.apiCall(
|
|
217
|
+
casManagement.links('servers')
|
|
218
|
+
);
|
|
219
|
+
let serverName = servers.itemsList(0);
|
|
220
|
+
let session = await store.apiCall(
|
|
221
|
+
servers.itemsCmd(serverName, 'createSession')
|
|
222
|
+
);
|
|
223
|
+
let payload = {
|
|
224
|
+
action: 'builtins.echo',
|
|
225
|
+
data: { code: { x: 1 } }
|
|
226
|
+
};
|
|
227
|
+
console.log(JSON.stringify(session.links("execute"), null, 4));
|
|
228
|
+
let r = await store.runAction(session, payload);
|
|
229
|
+
console.log('echo completed');
|
|
230
|
+
await store.apiCall(session.links('delete'));
|
|
231
|
+
return r.items();
|
|
232
|
+
}
|
|
244
233
|
|
|
245
|
-
|
|
234
|
+
async function SASfileService(store) {
|
|
235
|
+
debugger;
|
|
236
|
+
let content;
|
|
237
|
+
try {
|
|
246
238
|
debugger;
|
|
247
|
-
let
|
|
248
|
-
try {
|
|
249
|
-
debugger;
|
|
250
|
-
let {files} = await store.addServices('files');
|
|
239
|
+
let { files } = await store.addServices('files');
|
|
251
240
|
debugger;
|
|
252
241
|
console.log(JSON.stringify(files.links(), null, 4));
|
|
253
242
|
//console.log('items - should be an array of files(empty array is ok)')
|
|
254
|
-
|
|
243
|
+
// console.log(files.items().toJS());
|
|
255
244
|
let payload = {
|
|
256
245
|
data: { x: 1, y: 'This was saved earlier in the step' },
|
|
257
246
|
headers: { 'content-type': 'application/json' }
|
|
@@ -261,100 +250,102 @@
|
|
|
261
250
|
debugger;
|
|
262
251
|
console.log(JSON.stringify(newFile.links('content'), null, 4));
|
|
263
252
|
content = await store.apiCall(newFile.links('content'));
|
|
264
|
-
|
|
265
|
-
} catch(err) {
|
|
253
|
+
|
|
254
|
+
} catch (err) {
|
|
266
255
|
console.log(JSON.stringify(err, null, 4));
|
|
267
256
|
debugger;
|
|
268
257
|
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
258
|
+
console.log(content);
|
|
259
|
+
return content.items();
|
|
260
|
+
}
|
|
261
|
+
async function dsCompute(store) {
|
|
262
|
+
let log = null;
|
|
263
|
+
debugger;
|
|
264
|
+
let { compute } = await store.addServices('compute');
|
|
265
|
+
let servers = await store.apiCall(compute.links('servers'));
|
|
277
266
|
|
|
278
|
-
|
|
267
|
+
let contexts = await store.apiCall(compute.links('contexts'));
|
|
279
268
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
269
|
+
// lookup the name of the first context and then use it to get the associated createSession restafLink
|
|
270
|
+
let createSession = contexts.itemsCmd(
|
|
271
|
+
contexts.itemsList(0),
|
|
272
|
+
'createSession'
|
|
273
|
+
);
|
|
274
|
+
let session = await store.apiCall(createSession);
|
|
286
275
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
276
|
+
// Now run a simple data step in that session
|
|
277
|
+
let payload = {
|
|
278
|
+
data: {
|
|
279
|
+
code: [`data _null_; do i = 1 to 100; x=1; end; run; `]
|
|
280
|
+
}
|
|
281
|
+
};
|
|
293
282
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
283
|
+
// Now execute the data step and wait for completion
|
|
284
|
+
let job = await store.apiCall(
|
|
285
|
+
session.links('execute'),
|
|
286
|
+
payload
|
|
287
|
+
);
|
|
288
|
+
let status = await store.jobState(job, null, 5, 2);
|
|
300
289
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
}
|
|
290
|
+
if (status.data === 'running') {
|
|
291
|
+
throw `ERROR: Job did not complete in allotted time`;
|
|
292
|
+
} else {
|
|
293
|
+
switch (status.data) {
|
|
294
|
+
case 'warning':
|
|
295
|
+
console.log(`Warning: check your log for warnings`);
|
|
296
|
+
break;
|
|
297
|
+
case 'error':
|
|
298
|
+
throw `Please correct errors and rerun program`;
|
|
299
|
+
default:
|
|
300
|
+
log = await store.apiCall(status.job.links('log'));
|
|
301
|
+
break;
|
|
314
302
|
}
|
|
315
|
-
return log === null ? status : log.items();
|
|
316
303
|
}
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
304
|
+
return log === null ? status : log.items();
|
|
305
|
+
}
|
|
306
|
+
</script>
|
|
307
|
+
</head>
|
|
308
|
+
|
|
309
|
+
<body onload="setup()">
|
|
310
|
+
<h1 id="head">Hi</h1>
|
|
311
|
+
<div>
|
|
312
|
+
<button onclick="runit('redir')">
|
|
313
|
+
Press to do some redirs
|
|
314
|
+
</button>
|
|
315
|
+
<button onclick="runit('files')">
|
|
316
|
+
Press to make a call to file service
|
|
317
|
+
</button>
|
|
318
|
+
<br />
|
|
319
|
+
<br />
|
|
320
|
+
<button onclick="runit('compute')">
|
|
321
|
+
Press to make a call compute service
|
|
322
|
+
</button>
|
|
323
|
+
<br />
|
|
324
|
+
<br />
|
|
325
|
+
<button onclick="runit('cas')">
|
|
326
|
+
Press to make a call to cas echo
|
|
327
|
+
</button>
|
|
328
|
+
<br />
|
|
329
|
+
<br />
|
|
330
|
+
<button onclick="runit('spre')">
|
|
331
|
+
REST call
|
|
332
|
+
</button>
|
|
333
|
+
<br />
|
|
334
|
+
<br />
|
|
335
|
+
<input id='filename'> </input>
|
|
336
|
+
<button onclick="runit('timedout')">
|
|
337
|
+
Press to test timedout
|
|
338
|
+
</button>
|
|
339
|
+
<br />
|
|
340
|
+
<br />
|
|
341
|
+
<button onclick="logoff()">
|
|
342
|
+
logoff
|
|
343
|
+
</button>
|
|
344
|
+
<br />
|
|
345
|
+
</div>
|
|
346
|
+
<div>
|
|
347
|
+
<pre id="output"></pre>
|
|
348
|
+
</div>
|
|
349
|
+
</body>
|
|
350
|
+
|
|
351
|
+
</html>
|
package/public/indexProxy.html
CHANGED
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
></script>
|
|
32
32
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.26.0/babel.min.js"></script>
|
|
33
33
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/6.26.0/polyfill.min.js"></script>
|
|
34
|
-
<script src="https://unpkg.com/@sassoftware/restaf@
|
|
35
|
-
<script src="https://unpkg.com/@sassoftware/restaflib@
|
|
34
|
+
<script src="https://unpkg.com/@sassoftware/restaf@alpha"></script>
|
|
35
|
+
<script src="https://unpkg.com/@sassoftware/restaflib@alpha"></script>
|
|
36
36
|
<script src="/appenv"></script>
|
|
37
37
|
|
|
38
38
|
<style>
|
package/src/iService.js
CHANGED
|
@@ -196,7 +196,7 @@ function iService (userRouteTable, useDefault, asset, allAppEnv, serverMode, use
|
|
|
196
196
|
});
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
|
-
|
|
199
|
+
console.log('Plugin', process.env.PLUGIN);
|
|
200
200
|
|
|
201
201
|
if (process.env.PLUGIN === 'hapi-swagger' && serverMode ==='api') {
|
|
202
202
|
let swaggerOptions = {
|
|
@@ -259,27 +259,25 @@ function iService (userRouteTable, useDefault, asset, allAppEnv, serverMode, use
|
|
|
259
259
|
|
|
260
260
|
async function getCertificates () {
|
|
261
261
|
|
|
262
|
-
let
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
if (fs.existsSync(
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
262
|
+
let options = null;
|
|
263
|
+
let tlsdir = process.env.SSLCERT;
|
|
264
|
+
if (tlsdir != null && tlsdir.trim().length > 0) {
|
|
265
|
+
console.log('ssl CERTIFICATES', tlsdir);
|
|
266
|
+
if (fs.existsSync(`${tlsdir}/key.pem`) === true) {
|
|
267
|
+
options = {};
|
|
268
|
+
options.key = fs.readFileSync(`${tlsdir}/key.pem`, { encoding: 'utf8' });
|
|
269
|
+
options.cert = fs.readFileSync(`${tlsdir}/crt.pem`, { encoding: 'utf8' });
|
|
270
|
+
if (fs.existsSync(`${tlsdir}/ca.pem`) === true) {
|
|
271
|
+
options.ca = fs.readFileSync(`${tlsdir}/ca.pem`, { encoding: 'utf8' });
|
|
272
|
+
}
|
|
273
|
+
options.rejectUnauthorized= true;
|
|
270
274
|
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
console.log('Creating selfsigned certificate');
|
|
276
|
-
debug2('TLS set: TLS_CREATE=', process.env.TLS_CREATE);
|
|
277
|
-
tls = await getTls();
|
|
275
|
+
} else {
|
|
276
|
+
console.log('No SSL certificates found, generating self-signed certificates');
|
|
277
|
+
options = await getTls();
|
|
278
|
+
options.rejectUnauthorized= false;
|
|
278
279
|
}
|
|
279
|
-
|
|
280
|
-
console.log('Warning: The current host protocol is https: No TLS certificate information has been specified.');
|
|
281
|
-
}
|
|
282
|
-
return tls;
|
|
280
|
+
return options;
|
|
283
281
|
}
|
|
284
282
|
|
|
285
283
|
async function getTls () {
|