@sassoftware/viya-serverjs 0.6.3-0 → 0.6.3-2

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 CHANGED
@@ -12,8 +12,9 @@ REDIRECT=
12
12
  # USELOGON=FALSE
13
13
  # USETOKEN=FALSE
14
14
  HTTPS=true
15
-
16
- VIYACERT=c:\Users\kumar\viyaCert\xf1
15
+ # SSLCERT=
16
+ # VIYACERT=c:\Users\kumar\viyaCert\xf1
17
17
  NODE_TLS_REJECT_UNAUTHORIZED=0
18
- AUTOSTART=TRUE
18
+ # AUTOSTART=TRUE
19
19
 
20
+ CUSTOMTEXT="<h1> sas-score-mcp-server</h>"
package/autoStart.js CHANGED
@@ -1,6 +1,6 @@
1
- import open from 'open';
2
- async function autoStart(url) {
3
- await open(url, {wait:true});
4
- console.error(`[Note]URL: ${url} closed by user`);
5
- }
1
+ import open from 'open';
2
+ async function autoStart(url) {
3
+ await open(url, {wait:true});
4
+ console.error(`[Note]URL: ${url} closed by user`);
5
+ }
6
6
  export default autoStart;
package/cli.js CHANGED
@@ -13,7 +13,7 @@ let userCache = {};
13
13
  api.asyncCore(null, true, 'app', null, userCache)
