@sasjs/cli 2.39.0 → 3.0.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.
@@ -1,4 +1,4 @@
1
- import { SasAuthResponse, Target } from '@sasjs/utils/types';
1
+ import { SasAuthResponse, Target, HttpsAgentOptions } from '@sasjs/utils/types';
2
2
  import { TargetScope } from '../../types/targetScope';
3
3
  /**
4
4
  * Creates a .env file for the specified target.
@@ -10,6 +10,6 @@ import { TargetScope } from '../../types/targetScope';
10
10
  */
11
11
  export declare const addCredential: (target: Target, insecure: boolean, targetScope: TargetScope) => Promise<Target>;
12
12
  export declare const validateTargetName: (targetName: string) => string;
13
- export declare const getTokens: (target: Target, client: string, secret: string, insecure?: boolean) => Promise<SasAuthResponse>;
13
+ export declare const getTokens: (target: Target, client: string, secret: string, httpsAgentOptions?: HttpsAgentOptions | undefined) => Promise<SasAuthResponse>;
14
14
  export declare const createEnvFileForViya: (targetName: string, client: string, secret: string, accessToken: string, refreshToken: string) => Promise<void>;
15
15
  export declare const createEnvFileForSas9: (targetName: string, userName: string, password: string) => Promise<void>;
@@ -69,12 +69,13 @@ var saveConfig_1 = require("./internal/saveConfig");
69
69
  * @param {boolean} insecure- boolean to use insecure connection, default is false. lf true the server will not reject any connection which is not authorized with the list of supplied CAs
70
70
  */
