botium-core 1.12.2 → 1.12.5

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.
@@ -79,7 +79,7 @@ var express__default = /*#__PURE__*/_interopDefaultLegacy(express);
79
79
  var bodyParser__default = /*#__PURE__*/_interopDefaultLegacy(bodyParser);
80
80
 
81
81
  var name = "botium-core";
82
- var version$1 = "1.12.2";
82
+ var version$1 = "1.12.5";
83
83
  var description = "The Selenium for Chatbots";
84
84
  var main = "index.js";
85
85
  var module$1 = "dist/botium-es.js";
@@ -111,25 +111,25 @@ var bugs = {
111
111
  };
112
112
  var homepage = "https://www.botium.ai";
113
113
  var dependencies = {
114
- "@babel/runtime": "^7.16.7",
114
+ "@babel/runtime": "^7.17.9",
115
115
  async: "^3.2.3",
116
- "body-parser": "^1.19.1",
117
- boolean: "^3.1.4",
116
+ "body-parser": "^1.20.0",
117
+ boolean: "^3.2.0",
118
118
  bottleneck: "^2.19.5",
119
119
  "csv-parse": "^5.0.4",
120
- debug: "^4.3.3",
120
+ debug: "^4.3.4",
121
121
  esprima: "^4.0.1",
122
- express: "^4.17.2",
122
+ express: "^4.17.3",
123
123
  globby: "11.0.4",
124
- ioredis: "^4.28.3",
124
+ ioredis: "^5.0.4",
125
125
  "is-class": "^0.0.9",
126
126
  "is-json": "^2.0.1",
127
127
  jsonpath: "^1.1.1",
128
128
  lodash: "^4.17.21",
129
129
  "markdown-it": "^12.3.2",
130
- "mime-types": "^2.1.34",
130
+ "mime-types": "^2.1.35",
131
131
  mkdirp: "^1.0.4",
132
- moment: "^2.29.1",
132
+ moment: "^2.29.3",
133
133
  mustache: "^4.2.0",
134
134
  "promise-retry": "^2.0.1",
135
135
  "promise.allsettled": "^1.0.5",
@@ -141,36 +141,36 @@ var dependencies = {
141
141
  "socket.io": "^4.4.1",
142
142
  "socket.io-client": "^4.4.1",
143
143
  "socketio-auth": "^0.1.1",
144
- "swagger-jsdoc": "^6.1.0",
144
+ "swagger-jsdoc": "^6.2.1",
145
145
  "swagger-ui-express": "^4.3.0",
146
146
  uuid: "^8.3.2",
147
- vm2: "^3.9.5",
147
+ vm2: "^3.9.9",
148
148
  "write-yaml": "^1.0.0",
149
- xlsx: "^0.17.5",
149
+ xlsx: "^0.18.5",
150
150
  xregexp: "^5.1.0",
151
- yaml: "^1.10.2"
151
+ yaml: "^2.0.1"
152
152
  };
153
153
  var devDependencies = {
154
- "@babel/core": "^7.16.12",
154
+ "@babel/core": "^7.17.9",
155
155
  "@babel/node": "^7.16.8",
156
- "@babel/plugin-transform-runtime": "^7.16.10",
156
+ "@babel/plugin-transform-runtime": "^7.17.0",
157
157
  "@babel/preset-env": "^7.16.11",
158
- chai: "^4.3.4",
158
+ chai: "^4.3.6",
159
159
  "chai-as-promised": "^7.1.1",
160
160
  "cross-env": "^7.0.3",
161
- eslint: "^8.7.0",
162
- "eslint-config-standard": "^16.0.3",
163
- "eslint-plugin-import": "^2.25.4",
164
- "eslint-plugin-node": "^11.1.0",
161
+ eslint: "^8.13.0",
162
+ "eslint-config-standard": "^17.0.0",
163
+ "eslint-plugin-import": "^2.26.0",
164
+ "eslint-plugin-n": "^15.1.0",
165
165
  "eslint-plugin-promise": "^6.0.0",
166
166
  "eslint-plugin-standard": "^4.1.0",
167
167
  "license-checker": "^25.0.1",
168
168
  "license-compatibility-checker": "^0.3.5",
169
- mocha: "^9.2.0",
170
- nock: "^13.2.2",
171
- "npm-check-updates": "^12.2.1",
169
+ mocha: "^9.2.2",
170
+ nock: "^13.2.4",
171
+ "npm-check-updates": "^12.5.9",
172
172
  nyc: "^15.1.0",
173
- rollup: "^2.66.0",
173
+ rollup: "^2.70.2",
174
174
  "rollup-plugin-babel": "^4.4.0",
175
175
  "rollup-plugin-commonjs": "^10.1.0",
176
176
  "rollup-plugin-json": "^4.0.0",
@@ -287,6 +287,11 @@ var Capabilities = {
287
287
  SIMPLEREST_RESPONSE_HOOK: 'SIMPLEREST_RESPONSE_HOOK',
288
288
  SIMPLEREST_MEDIA_JSONPATH: 'SIMPLEREST_MEDIA_JSONPATH',
289
289
  SIMPLEREST_BUTTONS_JSONPATH: 'SIMPLEREST_BUTTONS_JSONPATH',
290
+ SIMPLEREST_CARDS_JSONPATH: 'SIMPLEREST_CARDS_JSONPATH',
291
+ SIMPLEREST_CARD_TEXT_JSONPATH: 'SIMPLEREST_CARD_TEXT_JSONPATH',
292
+ SIMPLEREST_CARD_SUBTEXT_JSONPATH: 'SIMPLEREST_CARD_SUBTEXT_JSONPATH',
293
+ SIMPLEREST_CARD_BUTTONS_JSONPATH: 'SIMPLEREST_CARD_BUTTONS_JSONPATH',
294
+ SIMPLEREST_CARD_ATTACHMENTS_JSONPATH: 'SIMPLEREST_CARD_ATTACHMENTS_JSONPATH',
290
295
  SIMPLEREST_CONTEXT_JSONPATH: 'SIMPLEREST_CONTEXT_JSONPATH',
291
296
  SIMPLEREST_CONTEXT_MERGE_OR_REPLACE: 'SIMPLEREST_CONTEXT_MERGE_OR_REPLACE',
292
297
  SIMPLEREST_CONVERSATION_ID_TEMPLATE: 'SIMPLEREST_CONVERSATION_ID_TEMPLATE',
@@ -300,6 +305,7 @@ var Capabilities = {
300
305
  SIMPLEREST_REDIS_TOPIC: 'SIMPLEREST_REDIS_TOPIC',
301
306
  SIMPLEREST_INBOUND_ORDER_UNSETTLED_EVENTS_JSONPATH: 'SIMPLEREST_INBOUND_ORDER_UNSETTLED_EVENTS_JSONPATH',
302
307
  SIMPLEREST_INBOUND_DEBOUNCE_TIMEOUT: 'SIMPLEREST_INBOUND_DEBOUNCE_TIMEOUT',
308
+ SIMPLEREST_COOKIE_REPLICATION: 'SIMPLEREST_COOKIE_REPLICATION',
303
309
  // Script Compiler
304
310
  SCRIPTING_TXT_EOL: 'SCRIPTING_TXT_EOL',
305
311
  // ROW_PER_MESSAGE or QUESTION_ANSWER
@@ -433,6 +439,11 @@ Capabilities.SIMPLEREST_RESPONSE_JSONPATH;
433
439
  Capabilities.SIMPLEREST_RESPONSE_HOOK;
434
440
  Capabilities.SIMPLEREST_MEDIA_JSONPATH;
435
441
  Capabilities.SIMPLEREST_BUTTONS_JSONPATH;
442
+ Capabilities.SIMPLEREST_CARDS_JSONPATH;
443
+ Capabilities.SIMPLEREST_CARD_TEXT_JSONPATH;
444
+ Capabilities.SIMPLEREST_CARD_SUBTEXT_JSONPATH;
445
+ Capabilities.SIMPLEREST_CARD_BUTTONS_JSONPATH;
446
+ Capabilities.SIMPLEREST_CARD_ATTACHMENTS_JSONPATH;
436
447
  Capabilities.SIMPLEREST_CONTEXT_JSONPATH;
437
448
  Capabilities.SIMPLEREST_CONTEXT_MERGE_OR_REPLACE;
438
449
  Capabilities.SIMPLEREST_CONVERSATION_ID_TEMPLATE;
@@ -446,6 +457,7 @@ Capabilities.SIMPLEREST_INBOUND_UPDATE_CONTEXT;
446
457
  Capabilities.SIMPLEREST_REDIS_TOPIC;
447
458
  Capabilities.SIMPLEREST_INBOUND_ORDER_UNSETTLED_EVENTS_JSONPATH;
448
459
  Capabilities.SIMPLEREST_INBOUND_DEBOUNCE_TIMEOUT;
460
+ Capabilities.SIMPLEREST_COOKIE_REPLICATION;
449
461
  Capabilities.SCRIPTING_TXT_EOL;
450
462
  Capabilities.SCRIPTING_XLSX_MODE;
451
463
  Capabilities.SCRIPTING_XLSX_EOL_WRITE;
@@ -541,10 +553,10 @@ var Defaults$1 = {
541
553
  [Capabilities.SIMPLEREST_METHOD]: 'GET',
542
554
  [Capabilities.SIMPLEREST_IGNORE_EMPTY]: true,
543
555
  [Capabilities.SIMPLEREST_TIMEOUT]: 10000,
544
- [Capabilities.SIMPLEREST_EXTRA_OPTIONS]: {},
545
556
  [Capabilities.SIMPLEREST_STRICT_SSL]: true,
546
557
  [Capabilities.SIMPLEREST_INBOUND_UPDATE_CONTEXT]: true,
547
558
  [Capabilities.SIMPLEREST_CONTEXT_MERGE_OR_REPLACE]: 'MERGE',
559
+ [Capabilities.SIMPLEREST_COOKIE_REPLICATION]: true,
548
560
  [Capabilities.SCRIPTING_TXT_EOL]: '\n',
549
561
  [Capabilities.SCRIPTING_XLSX_EOL_WRITE]: '\r\n',
550
562
  [Capabilities.SCRIPTING_XLSX_HASHEADERS]: true,
@@ -2339,7 +2351,7 @@ const linesToScriptingMemories$2 = (lines, columnMode = null) => {
2339
2351
  header: {
2340
2352
  name: caseName
2341
2353
  },
2342
- values: values
2354
+ values
2343
2355
  };
2344
2356
  scriptingMemories.push(scriptingMemory);
2345
2357
  }
@@ -2989,7 +3001,7 @@ class Convo$6 {
2989
3001
  },
2990
3002
  container,
2991
3003
  transcript,
2992
- scriptingMemory: scriptingMemory
3004
+ scriptingMemory
2993
3005
  });
2994
3006
  } catch (err) {
2995
3007
  throw new TranscriptError(botiumErrorFromErr$1(`${this.header.name}: ${err.message}`, err), transcript);
@@ -3006,7 +3018,7 @@ class Convo$6 {
3006
3018
  },
3007
3019
  container,
3008
3020
  transcript,
3009
- scriptingMemory: scriptingMemory
3021
+ scriptingMemory
3010
3022
  });