14
14
  .then ((r) => {
15
15
  console.log('core returned', r);
16
- if (process.env.AUTOSTART && process.env.AUTOSTART.toUpperCase() === 'TRUE'){
16
+ if (process.env.AUTOSTART && process.env.AUTOSTART.toUpperCase() ==='TRUE'){
17
17
  console.log('Auto-starting the server as per AUTOSTART env variable');
18
18
  autoStart(r).catch((err) => {
19
19
  console.log('Error in autoStart', err);
package/lib/iService.js CHANGED
@@ -113,12 +113,20 @@ function _iService() {
113
113
  };
114
114
  }
115
115
  debug(JSON.stringify(sConfig, null, 4));
116
- if (https === 'TRUE') {
117
- sConfig.tls = getCertificates();
118
- debug('Setup of SSL certificates completed');
119
- } else {
120
- debug('Running with no SSL certificates');
116
+ if (!(https === 'TRUE')) {
117
+ _context.n = 2;
118
+ break;
121
119
  }
120
+ _context.n = 1;
121
+ return getCertificates();
122
+ case 1:
123
+ sConfig.tls = _context.v;
124
+ debug('Setup of SSL certificates completed');
125
+ _context.n = 3;
126
+ break;
127
+ case 2:
128
+ debug('Running with no SSL certificates');
129
+ case 3:
122
130
  if (asset !== null) {
123
131
  sConfig.routes.files = {
124
132
  relativeTo: asset
@@ -148,26 +156,26 @@ function _iService() {
148
156
  relativeTo: __dirname,
149
157
  path: '.'
150
158
  };
151
- _context.n = 1;
159
+ _context.n = 4;
152
160
  return hapiServer.register(Vision);
153
- case 1:
161
+ case 4:
154
162
  hapiServer.views(visionOptions);
155
- _context.n = 2;
163
+ _context.n = 5;
156
164
  return hapiServer.register(inert);
157
- case 2:
165
+ case 5:
158
166
  if (!(https === 'TRUE')) {
159
- _context.n = 3;
167
+ _context.n = 6;
160
168
  break;
161
169
  }
162
- _context.n = 3;
170
+ _context.n = 6;
163
171
  return hapiServer.register({
164
172
  plugin: require('hapi-require-https'),
165
173
  options: {}
166
174
  });
167
- case 3:
168
- _context.n = 4;
175
+ case 6:
176
+ _context.n = 7;
169
177
  return hapiServer.register(H202);
170
- case 4:
178
+ case 7:
171
179
  // setup authentication related plugins
172
180
  options = {
173
181
  serverMode: serverMode,
@@ -197,12 +205,12 @@ function _iService() {
197
205
  };
198
206
  debug2('Options', options);
199
207
  if (!(process.env.AUTHFLOW != null)) {
200
- _context.n = 6;
208
+ _context.n = 9;
201
209
  break;
202
210
  }
203
- _context.n = 5;
211
+ _context.n = 8;
204
212
  return (0, _setupAuth["default"])(hapiServer, options);
205
- case 5:
213
+ case 8:
206
214
  if (process.env.PREAUTH === 'YES') {
207
215
  console.log('Preauth enabled');
208
216
  hapiServer.ext('onPreAuth', function (request, h) {
@@ -218,15 +226,15 @@ function _iService() {
218
226
  return h["continue"];
219
227
  });
220
228
  }
221
- case 6:
229
+ case 9:
222
230
  //
223
231
  // Start server
224
232
  //
225
233
  // eslint-disable-next-line no-unused-vars
226
234
  allRoutes = hapiServer.table();
227
- _context.n = 7;
235
+ _context.n = 10;
228
236
  return hapiServer.start();
229
- case 7:
237
+ case 10:
230
238
  hh = hapiServer.info.uri;
231
239
  hh = hh.replace(/0.0.0.0/, 'localhost');
232
240
  console.log('====================================================================================');
@@ -268,81 +276,104 @@ function _iService() {
268
276
  return _iService.apply(this, arguments);
269
277
  }
270
278
  function getCertificates() {
271
- var tlsdir = process.env.SSLCERT;
272
- var options = (0, _readCerts["default"])(tlsdir);
273
- if (options === null) {
274
- console.log('No SSL certificates found, generating self-signed certificates');
275
- options = getTls();
276
- options.rejectUnauthorized = false;
277
- }
278
- return options;
279
+ return _getCertificates.apply(this, arguments);
280
+ }
281
+ function _getCertificates() {
282
+ _getCertificates = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
283
+ var tlsdir, options;
284
+ return _regenerator().w(function (_context3) {
285
+ while (1) switch (_context3.n) {
286
+ case 0:
287
+ tlsdir = process.env.SSLCERT;
288
+ options = (0, _readCerts["default"])(tlsdir);
289
+ if (!(options === null)) {
290
+ _context3.n = 2;
291
+ break;
292
+ }
293
+ console.log('No SSL certificates found, generating self-signed certificates');
294
+ _context3.n = 1;
295
+ return getTls();
296
+ case 1:
297
+ options = _context3.v;
298
+ options.rejectUnauthorized = false;
299
+ case 2:
300
+ return _context3.a(2, options);
301
+ }
302
+ }, _callee3);
303
+ }));
304
+ return _getCertificates.apply(this, arguments);
279
305
  }
280
306
  function getTls() {
281
- var options = {
282
- keySize: 2048,
283
- days: 360,
284
- algorithm: "sha256",
285
- clientCertificate: true,
286
- extensions: {}
287
- };
288
- var subjt = process.env.TLS_CREATE.replaceAll('"', '').trim();
289
- var subj = subjt.split(',');
290
- var d = {};
291
- subj.map(function (c) {
292
- var r = c.split(':');
293
- d[r[0]] = r[1];
294
- return {
295
- value: r[1]
296
- };
297
- });
307
+ return _getTls.apply(this, arguments);
308
+ }
309
+ function _getTls() {
310
+ _getTls = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
311
+ var options, subjt, subj, d, attr, pems, tls;
312
+ return _regenerator().w(function (_context4) {
313
+ while (1) switch (_context4.n) {
314
+ case 0:
315
+ options = {
316
+ keySize: 2048,
317
+ days: 360,
318
+ algorithm: "sha256",
319
+ clientCertificate: true,
320
+ extensions: {}
321
+ };
322
+ subjt = process.env.TLS_CREATE.replaceAll('"', '').trim();
323
+ subj = subjt.split(',');
324
+ d = {};
325
+ subj.map(function (c) {
326
+ var r = c.split(':');
327
+ d[r[0]] = r[1];
328
+ return {
329
+ value: r[1]
330
+ };
331
+ });
298
332
 
299
- // TLS_CREATE=C:US,ST:NC,L:Cary,O:SAS Institute,OU:STO,CN:localhost,ALT:na.sas.com
300
- var attr = [{
301
- name: 'commonName',
302
- value: d.CN /*process.env.APPHOST*/
303
- }, {
304
- name: 'countryName',
305
- value: d.C
306
- }, {
307
- shortName: 'ST',
308
- value: d.ST
309
- }, {
310
- name: 'localityName',
311
- value: d.L
312
- }, {
313
- name: 'organizationName',
314
- value: d.O
315
- }, {
316
- shortName: 'OU',
317
- value: d.OU
318
- }];
319
- options.extensions.altNames = [
320
- // { type: 6, value: `http://${process.env.APPHOST}:${process.env.APPPORT}/${process.env.APPNAME}` },
321
- {
322
- type: 6,
323
- value: "https://".concat(process.env.APPHOST, ":").concat(process.env.APPPORT, "/").concat(process.env.APPNAME)
324
- }, {
325
- type: 6,
326
- value: "https://".concat(process.env.APPHOST, ":").concat(process.env.APPPORT, "/").concat(process.env.APPNAME, "/api")
327
- }, {
328
- type: 6,
329
- value: "https://".concat(process.env.APPHOST, ":").concat(process.env.APPPORT, "/").concat(process.env.APPNAME, "/logon")
330
- }, {
331
- type: 6,
332
- value: "https://".concat(process.env.APPHOST, "/").concat(process.env.APPNAME)
333
- }, {
334
- type: 6,
335
- value: "https://".concat(process.env.APPHOST, "/").concat(process.env.APPNAME, "/api")
336
- }, {
337
- type: 6,
338
- value: "https://".concat(process.env.APPHOST, "/").concat(process.env.APPNAME, "/logon")
339
- }];
340
- debug('tls options ', JSON.stringify(options, null, 4));
341
- var pems = selfsigned.generate(attr, options);
342
- var tls = {
343
- cert: pems.cert,
344
- key: pems["private"]
345
- };
346
- return tls;
333
+ // TLS_CREATE=C:US,ST:NC,L:Cary,O:SAS Institute,OU:STO,CN:localhost,ALT:na.sas.com
334
+ attr = [{
335
+ name: 'commonName',
336
+ value: d.CN /*process.env.APPHOST*/
337
+ }, {
338
+ name: 'countryName',
339
+ value: d.C
340
+ }, {
341
+ shortName: 'ST',
342
+ value: d.ST
343
+ }, {
344
+ name: 'localityName',
345
+ value: d.L
346
+ }, {
347
+ name: 'organizationName',
348
+ value: d.O
349
+ }, {
350
+ shortName: 'OU',
351
+ value: d.OU
352
+ }];
353
+ /*
354
+ options.extensions.altNames = [
355
+ // { type: 6, value: `http://${process.env.APPHOST}:${process.env.APPPORT}/${process.env.APPNAME}` },
356
+ { type: 6, value: `https://${process.env.APPHOST}:${process.env.APPPORT}/${process.env.APPNAME}` },
357
+ { type: 6, value: `https://${process.env.APPHOST}:${process.env.APPPORT}/${process.env.APPNAME}/api` },
358
+ { type: 6, value: `https://${process.env.APPHOST}:${process.env.APPPORT}/${process.env.APPNAME}/logon` },
359
+ { type: 6, value: `https://${process.env.APPHOST}/${process.env.APPNAME}` },
360
+ { type: 6, value: `https://${process.env.APPHOST}/${process.env.APPNAME}/api` },
361
+ { type: 6, value: `https://${process.env.APPHOST}/${process.env.APPNAME}/logon` },
362
+ ];
363
+ */
364
+ debug('tls options ', JSON.stringify(options, null, 4));
365
+ _context4.n = 1;
366
+ return selfsigned.generate(attr);
367
+ case 1:
368
+ pems = _context4.v;
369
+ tls = {
370
+ cert: pems.cert,
371
+ key: pems["private"]
372
+ };
373
+ return _context4.a(2, tls);
374
+ }
375
+ }, _callee4);
376
+ }));
377
+ return _getTls.apply(this, arguments);
347
378
  }
348
379
  var _default = exports["default"] = iService;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sassoftware/viya-serverjs",
3
- "version": "0.6.3-0",
3
+ "version": "0.6.3-2",
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",
package/server.js CHANGED
@@ -2,10 +2,10 @@
2
2
  * Copyright © 2025, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
- let core = require('./lib/index.js');
5
+ let api = require('./lib/index.js');
6
6
  debugger;
7
7
  let userCache = {};
8
- core(getCustomHandler, true, 'app', null, userCache);
8
+ api.core(getCustomHandler, true, 'app', null, userCache);
9
9
  console.log('Finished cli setup', userCache);
10
10
 
11
11
  function getCustomHandler() {
package/src/iService.js CHANGED
@@ -95,7 +95,7 @@ async function iService (userRouteTable, useDefault, asset, allAppEnv, serverMod
95
95
  }
96
96
  debug(JSON.stringify(sConfig, null,4));
97
97
  if (https === 'TRUE') {
98
- sConfig.tls = getCertificates();
98
+ sConfig.tls = await getCertificates();
99
99
  debug('Setup of SSL certificates completed');
100
100
  } else {
101
101
  debug('Running with no SSL certificates');
@@ -229,18 +229,18 @@ async function iService (userRouteTable, useDefault, asset, allAppEnv, serverMod
229
229
  };
230
230
  }
231
231
 
232
- function getCertificates () {
232
+ async function getCertificates () {
233
233
  let tlsdir = process.env.SSLCERT;
234
234
  let options = readCerts(tlsdir);
235
235
  if (options === null){
236
236
  console.log('No SSL certificates found, generating self-signed certificates');
237
- options = getTls();
237
+ options = await getTls();
238
238
  options.rejectUnauthorized= false;
239
239
  }
240
240
  return options;
241
241
  }
242
242
 
243
- function getTls () {
243
+ async function getTls () {
244
244
  let options = {
245
245
  keySize : 2048,
246
246
  days : 360,
@@ -283,6 +283,7 @@ function getTls () {
283
283
  }
284
284
  ];
285
285
 
286
+ /*
286
287
  options.extensions.altNames = [
287
288
  // { type: 6, value: `http://${process.env.APPHOST}:${process.env.APPPORT}/${process.env.APPNAME}` },
288
289
  { type: 6, value: `https://${process.env.APPHOST}:${process.env.APPPORT}/${process.env.APPNAME}` },
@@ -292,8 +293,9 @@ function getTls () {
292
293
  { type: 6, value: `https://${process.env.APPHOST}/${process.env.APPNAME}/api` },
293
294
  { type: 6, value: `https://${process.env.APPHOST}/${process.env.APPNAME}/logon` },
294
295
  ];
296
+ */
295
297
  debug('tls options ', JSON.stringify(options, null,4));
296
- let pems = selfsigned.generate(attr, options);
298
+ let pems = await selfsigned.generate(attr);
297
299
  let tls = {
298
300
  cert: pems.cert,
299
301
  key : pems.private