71
71
  var addCredential = function (target, insecure, targetScope) { return __awaiter(void 0, void 0, void 0, function () {
72
- var serverUrl, filePath, _a, client, secret, _b, access_token, refresh_token, filePath, _c, userName, password, filePath;
72
+ var httpsAgentOptions, serverUrl, filePath, _a, client, secret, _b, access_token, refresh_token, filePath, _c, userName, password, filePath;
73
73
  var _d, _e, _f, _g;
74
74
  return __generator(this, function (_h) {
75
75
  switch (_h.label) {
76
76
  case 0:
77
- insecure = insecure || target.allowInsecureRequests;
77
+ httpsAgentOptions = insecure
78
+ ? __assign(__assign({}, target.httpsAgentOptions), { allowInsecureRequests: true, rejectUnauthorized: false }) : target.httpsAgentOptions;
78
79
  if (insecure)
79
80
  (_d = process.logger) === null || _d === void 0 ? void 0 : _d.warn('Executing with insecure connection.');
80
81
  if (!!target.serverUrl) return [3 /*break*/, 3];
@@ -92,7 +93,7 @@ var addCredential = function (target, insecure, targetScope) { return __awaiter(
92
93
  return [4 /*yield*/, input_1.getCredentialsInputForViya(target.name)];
93
94
  case 4:
94
95
  _a = _h.sent(), client = _a.client, secret = _a.secret;
95
- return [4 /*yield*/, exports.getTokens(target, client, secret, insecure)];
96
+ return [4 /*yield*/, exports.getTokens(target, client, secret, httpsAgentOptions)];
96
97
  case 5:
97
98
  _b = _h.sent(), access_token = _b.access_token, refresh_token = _b.refresh_token;
98
99
  if (!(targetScope === targetScope_1.TargetScope.Local)) return [3 /*break*/, 7];
@@ -144,32 +145,29 @@ var validateTargetName = function (targetName) {
144
145
  return targetName;
145
146
  };
146
147
  exports.validateTargetName = validateTargetName;
147
- var getTokens = function (target, client, secret, insecure) {
148
- if (insecure === void 0) { insecure = false; }
149
- return __awaiter(void 0, void 0, void 0, function () {
150
- var adapter, authResponse;
151
- var _a;
152
- return __generator(this, function (_b) {
153
- switch (_b.label) {
154
- case 0:
155
- adapter = new node_1.default({
156
- serverUrl: target.serverUrl,
157
- serverType: target.serverType,
158
- allowInsecureRequests: insecure,
159
- debug: ((_a = process.logger) === null || _a === void 0 ? void 0 : _a.logLevel) === logger_1.LogLevel.Debug
160
- });
161
- return [4 /*yield*/, auth_1.getNewAccessToken(adapter, client, secret, target).catch(function (e) {
162
- var _a;
163
- (_a = process.logger) === null || _a === void 0 ? void 0 : _a.error("An error has occurred while validating your credentials: " + e + "\nPlease check your Client ID and Client Secret and try again.\n");
164
- throw e;
165
- })];
166
- case 1:
167
- authResponse = _b.sent();
168
- return [2 /*return*/, authResponse];
169
- }
170
- });
148
+ var getTokens = function (target, client, secret, httpsAgentOptions) { return __awaiter(void 0, void 0, void 0, function () {
149
+ var adapter, authResponse;
150
+ var _a;
151
+ return __generator(this, function (_b) {
152
+ switch (_b.label) {
153
+ case 0:
154
+ adapter = new node_1.default({
155
+ serverUrl: target.serverUrl,
156
+ serverType: target.serverType,
157
+ httpsAgentOptions: httpsAgentOptions,
158
+ debug: ((_a = process.logger) === null || _a === void 0 ? void 0 : _a.logLevel) === logger_1.LogLevel.Debug
159
+ });
160
+ return [4 /*yield*/, auth_1.getNewAccessToken(adapter, client, secret, target).catch(function (e) {
161
+ var _a;
162
+ (_a = process.logger) === null || _a === void 0 ? void 0 : _a.error("An error has occurred while validating your credentials: " + e + "\nPlease check your Client ID and Client Secret and try again.\n");
163
+ throw e;
164
+ })];
165
+ case 1:
166
+ authResponse = _b.sent();
167
+ return [2 /*return*/, authResponse];
168
+ }
171
169
  });
172
- };
170
+ }); };
173
171
  exports.getTokens = getTokens;
174
172
  var createEnvFileForViya = function (targetName, client, secret, accessToken, refreshToken) { return __awaiter(void 0, void 0, void 0, function () {
175
173
  var envFileContent, envFilePath;
@@ -1,4 +1,15 @@
1
1
  "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
2
13
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
14
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
15
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -229,7 +240,7 @@ exports.getAndValidateSas9Fields = getAndValidateSas9Fields;
229
240
  function getAndValidateSasViyaFields(target, scope, serverUrl, insecure, authenticateCallback) {
230
241
  var _a;
231
242
  return __awaiter(this, void 0, void 0, function () {
232
- var contextName, shouldAuthenticate, sasjs, contexts, contextNumberErrorMessage, contextNumber;
243
+ var contextName, shouldAuthenticate, httpsAgentOptions, sasjs, contexts, contextNumberErrorMessage, contextNumber;
233
244
  return __generator(this, function (_b) {
234
245
  switch (_b.label) {
235
246
  case 0:
@@ -241,10 +252,12 @@ function getAndValidateSasViyaFields(target, scope, serverUrl, insecure, authent
241
252
  return [4 /*yield*/, authenticateCallback(target, insecure, scope)];
242
253
  case 2:
243
254
  target = _b.sent();
255
+ httpsAgentOptions = insecure
256
+ ? __assign(__assign({}, target.httpsAgentOptions), { allowInsecureRequests: true, rejectUnauthorized: false }) : target.httpsAgentOptions;
244
257
  sasjs = new node_1.default({
245
258
  serverUrl: serverUrl,
246
259
  serverType: types_1.ServerType.SasViya,
247
- allowInsecureRequests: insecure,
260
+ httpsAgentOptions: httpsAgentOptions,
248
261
  debug: ((_a = process.logger) === null || _a === void 0 ? void 0 : _a.logLevel) === logger_1.LogLevel.Debug
249
262
  });
250
263
  contexts = [];
@@ -221,7 +221,7 @@ var ContextCommand = /** @class */ (function (_super) {
221
221
  target = (_a.sent()).target;
222
222
  sasjs = new node_1.default({
223
223
  serverUrl: target.serverUrl,
224
- allowInsecureRequests: target.allowInsecureRequests,
224
+ httpsAgentOptions: target.httpsAgentOptions,
225
225
  appLoc: target.appLoc,
226
226
  serverType: target.serverType
227
227
  });
@@ -269,7 +269,7 @@ var ContextCommand = /** @class */ (function (_super) {
269
269
  target = (_a.sent()).target;
270
270
  sasjs = new node_1.default({
271
271
  serverUrl: target.serverUrl,
272
- allowInsecureRequests: target.allowInsecureRequests,
272
+ httpsAgentOptions: target.httpsAgentOptions,
273
273
  appLoc: target.appLoc,
274
274
  serverType: target.serverType
275
275
  });
@@ -308,7 +308,7 @@ var ContextCommand = /** @class */ (function (_super) {
308
308
  target = (_a.sent()).target;
309
309
  sasjs = new node_1.default({
310
310
  serverUrl: target.serverUrl,
311
- allowInsecureRequests: target.allowInsecureRequests,
311
+ httpsAgentOptions: target.httpsAgentOptions,
312
312
  appLoc: target.appLoc,
313
313
  serverType: target.serverType
314
314
  });
@@ -356,7 +356,7 @@ var ContextCommand = /** @class */ (function (_super) {
356
356
  target = (_a.sent()).target;
357
357
  sasjs = new node_1.default({
358
358
  serverUrl: target.serverUrl,
359
- allowInsecureRequests: target.allowInsecureRequests,
359
+ httpsAgentOptions: target.httpsAgentOptions,
360
360
  appLoc: target.appLoc,
361
361
  serverType: target.serverType
362
362
  });
@@ -399,7 +399,7 @@ var ContextCommand = /** @class */ (function (_super) {
399
399
  }
400
400
  sasjs = new node_1.default({
401
401
  serverUrl: target.serverUrl,
402
- allowInsecureRequests: target.allowInsecureRequests,
402
+ httpsAgentOptions: target.httpsAgentOptions,
403
403
  appLoc: target.appLoc,
404
404
  serverType: target.serverType
405
405
  });
@@ -149,7 +149,7 @@ function getSASjsAndAuthConfig(target, isLocal) {
149
149
  serverUrl: target.serverUrl,
150
150
  appLoc: target.appLoc,
151
151
  serverType: target.serverType,
152
- allowInsecureRequests: target.allowInsecureRequests,
152
+ httpsAgentOptions: target.httpsAgentOptions,
153
153
  debug: true,
154
154
  useComputeApi: true
155
155
  });
@@ -241,7 +241,7 @@ function deployToSas9(deployScript, target, linesToExecute, logFilePath, streamC
241
241
  password = utils_2.decodeFromBase64(password);
242
242
  sasjs = new node_1.default({
243
243
  serverUrl: target.serverUrl,
244
- allowInsecureRequests: target.allowInsecureRequests,
244
+ httpsAgentOptions: target.httpsAgentOptions,
245
245
  appLoc: target.appLoc,
246
246
  serverType: target.serverType
247
247
  });
@@ -125,7 +125,7 @@ var FlowCommand = /** @class */ (function (_super) {
125
125
  target = (_b.sent()).target;
126
126
  sasjs = new node_1.default({
127
127
  serverUrl: target.serverUrl,
128
- allowInsecureRequests: target.allowInsecureRequests,
128
+ httpsAgentOptions: target.httpsAgentOptions,
129
129
  appLoc: target.appLoc,
130
130
  serverType: target.serverType
131
131
  });
@@ -54,7 +54,7 @@ describe('sasjs flow', function () {
54
54
  var target = generateTarget();
55
55
  var sasjs = new node_1.default({
56
56
  serverUrl: target.serverUrl,
57
- allowInsecureRequests: target.allowInsecureRequests,
57
+ httpsAgentOptions: target.httpsAgentOptions,
58
58
  appLoc: target.appLoc,
59
59
  serverType: target.serverType
60
60
  });
@@ -132,7 +132,7 @@ var FolderCommand = /** @class */ (function (_super) {
132
132
  }
133
133
  sasjs = new node_1.default({
134
134
  serverUrl: target.serverUrl,
135
- allowInsecureRequests: target.allowInsecureRequests,
135
+ httpsAgentOptions: target.httpsAgentOptions,
136
136
  appLoc: target.appLoc,
137
137
  serverType: target.serverType
138
138
  });
@@ -259,7 +259,7 @@ var FolderCommand = /** @class */ (function (_super) {
259
259
  }
260
260
  sasjs = new node_1.default({
261
261
  serverUrl: target.serverUrl,
262
- allowInsecureRequests: target.allowInsecureRequests,
262
+ httpsAgentOptions: target.httpsAgentOptions,
263
263
  appLoc: target.appLoc,
264
264
  serverType: target.serverType
265
265
  });
@@ -52,7 +52,7 @@ describe('sasjs folder operations', function () {
52
52
  var target = generateTarget();
53
53
  var sasjs = new node_1.default({
54
54
  serverUrl: target.serverUrl,
55
- allowInsecureRequests: target.allowInsecureRequests,
55
+ httpsAgentOptions: target.httpsAgentOptions,
56
56
  appLoc: target.appLoc,
57
57
  serverType: target.serverType
58
58
  });
@@ -152,7 +152,7 @@ var JobCommand = /** @class */ (function (_super) {
152
152
  case 2:
153
153
  sasjs = new node_1.default({
154
154
  serverUrl: target.serverUrl,
155
- allowInsecureRequests: target.allowInsecureRequests,
155
+ httpsAgentOptions: target.httpsAgentOptions,
156
156
  appLoc: target.appLoc,
157
157
  serverType: target.serverType,
158
158
  debug: true
@@ -92,7 +92,7 @@ describe('sasjs job execute', function () {
92
92
  _a.sent();
93
93
  sasjs = new node_1.default({
94
94
  serverUrl: target.serverUrl,
95
- allowInsecureRequests: target.allowInsecureRequests,
95
+ httpsAgentOptions: target.httpsAgentOptions,
96
96
  appLoc: target.appLoc,
97
97
  serverType: target.serverType,
98
98
  debug: true
@@ -530,7 +530,7 @@ describe('sasjs job execute', function () {
530
530
  case 0:
531
531
  adapter = new node_1.default({
532
532
  serverUrl: target.serverUrl,
533
- allowInsecureRequests: target.allowInsecureRequests,
533
+ httpsAgentOptions: target.httpsAgentOptions,
534
534
  appLoc: target.appLoc,
535
535
  serverType: target.serverType
536
536
  });
@@ -102,7 +102,7 @@ function runSasJob(target, isLocal, sasJobLocation, dataFilePath, configFilePath
102
102
  }
103
103
  sasjs = new node_1.default({
104
104
  serverUrl: target.serverUrl,
105
- allowInsecureRequests: target.allowInsecureRequests,
105
+ httpsAgentOptions: target.httpsAgentOptions,
106
106
  appLoc: target.appLoc,
107
107
  serverType: target.serverType,
108
108
  contextName: target.contextName,
@@ -139,7 +139,7 @@ function executeOnSasViya(filePath, isTempFile, target, linesToExecute) {
139
139
  (_a = process.logger) === null || _a === void 0 ? void 0 : _a.info("Sending " + path_1.default.basename(filePath) + " to SAS server for execution.");
140
140
  sasjs = new node_1.default({
141
141
  serverUrl: target.serverUrl,
142
- allowInsecureRequests: target.allowInsecureRequests,
142
+ httpsAgentOptions: target.httpsAgentOptions,
143
143
  appLoc: target.appLoc,
144
144
  serverType: target.serverType,
145
145
  debug: true,
@@ -225,7 +225,7 @@ function executeOnSas9(filePath, isTempFile, target, linesToExecute) {
225
225
  password = utils_1.decodeFromBase64(password);
226
226
  sasjs = new node_1.default({
227
227
  serverUrl: target.serverUrl,
228
- allowInsecureRequests: target.allowInsecureRequests,
228
+ httpsAgentOptions: target.httpsAgentOptions,
229
229
  appLoc: target.appLoc,
230
230
  serverType: target.serverType,
231
231
  debug: true
@@ -61,7 +61,6 @@ describe('sasjs servicepack', function () {
61
61
  name: targetName,
62
62
  serverType: utils_1.ServerType.SasViya,
63
63
  serverUrl: process.env.VIYA_SERVER_URL,
64
- allowInsecureRequests: false,
65
64
  appLoc: "/Public/app/cli-tests/" + targetName,
66
65
  contextName: utils_2.contextName,
67
66
  authConfig: {
@@ -67,7 +67,7 @@ function deployToSasViyaWithServicePack(jsonFilePath, target, isLocal, isForced)
67
67
  throw new Error("Deployment failed. Request is not authenticated.\nPlease add the following variables to your .env" + (isLocal ? "." + target.name : '') + " file:\nCLIENT, SECRET, ACCESS_TOKEN, REFRESH_TOKEN");
68
68
  }
69
69
  sasjs = new node_1.default({
70
- allowInsecureRequests: target.allowInsecureRequests,
70
+ httpsAgentOptions: target.httpsAgentOptions,
71
71
  appLoc: target.appLoc,
72
72
  serverType: target.serverType,
73
73
  serverUrl: target.serverUrl,
@@ -144,7 +144,7 @@ function runTest(target, testRegExps, outDirectory, flowSourcePath) {
144
144
  flow.push(testFlow.testTearDown);
145
145
  sasjs = new node_1.default({
146
146
  serverUrl: target.serverUrl,
147
- allowInsecureRequests: target.allowInsecureRequests,
147
+ httpsAgentOptions: target.httpsAgentOptions,
148
148
  appLoc: target.appLoc,
149
149
  serverType: target.serverType,
150
150
  debug: true,
package/build/config.json CHANGED
@@ -241,7 +241,9 @@
241
241
  "name": "viya",
242
242
  "serverType": "SASVIYA",
243
243
  "serverUrl": "https://sas.analytium.co.uk",
244
- "allowInsecureRequests": false,
244
+ "httpsAgentOptions": {
245
+ "allowInsecureRequests": false
246
+ },
245
247
  "appLoc": "/Public/app",
246
248
  "contextName": "SAS Job Execution compute context",
247
249
  "buildConfig": {
@@ -234,26 +234,28 @@ exports.findTargetInConfiguration = findTargetInConfiguration;
234
234
  function getLocalTarget(targetName) {
235
235
  var _a;
236
236
  return __awaiter(this, void 0, void 0, function () {
237
- var localConfig, targetJson;
238
- return __generator(this, function (_b) {
239
- switch (_b.label) {
237
+ var localConfig, targetJson, _b;
238
+ return __generator(this, function (_c) {
239
+ switch (_c.label) {
240
240
  case 0: return [4 /*yield*/, getConfiguration(path_1.default.join(process.projectDir, 'sasjs', 'sasjsconfig.json')).catch(function () { return null; })];
241
241
  case 1:
242
- localConfig = _b.sent();
243
- if (localConfig === null || localConfig === void 0 ? void 0 : localConfig.targets) {
244
- targetJson = localConfig.targets.find(function (t) { return t.name === targetName; });
245
- if (targetJson) {
246
- (_a = process.logger) === null || _a === void 0 ? void 0 : _a.info("Target " + targetName + " was found in your local sasjsconfig.json file.");
247
- targetJson.appLoc = sanitizeAppLoc(targetJson.appLoc);
248
- if (!targetJson.hasOwnProperty('serverUrl')) {
249
- targetJson.serverUrl = '';
250
- }
251
- targetJson.serverUrl = utils_1.urlOrigin(targetJson.serverUrl);
252
- targetJson.allowInsecureRequests = getPrecedenceOfInsecureRequests(localConfig, targetJson);
253
- return [2 /*return*/, new utils_1.Target(targetJson)];
254
- }
242
+ localConfig = _c.sent();
243
+ if (!(localConfig === null || localConfig === void 0 ? void 0 : localConfig.targets)) return [3 /*break*/, 3];
244
+ targetJson = localConfig.targets.find(function (t) { return t.name === targetName; });
245
+ if (!targetJson) return [3 /*break*/, 3];
246
+ (_a = process.logger) === null || _a === void 0 ? void 0 : _a.info("Target " + targetName + " was found in your local sasjsconfig.json file.");
247
+ targetJson.appLoc = sanitizeAppLoc(targetJson.appLoc);
248
+ if (!targetJson.hasOwnProperty('serverUrl')) {
249
+ targetJson.serverUrl = '';
255
250
  }
256
- throw new Error(ERROR_MESSAGE(targetName).NOT_FOUND_TARGET_NAME);
251
+ targetJson.serverUrl = utils_1.urlOrigin(targetJson.serverUrl);
252
+ _b = targetJson;
253
+ return [4 /*yield*/, getPrecedenceOfHttpsAgentOptionsAndContent(localConfig, targetJson)];
254
+ case 2:
255
+ _b.httpsAgentOptions =
256
+ _c.sent();
257
+ return [2 /*return*/, new utils_1.Target(targetJson)];
258
+ case 3: throw new Error(ERROR_MESSAGE(targetName).NOT_FOUND_TARGET_NAME);
257
259
  }
258
260
  });
259
261
  });
@@ -261,31 +263,34 @@ function getLocalTarget(targetName) {
261
263
  function getLocalFallbackTarget() {
262
264
  var _a, _b;
263
265
  return __awaiter(this, void 0, void 0, function () {
264
- var localConfig, fallBackTargetJson, defaultTargetName_1;
265
- return __generator(this, function (_c) {
266
- switch (_c.label) {
266
+ var localConfig, fallBackTargetJson, defaultTargetName_1, _c;
267
+ return __generator(this, function (_d) {
268
+ switch (_d.label) {
267
269
  case 0: return [4 /*yield*/, getConfiguration(path_1.default.join(process.projectDir, 'sasjs', 'sasjsconfig.json')).catch(function () { return null; })];
268
270
  case 1:
269
- localConfig = _c.sent();
270
- if (!(localConfig === null || localConfig === void 0 ? void 0 : localConfig.targets)) return [3 /*break*/, 3];
271
+ localConfig = _d.sent();
272
+ if (!(localConfig === null || localConfig === void 0 ? void 0 : localConfig.targets)) return [3 /*break*/, 4];
271
273
  defaultTargetName_1 = localConfig === null || localConfig === void 0 ? void 0 : localConfig.defaultTarget;
272
274
  if (defaultTargetName_1) {
273
275
  fallBackTargetJson = (_a = localConfig === null || localConfig === void 0 ? void 0 : localConfig.targets) === null || _a === void 0 ? void 0 : _a.find(function (t) { return t.name === defaultTargetName_1; });
274
276
  }
275
- if (!fallBackTargetJson) return [3 /*break*/, 3];
277
+ if (!fallBackTargetJson) return [3 /*break*/, 4];
276
278
  (_b = process.logger) === null || _b === void 0 ? void 0 : _b.info("No target was specified. Falling back to default target '" + fallBackTargetJson.name + "' from your local sasjsconfig.json file.");
277
279
  fallBackTargetJson.appLoc = sanitizeAppLoc(fallBackTargetJson.appLoc);
278
280
  if (!fallBackTargetJson.hasOwnProperty('serverUrl')) {
279
281
  fallBackTargetJson.serverUrl = '';
280
282
  }
281
283
  fallBackTargetJson.serverUrl = utils_1.urlOrigin(fallBackTargetJson.serverUrl);
282
- fallBackTargetJson.allowInsecureRequests =
283
- getPrecedenceOfInsecureRequests(localConfig, fallBackTargetJson);
284
- return [4 /*yield*/, utils_2.loadEnvVariables(".env." + fallBackTargetJson.name)];
284
+ _c = fallBackTargetJson;
285
+ return [4 /*yield*/, getPrecedenceOfHttpsAgentOptionsAndContent(localConfig, fallBackTargetJson)];
285
286
  case 2:
286
- _c.sent();
287
+ _c.httpsAgentOptions =
288
+ _d.sent();
289
+ return [4 /*yield*/, utils_2.loadEnvVariables(".env." + fallBackTargetJson.name)];
290
+ case 3:
291
+ _d.sent();
287
292
  return [2 /*return*/, new utils_1.Target(fallBackTargetJson)];
288
- case 3: throw new Error(ERROR_MESSAGE().NOT_FOUND_FALLBACK);
293
+ case 4: throw new Error(ERROR_MESSAGE().NOT_FOUND_FALLBACK);
289
294
  }
290
295
  });
291
296
  });
@@ -293,26 +298,28 @@ function getLocalFallbackTarget() {
293
298
  function getGlobalTarget(targetName) {
294
299
  var _a;
295
300
  return __awaiter(this, void 0, void 0, function () {
296
- var globalConfig, targetJson;
297
- return __generator(this, function (_b) {
298
- switch (_b.label) {
301
+ var globalConfig, targetJson, _b;
302
+ return __generator(this, function (_c) {
303
+ switch (_c.label) {
299
304
  case 0: return [4 /*yield*/, getGlobalRcFile()];
300
305
  case 1:
301
- globalConfig = _b.sent();
302
- if (globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.targets) {
303
- targetJson = globalConfig.targets.find(function (t) { return t.name === targetName; });
304
- if (targetJson) {
305
- (_a = process.logger) === null || _a === void 0 ? void 0 : _a.info("Target " + targetName + " was found in your global .sasjsrc file.");
306
- targetJson.appLoc = sanitizeAppLoc(targetJson.appLoc);
307
- if (!targetJson.hasOwnProperty('serverUrl')) {
308
- targetJson.serverUrl = '';
309
- }
310
- targetJson.serverUrl = utils_1.urlOrigin(targetJson.serverUrl);
311
- targetJson.allowInsecureRequests = getPrecedenceOfInsecureRequests(globalConfig, targetJson);
312
- return [2 /*return*/, new utils_1.Target(targetJson)];
313
- }
306
+ globalConfig = _c.sent();
307
+ if (!(globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.targets)) return [3 /*break*/, 3];
308
+ targetJson = globalConfig.targets.find(function (t) { return t.name === targetName; });
309
+ if (!targetJson) return [3 /*break*/, 3];
310
+ (_a = process.logger) === null || _a === void 0 ? void 0 : _a.info("Target " + targetName + " was found in your global .sasjsrc file.");
311
+ targetJson.appLoc = sanitizeAppLoc(targetJson.appLoc);
312
+ if (!targetJson.hasOwnProperty('serverUrl')) {
313
+ targetJson.serverUrl = '';
314
314
  }
315
- throw new Error(ERROR_MESSAGE(targetName).NOT_FOUND_TARGET_NAME);
315
+ targetJson.serverUrl = utils_1.urlOrigin(targetJson.serverUrl);
316
+ _b = targetJson;
317
+ return [4 /*yield*/, getPrecedenceOfHttpsAgentOptionsAndContent(globalConfig, targetJson)];
318
+ case 2:
319
+ _b.httpsAgentOptions =
320
+ _c.sent();
321
+ return [2 /*return*/, new utils_1.Target(targetJson)];
322
+ case 3: throw new Error(ERROR_MESSAGE(targetName).NOT_FOUND_TARGET_NAME);
316
323
  }
317
324
  });
318
325
  });
@@ -320,27 +327,30 @@ function getGlobalTarget(targetName) {
320
327
  function getGlobalFallbackTarget() {
321
328
  var _a, _b;
322
329
  return __awaiter(this, void 0, void 0, function () {
323
- var globalConfig, fallBackTargetJson, defaultTargetName;
324
- return __generator(this, function (_c) {
325
- switch (_c.label) {
330
+ var globalConfig, fallBackTargetJson, defaultTargetName, _c;
331
+ return __generator(this, function (_d) {
332
+ switch (_d.label) {
326
333
  case 0: return [4 /*yield*/, getGlobalRcFile()];
327
334
  case 1:
328
- globalConfig = (_c.sent());
335
+ globalConfig = (_d.sent());
329
336
  defaultTargetName = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.defaultTarget;
330
337
  if (defaultTargetName) {
331
338
  fallBackTargetJson = (_a = globalConfig === null || globalConfig === void 0 ? void 0 : globalConfig.targets) === null || _a === void 0 ? void 0 : _a.find(function (t) { return t.name === defaultTargetName; });
332
339
  }
333
- if (fallBackTargetJson) {
334
- (_b = process.logger) === null || _b === void 0 ? void 0 : _b.info("No target was specified. Falling back to default target '" + fallBackTargetJson.name + "' from your global .sasjsrc file.");
335
- fallBackTargetJson.appLoc = sanitizeAppLoc(fallBackTargetJson.appLoc);
336
- if (!fallBackTargetJson.hasOwnProperty('serverUrl')) {
337
- fallBackTargetJson.serverUrl = '';
338
- }
339
- fallBackTargetJson.serverUrl = utils_1.urlOrigin(fallBackTargetJson.serverUrl);
340
- fallBackTargetJson.allowInsecureRequests = getPrecedenceOfInsecureRequests(globalConfig, fallBackTargetJson);
341
- return [2 /*return*/, new utils_1.Target(fallBackTargetJson)];
340
+ if (!fallBackTargetJson) return [3 /*break*/, 3];
341
+ (_b = process.logger) === null || _b === void 0 ? void 0 : _b.info("No target was specified. Falling back to default target '" + fallBackTargetJson.name + "' from your global .sasjsrc file.");
342
+ fallBackTargetJson.appLoc = sanitizeAppLoc(fallBackTargetJson.appLoc);
343
+ if (!fallBackTargetJson.hasOwnProperty('serverUrl')) {
344
+ fallBackTargetJson.serverUrl = '';
342
345
  }
343
- throw new Error(ERROR_MESSAGE().NOT_FOUND_FALLBACK);
346
+ fallBackTargetJson.serverUrl = utils_1.urlOrigin(fallBackTargetJson.serverUrl);
347
+ _c = fallBackTargetJson;
348
+ return [4 /*yield*/, getPrecedenceOfHttpsAgentOptionsAndContent(globalConfig, fallBackTargetJson)];
349
+ case 2:
350
+ _c.httpsAgentOptions =
351
+ _d.sent();
352
+ return [2 /*return*/, new utils_1.Target(fallBackTargetJson)];
353
+ case 3: throw new Error(ERROR_MESSAGE().NOT_FOUND_FALLBACK);
344
354
  }
345
355
  });
346
356
  });
@@ -798,7 +808,7 @@ function getAuthConfig(target) {
798
808
  if (!auth_1.isAccessTokenExpiring(access_token)) return [3 /*break*/, 7];
799
809
  sasjs = new node_1.default({
800
810
  serverUrl: target.serverUrl,
801
- allowInsecureRequests: target.allowInsecureRequests,
811
+ httpsAgentOptions: target.httpsAgentOptions,
802
812
  serverType: target.serverType
803
813
  });
804
814
  if (!auth_1.isRefreshTokenExpiring(refresh_token)) return [3 /*break*/, 4];
@@ -866,7 +876,7 @@ function getAccessToken(target, checkIfExpiring) {
866
876
  if (!(checkIfExpiring && auth_1.isAccessTokenExpiring(accessToken))) return [3 /*break*/, 7];
867
877
  sasjs = new node_1.default({
868
878
  serverUrl: target.serverUrl,
869
- allowInsecureRequests: target.allowInsecureRequests,
879
+ httpsAgentOptions: target.httpsAgentOptions,
870
880
  serverType: target.serverType
871
881
  });
872
882
  client = target.authConfig && target.authConfig.client
@@ -947,9 +957,39 @@ var overrideEnvVariables = function (targetName) { return __awaiter(void 0, void
947
957
  });
948
958
  }); };
949
959
  exports.overrideEnvVariables = overrideEnvVariables;
950
- var getPrecedenceOfInsecureRequests = function (config, target) {
951
- var _a;
952
- return (_a = target.allowInsecureRequests) !== null && _a !== void 0 ? _a : !!config.allowInsecureRequests;
960
+ var getPrecedenceOfHttpsAgentOptionsAndContent = function (config, target) { return __awaiter(void 0, void 0, void 0, function () {
961
+ var httpsAgentOptions, _a, _b, _c;
962
+ return __generator(this, function (_d) {
963
+ switch (_d.label) {
964
+ case 0:
965
+ httpsAgentOptions = getHttpsAgentOptionsForInsecure(__assign(__assign({ allowInsecureRequests: false }, config.httpsAgentOptions), target.httpsAgentOptions));
966
+ if (!httpsAgentOptions.caPath) return [3 /*break*/, 2];
967
+ _a = httpsAgentOptions;
968
+ return [4 /*yield*/, utils_1.readFile(httpsAgentOptions.caPath)];
969
+ case 1:
970
+ _a.ca = _d.sent();
971
+ _d.label = 2;
972
+ case 2:
973
+ if (!httpsAgentOptions.keyPath) return [3 /*break*/, 4];
974
+ _b = httpsAgentOptions;
975
+ return [4 /*yield*/, utils_1.readFile(httpsAgentOptions.keyPath)];
976
+ case 3:
977
+ _b.key = _d.sent();
978
+ _d.label = 4;
979
+ case 4:
980
+ if (!httpsAgentOptions.certPath) return [3 /*break*/, 6];
981
+ _c = httpsAgentOptions;
982
+ return [4 /*yield*/, utils_1.readFile(httpsAgentOptions.certPath)];
983
+ case 5:
984
+ _c.cert = _d.sent();
985
+ _d.label = 6;
986
+ case 6: return [2 /*return*/, httpsAgentOptions];
987
+ }
988
+ });
989
+ }); };
990
+ var getHttpsAgentOptionsForInsecure = function (options) {
991
+ return options.allowInsecureRequests
992
+ ? __assign({ rejectUnauthorized: false }, options) : options;
953
993
  };
954
994
  var getTestSetUp = function (target) { return __awaiter(void 0, void 0, void 0, function () {
955
995
  var projectRoot, localConfig;
@@ -147,7 +147,7 @@ var removeTestServerFolder = function (folderPath, target) { return __awaiter(vo
147
147
  }
148
148
  sasjs = new node_1.default({
149
149
  serverUrl: target.serverUrl,
150
- allowInsecureRequests: target.allowInsecureRequests,
150
+ httpsAgentOptions: target.httpsAgentOptions,
151
151
  appLoc: target.appLoc,
152
152
  serverType: target.serverType
153
153
  });
@@ -510,7 +510,7 @@ function getAdapterInstance(target) {
510
510
  var sasjs = new node_1.default({
511
511
  serverUrl: target.serverUrl,
512
512
  serverType: target.serverType,
513
- allowInsecureRequests: target.allowInsecureRequests,
513
+ httpsAgentOptions: target.httpsAgentOptions,
514
514
  contextName: target.contextName,
515
515
  useComputeApi: true,
516
516
  debug: process.env.LOG_LEVEL === utils_1.LogLevel.Debug
package/package.json CHANGED
@@ -53,10 +53,10 @@
53
53
  }
54
54
  },
55
55
  "dependencies": {
56
- "@sasjs/adapter": "2.12.0",
56
+ "@sasjs/adapter": "3.0.0",
57
57
  "@sasjs/core": "2.45.2",
58
58
  "@sasjs/lint": "1.11.2",
59
- "@sasjs/utils": "2.32.0",
59
+ "@sasjs/utils": "2.33.1",
60
60
  "chalk": "4.1.2",
61
61
  "csv-stringify": "5.6.5",
62
62
  "dotenv": "10.0.0",
@@ -93,7 +93,7 @@
93
93
  "ghooks": "2.0.4",
94
94
  "jest": "27.2.4",
95
95
  "jest-cli": "27.2.4",
96
- "jest-extended": "0.11.5",
96
+ "jest-extended": "1.1.0",
97
97
  "nodemon": "2.0.13",
98
98
  "semantic-release": "17.4.7",
99
99
  "ts-jest": "27.0.5",
@@ -101,7 +101,7 @@
101
101
  "tslib": "2.3.1",
102
102
  "typescript": "4.3.5",
103
103
  "util": "0.12.4",
104
- "validate-commit-msg": "2.14.0"
104
+ "validate-commit-msg": "1.1.3"
105
105
  },
106
- "version": "2.39.0"
106
+ "version": "3.0.0"
107
107
  }