3011
3023
  } catch (err) {
3012
3024
  assertConvoEndErr = botiumErrorFromErr$1(`${this.header.name}: ${err.message}`, err);
@@ -3032,7 +3044,7 @@ class Convo$6 {
3032
3044
  },
3033
3045
  container,
3034
3046
  transcript,
3035
- scriptingMemory: scriptingMemory
3047
+ scriptingMemory
3036
3048
  });
3037
3049
  } catch (err) {
3038
3050
  transcript.err = botiumErrorFromErr$1(`${this.header.name}: ${err.message}`, err);
@@ -3094,7 +3106,8 @@ class Convo$6 {
3094
3106
  scriptingMemory,
3095
3107
  meMsg,
3096
3108
  transcript,
3097
- transcriptStep
3109
+ transcriptStep,
3110
+ transcriptSteps
3098
3111
  });
3099
3112
  await this.scriptingEvents.onMeStart({
3100
3113
  convo: this,
@@ -3103,7 +3116,8 @@ class Convo$6 {
3103
3116
  scriptingMemory,
3104
3117
  meMsg,
3105
3118
  transcript,
3106
- transcriptStep
3119
+ transcriptStep,
3120
+ transcriptSteps
3107
3121
  });
3108
3122
  await this.scriptingEvents.onMePrepare({
3109
3123
  convo: this,
@@ -3112,7 +3126,8 @@ class Convo$6 {
3112
3126
  scriptingMemory,
3113
3127
  meMsg,
3114
3128
  transcript,
3115
- transcriptStep
3129
+ transcriptStep,
3130
+ transcriptSteps
3116
3131
  });
3117
3132
  await this._checkBotRepliesConsumed(container);
3118
3133
 
@@ -3807,7 +3822,7 @@ const optionalJson = json => {
3807
3822
  const body = isJson(json);
3808
3823
  return body ? {
3809
3824
  'content-type': 'application/json',
3810
- body: body
3825
+ body
3811
3826
  } : {
3812
3827
  'content-type': 'text/plain',
3813
3828
  body: json
@@ -4875,7 +4890,7 @@ var CompilerXlsx_1 = class CompilerXlsx extends CompilerBase_1 {
4875
4890
  header: {
4876
4891
  name: caseName
4877
4892
  },
4878
- values: values
4893
+ values
4879
4894
  });
4880
4895
  }
4881
4896
  } else {
@@ -4918,7 +4933,7 @@ var CompilerXlsx_1 = class CompilerXlsx extends CompilerBase_1 {
4918
4933
  header: {
4919
4934
  name: caseName
4920
4935
  },
4921
- values: values
4936
+ values
4922
4937
  });
4923
4938
  } else {
4924
4939
  break;
@@ -7264,7 +7279,7 @@ var ScriptingProvider_1 = class ScriptingProvider {
7264
7279
  const node = {
7265
7280
  sender: convoNode.sender,
7266
7281
  key: randomatic__default["default"]('0', 20),
7267
- hash: hash,
7282
+ hash,
7268
7283
  convoNodes: convoNodeValues,
7269
7284
  convos: [lodash__default["default"].cloneDeep(convoNodeHeader)],
7270
7285
  childNodes: []
@@ -8143,6 +8158,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8143
8158
 
8144
8159
  this.processInbound = false;
8145
8160
  this.redisTopic = this.caps[Capabilities.SIMPLEREST_REDIS_TOPIC] || 'SIMPLEREST_INBOUND_SUBSCRIPTION';
8161
+ this.cookies = {};
8146
8162
 
8147
8163
  if (this.caps[Capabilities.SIMPLEREST_INBOUND_ORDER_UNSETTLED_EVENTS_JSONPATH]) {
8148
8164
  const debounceTimeout = this.caps[Capabilities.SIMPLEREST_INBOUND_DEBOUNCE_TIMEOUT] || 500;
@@ -8427,31 +8443,82 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8427
8443
  }
8428
8444
 
8429
8445
  for (const jsonPathRoot of jsonPathRoots) {
8430
- const media = [];
8431
- const buttons = [];
8432
- const jsonPathsMedia = getAllCapValues(Capabilities.SIMPLEREST_MEDIA_JSONPATH, this.caps);
8433
- jsonPathsMedia.forEach(jsonPath => {
8434
- const responseMedia = jsonpath__default["default"].query(jsonPathRoot, jsonPath);
8435
-
8436
- if (responseMedia) {
8437
- (lodash__default["default"].isArray(responseMedia) ? lodash__default["default"].flattenDeep(responseMedia) : [responseMedia]).forEach(m => media.push({
8438
- mediaUri: m,
8439
- mimeType: mimeTypes__default["default"].lookup(m) || 'application/unknown'
8440
- }));
8441
- debug$4(`found response media: ${util__default["default"].inspect(media)}`);
8446
+ const _retrieveMedia = (jsonPathMediaRoot, jsonPathsMedia) => {
8447
+ const retrievedMedia = [];
8448
+ jsonPathsMedia.forEach(jsonPath => {
8449
+ const responseMedia = jsonpath__default["default"].query(jsonPathMediaRoot, jsonPath);
8450
+
8451
+ if (responseMedia) {
8452
+ (lodash__default["default"].isArray(responseMedia) ? lodash__default["default"].flattenDeep(responseMedia) : [responseMedia]).forEach(m => retrievedMedia.push({
8453
+ mediaUri: m,
8454
+ mimeType: mimeTypes__default["default"].lookup(m) || 'application/unknown'
8455
+ }));
8456
+ }
8457
+ });
8458
+ return retrievedMedia;
8459
+ };
8460
+
8461
+ const _retrieveButtons = (jsonPathButtonRoot, jsonPathsButtons) => {
8462
+ const retrievedButtons = [];
8463
+ jsonPathsButtons.forEach(jsonPath => {
8464
+ const responseButtons = jsonpath__default["default"].query(jsonPathButtonRoot, jsonPath);
8465
+
8466
+ if (responseButtons) {
8467
+ (lodash__default["default"].isArray(responseButtons) ? lodash__default["default"].flattenDeep(responseButtons) : [responseButtons]).forEach(b => retrievedButtons.push({
8468
+ text: b
8469
+ }));
8470
+ }
8471
+ });
8472
+ return retrievedButtons;
8473
+ };
8474
+
8475
+ const _getCardText = responseCardText => {
8476
+ if (responseCardText) {
8477
+ const texts = lodash__default["default"].isArray(responseCardText) ? lodash__default["default"].flattenDeep(responseCardText) : [responseCardText];
8478
+
8479
+ if (texts.length > 1) {
8480
+ debug$4(`more than one text found for card: ${util__default["default"].inspect(texts)}`);
8481
+ }
8482
+
8483
+ if (texts.length > 0) {
8484
+ return texts[0];
8485
+ }
8442
8486
  }
8443
- });
8444
- const jsonPathsButtons = getAllCapValues(Capabilities.SIMPLEREST_BUTTONS_JSONPATH, this.caps);
8445
- jsonPathsButtons.forEach(jsonPath => {
8446
- const responseButtons = jsonpath__default["default"].query(jsonPathRoot, jsonPath);
8447
-
8448
- if (responseButtons) {
8449
- (lodash__default["default"].isArray(responseButtons) ? lodash__default["default"].flattenDeep(responseButtons) : [responseButtons]).forEach(b => buttons.push({
8450
- text: b
8451
- }));
8452
- debug$4(`found response buttons: ${util__default["default"].inspect(buttons)}`);
8487
+ };
8488
+
8489
+ const media = _retrieveMedia(jsonPathRoot, getAllCapValues(Capabilities.SIMPLEREST_MEDIA_JSONPATH, this.caps));
8490
+
8491
+ debug$4(`found response media: ${util__default["default"].inspect(media)}`);
8492
+
8493
+ const buttons = _retrieveButtons(jsonPathRoot, getAllCapValues(Capabilities.SIMPLEREST_BUTTONS_JSONPATH, this.caps));
8494
+
8495
+ debug$4(`found response buttons: ${util__default["default"].inspect(buttons)}`);
8496
+ const cards = [];
8497
+ const jsonPathsCards = getAllCapValues(Capabilities.SIMPLEREST_CARDS_JSONPATH, this.caps);
8498
+ jsonPathsCards.forEach(jsonPath => {
8499
+ const responseCards = jsonpath__default["default"].query(jsonPathRoot, jsonPath);
8500
+
8501
+ if (responseCards) {
8502
+ (lodash__default["default"].isArray(responseCards) ? lodash__default["default"].flattenDeep(responseCards) : [responseCards]).forEach(c => {
8503
+ const card = {};
8504
+ const jsonPathsCardText = getAllCapValues(Capabilities.SIMPLEREST_CARD_TEXT_JSONPATH, this.caps);
8505
+ jsonPathsCardText.forEach(jsonPath => {
8506
+ card.text = _getCardText(jsonpath__default["default"].query(c, jsonPath));
8507
+ });
8508
+ const jsonPathsCardSubText = getAllCapValues(Capabilities.SIMPLEREST_CARD_SUBTEXT_JSONPATH, this.caps);
8509
+ jsonPathsCardSubText.forEach(jsonPath => {
8510
+ card.subtext = _getCardText(jsonpath__default["default"].query(c, jsonPath));
8511
+ });
8512
+ card.buttons = _retrieveButtons(c, getAllCapValues(Capabilities.SIMPLEREST_CARD_BUTTONS_JSONPATH, this.caps));
8513
+ card.media = _retrieveMedia(c, getAllCapValues(Capabilities.SIMPLEREST_CARD_ATTACHMENTS_JSONPATH, this.caps));
8514
+
8515
+ if (lodash__default["default"].keys(card).length > 0) {
8516
+ cards.push(card);
8517
+ }
8518
+ });
8453
8519
  }
8454
8520
  });
8521
+ debug$4(`found response cards: ${util__default["default"].inspect(cards)}`);
8455
8522
  let hasMessageText = false;
8456
8523
  const jsonPathsTexts = getAllCapValues(Capabilities.SIMPLEREST_RESPONSE_JSONPATH, this.caps);
8457
8524
 
@@ -8468,7 +8535,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8468
8535
  sourceData: body,
8469
8536
  messageText,
8470
8537
  media,
8471
- buttons
8538
+ buttons,
8539
+ cards
8472
8540
  };
8473
8541
  await executeHook(this.caps, this.responseHook, Object.assign({
8474
8542
  botMsg,
@@ -8484,7 +8552,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8484
8552
  messageText: '',
8485
8553
  sourceData: body,
8486
8554
  media,
8487
- buttons
8555
+ buttons,
8556
+ cards
8488
8557
  };
8489
8558
  const beforeHookKeys = Object.keys(botMsg);
8490
8559
  await executeHook(this.caps, this.responseHook, Object.assign({
@@ -8493,7 +8562,7 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8493
8562
  }, this.view));
8494
8563
  const afterHookKeys = Object.keys(botMsg);
8495
8564
 
8496
- if (beforeHookKeys.length !== afterHookKeys.length || !!(botMsg.messageText && botMsg.messageText.length > 0) || botMsg.media.length > 0 || botMsg.buttons.length > 0 || !this.caps[Capabilities.SIMPLEREST_IGNORE_EMPTY]) {
8565
+ if (beforeHookKeys.length !== afterHookKeys.length || !!(botMsg.messageText && botMsg.messageText.length > 0) || botMsg.media.length > 0 || botMsg.buttons.length > 0 || botMsg.cards.length > 0 || !this.caps[Capabilities.SIMPLEREST_IGNORE_EMPTY]) {
8497
8566
  result.push(botMsg);
8498
8567
  }
8499
8568
  }
@@ -8537,6 +8606,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8537
8606
  if (body) {
8538
8607
  debug$4(`got response code: ${response.statusCode}, body: ${Utils.shortenJsonString(body)}`);
8539
8608
 
8609
+ this._storeCookiesFromResponse(response);
8610
+
8540
8611
  try {
8541
8612
  body = await this._parseResponseBody(body);
8542
8613
  } catch (err) {
@@ -8659,6 +8730,9 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8659
8730
  await executeHook(this.caps, this.requestHook, Object.assign({
8660
8731
  requestOptions
8661
8732
  }, this.view));
8733
+
8734
+ this._addRequestCookies(requestOptions);
8735
+
8662
8736
  return requestOptions;
8663
8737
  }
8664
8738
 
@@ -8703,6 +8777,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8703
8777
  } else {
8704
8778
  debug$4(`_waitForUrlResponse success on url check ${pingConfig.uri}: ${response.statusCode}/${response.statusMessage}`);
8705
8779
 
8780
+ this._storeCookiesFromResponse(response);
8781
+
8706
8782
  if (debug$4.enabled && body) {
8707
8783
  debug$4(Utils.shortenJsonString(body));
8708
8784
  }
@@ -8887,9 +8963,9 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8887
8963
 
8888
8964
  const pollConfig = {
8889
8965
  method: verb,
8890
- uri: uri,
8966
+ uri,
8891
8967
  followAllRedirects: true,
8892
- timeout: timeout
8968
+ timeout
8893
8969
  };
8894
8970
 
8895
8971
  if (this.caps[Capabilities.SIMPLEREST_POLL_HEADERS]) {
@@ -8924,6 +9000,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8924
9000
  return;
8925
9001
  }
8926
9002
 
9003
+ this._addRequestCookies(pollConfig);
9004
+
8927
9005
  request__default["default"](pollConfig, async (err, response, body) => {
8928
9006
  if (err) {
8929
9007
  debug$4(`_runPolling: rest request failed: ${err.message}, request: ${JSON.stringify(pollConfig)}`);
@@ -8937,6 +9015,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8937
9015
  } else if (body) {
8938
9016
  debug$4(`_runPolling: got response code: ${response.statusCode}, body: ${Utils.shortenJsonString(body)}`);
8939
9017
 
9018
+ this._storeCookiesFromResponse(response);
9019
+
8940
9020
  try {
8941
9021
  body = await this._parseResponseBody(body);
8942
9022
  } catch (err) {
@@ -8981,9 +9061,9 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
8981
9061
 
8982
9062
  const httpConfig = {
8983
9063
  method: verb,
8984
- uri: uri,
9064
+ uri,
8985
9065
  followAllRedirects: true,
8986
- timeout: timeout
9066
+ timeout
8987
9067
  };
8988
9068
 
8989
9069
  if (this.caps[`${capPrefix}_HEADERS`]) {
@@ -9011,6 +9091,8 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
9011
9091
  requestOptions: httpConfig
9012
9092
  }, this.view));
9013
9093
 
9094
+ this._addRequestCookies(httpConfig);
9095
+
9014
9096
  const retries = this._getCapValue(`${capPrefix}_RETRIES`);
9015
9097
 
9016
9098
  debug$4(`_makeCall(${capPrefix}): rest request: ${JSON.stringify(httpConfig)}`);
@@ -9030,6 +9112,43 @@ var SimpleRestContainer_1 = class SimpleRestContainer {
9030
9112
  }
9031
9113
  }
9032
9114
 
9115
+ _addRequestCookies(requestOptions) {
9116
+ if (!this.caps[Capabilities.SIMPLEREST_COOKIE_REPLICATION] || !requestOptions) {
9117
+ return;
9118
+ }
9119
+
9120
+ const url = new URL(requestOptions.uri);
9121
+
9122
+ if (!requestOptions.headers) {
9123
+ requestOptions.headers = {};
9124
+ }
9125
+
9126
+ requestOptions.headers.Cookie = requestOptions.headers.Cookie ? `${requestOptions.headers.Cookie}; ${this.cookies[url.host]}` : this.cookies[url.host];
9127
+ }
9128
+
9129
+ _storeCookiesFromResponse(response) {
9130
+ if (!this.caps[Capabilities.SIMPLEREST_COOKIE_REPLICATION] || !response) {
9131
+ return;
9132
+ }
9133
+
9134
+ const responseCookies = response.headers['set-cookie'];
9135
+
9136
+ if (!responseCookies) {
9137
+ return;
9138
+ }
9139
+
9140
+ const host = lodash__default["default"].get(response, 'request.uri.host');
9141
+
9142
+ let cookie;
9143
+ responseCookies.forEach(cookieString => {
9144
+ cookie = cookie ? `${cookie}; ${cookieString}` : cookieString;
9145
+ });
9146
+
9147
+ if (cookie) {
9148
+ this.cookies[host] = cookie;
9149
+ }
9150
+ }
9151
+
9033
9152
  };
9034
9153
 
9035
9154
  const debug$3 = debug__default["default"]('botium-connector-PluginConnectorContainer-helper');
@@ -9104,7 +9223,7 @@ const tryLoadPlugin$1 = (containermode, modulepath, args) => {
9104
9223
  source: 'src/containers/plugins/index.js',
9105
9224
  cause: {
9106
9225
  SECURITY_ALLOW_UNSAFE: caps[Capabilities.SECURITY_ALLOW_UNSAFE],
9107
- mode: mode,
9226
+ mode,
9108
9227
  ...cause
9109
9228
  }
9110
9229
  });
@@ -9459,18 +9578,28 @@ var BotDriver_1 = class BotDriver {
9459
9578
 
9460
9579
  Build() {
9461
9580
  debug$1(`Build - Botium Core Version: ${version}`);
9462
- debug$1(`Build - Capabilites: ${util__default["default"].inspect(this.caps)}`);
9463
- debug$1(`Build - Sources : ${util__default["default"].inspect(this.sources)}`);
9464
- debug$1(`Build - Envs : ${util__default["default"].inspect(this.envs)}`);
9581
+ debug$1(`Build - Capabilites: ${JSON.stringify(lodash__default["default"].pickBy(this.caps, (value, key) => Defaults$1.Capabilities[key] !== value), null, 2)}`);
9582
+ debug$1(`Build - Sources: ${JSON.stringify(lodash__default["default"].pickBy(this.sources, (value, key) => Defaults$1.Sources[key] !== value), null, 2)}`);
9583
+ debug$1(`Build - Envs: ${JSON.stringify(lodash__default["default"].pickBy(this.envs, (value, key) => Defaults$1.Envs[key] !== value), null, 2)}`);
9465
9584
  this.eventEmitter.emit(Events.CONTAINER_BUILDING);
9466
9585
  return new Promise((resolve, reject) => {
9586
+ let tempDirectory = null;
9467
9587
  let repo = null;
9468
9588
  let container = null;
9469
9589
  async__default["default"].series([driverValidated => {
9470
9590
  this._validate().then(() => driverValidated()).catch(driverValidated);
9591
+ }, tempDirectoryCreated => {
9592
+ tempDirectory = path__default["default"].resolve(process.cwd(), this.caps[Capabilities.TEMPDIR], sanitizeFilename__default["default"](`${this.caps[Capabilities.PROJECTNAME]} ${moment__default["default"]().format('YYYYMMDD HHmmss')} ${randomatic__default["default"]('Aa0', 5)}`));
9593
+
9594
+ try {
9595
+ mkdirp__default["default"].sync(tempDirectory);
9596
+ tempDirectoryCreated();
9597
+ } catch (err) {
9598
+ tempDirectoryCreated(new Error(`Unable to create temp directory ${tempDirectory}: ${err.message}`));
9599
+ }
9471
9600
  }, repoValidated => {
9472
9601
  try {
9473
- repo = this._getRepo();
9602
+ repo = this._getRepo(tempDirectory);
9474
9603
  } catch (err) {
9475
9604
  return repoValidated(err);
9476
9605
  }
@@ -9480,7 +9609,7 @@ var BotDriver_1 = class BotDriver {
9480
9609
  repo.Prepare().then(() => repoPrepared()).catch(repoPrepared);
9481
9610
  }, containerValidated => {
9482
9611
  try {
9483
- container = this._getContainer(repo);
9612
+ container = this._getContainer(tempDirectory, repo);
9484
9613
  } catch (err) {
9485
9614
  return containerValidated(err);
9486
9615
  }
@@ -9493,9 +9622,9 @@ var BotDriver_1 = class BotDriver {
9493
9622
  debug$1(`BotDriver Build error: ${err}`);
9494
9623
  this.eventEmitter.emit(Events.CONTAINER_BUILD_ERROR, err);
9495
9624
 
9496
- if (this.tempDirectory) {
9497
- rimraf__default["default"](this.tempDirectory, err => {
9498
- if (err) debug$1(`Cleanup temp dir ${this.tempDirectory} failed: ${util__default["default"].inspect(err)}`);
9625
+ if (tempDirectory) {
9626
+ rimraf__default["default"](tempDirectory, err => {
9627
+ if (err) debug$1(`Cleanup temp dir ${tempDirectory} failed: ${util__default["default"].inspect(err)}`);
9499
9628
  });
9500
9629
  }
9501
9630
 
@@ -9671,14 +9800,6 @@ var BotDriver_1 = class BotDriver {
9671
9800
  throw new Error(`Capability '${Capabilities.CONTAINERMODE}' or '${Capabilities.BOTIUMGRIDURL}' missing`);
9672
9801
  }
9673
9802
 
9674
- this.tempDirectory = path__default["default"].resolve(process.cwd(), this.caps[Capabilities.TEMPDIR], sanitizeFilename__default["default"](`${this.caps[Capabilities.PROJECTNAME]} ${moment__default["default"]().format('YYYYMMDD HHmmss')} ${randomatic__default["default"]('Aa0', 5)}`));
9675
-
9676
- try {
9677
- mkdirp__default["default"].sync(this.tempDirectory);
9678
- } catch (err) {
9679
- throw new Error(`Unable to create temp directory ${this.tempDirectory}: ${err}`);
9680
- }
9681
-
9682
9803
  resolve(this);
9683
9804
  } catch (err) {
9684
9805
  reject(err);
@@ -9686,29 +9807,29 @@ var BotDriver_1 = class BotDriver {
9686
9807
  });
9687
9808
  }
9688
9809
 
9689
- _getRepo() {
9810
+ _getRepo(tempDirectory) {
9690
9811
  if (this.caps[Capabilities.BOTIUMGRIDURL]) {
9691
9812
  const NoRepo = NoRepo_1;
9692
- return new NoRepo(this.tempDirectory, this.sources);
9813
+ return new NoRepo(tempDirectory, this.sources);
9693
9814
  }
9694
9815
 
9695
9816
  if (this.sources[Source.GITURL]) {
9696
9817
  const GitRepo = GitRepo_1;
9697
- return new GitRepo(this.tempDirectory, this.sources);
9818
+ return new GitRepo(tempDirectory, this.sources);
9698
9819
  }
9699
9820
 
9700
9821
  if (this.sources[Source.LOCALPATH]) {
9701
9822
  const LocalRepo = LocalRepo_1;
9702
- return new LocalRepo(this.tempDirectory, this.sources);
9823
+ return new LocalRepo(tempDirectory, this.sources);
9703
9824
  }
9704
9825
 
9705
9826
  throw new Error(`No Repo provider found for Sources ${util__default["default"].inspect(this.sources)}`);
9706
9827
  }
9707
9828
 
9708
- _getContainer(repo) {
9829
+ _getContainer(tempDirectory, repo) {
9709
9830
  if (this.caps[Capabilities.BOTIUMGRIDURL]) {
9710
9831
  const GridContainer = GridContainer_1;
9711
- return new GridContainer(this.eventEmitter, this.tempDirectory, repo, this.caps, this.envs);
9832
+ return new GridContainer(this.eventEmitter, tempDirectory, repo, this.caps, this.envs);
9712
9833
  }
9713
9834
 
9714
9835
  if (!this.caps[Capabilities.CONTAINERMODE]) {
@@ -9717,11 +9838,11 @@ var BotDriver_1 = class BotDriver {
9717
9838
 
9718
9839
  if (this.caps[Capabilities.CONTAINERMODE] === 'inprocess') {
9719
9840
  const InProcessContainer = InProcessContainer_1;
9720
- return new InProcessContainer(this.eventEmitter, this.tempDirectory, repo, this.caps, this.envs);
9841
+ return new InProcessContainer(this.eventEmitter, tempDirectory, repo, this.caps, this.envs);
9721
9842
  }
9722
9843
 
9723
9844
  const PluginConnectorContainer = PluginConnectorContainer_1;
9724
- return new PluginConnectorContainer(this.eventEmitter, this.tempDirectory, repo, this.caps, this.envs);
9845
+ return new PluginConnectorContainer(this.eventEmitter, tempDirectory, repo, this.caps, this.envs);
9725
9846
  }
9726
9847
 
9727
9848
  };